All Versions
54
Latest Version
Avg Release Cycle
14 days
Latest Release
1057 days ago

Changelog History
Page 6

  • v2.0.0 Changes

    March 26, 2017

    ๐Ÿ‘• Closed Issues

    โž• Added

    • โœ… You can write tests alternatively into a lambda parameter in the class constructor, eg:
    class StringSpecExample : StringSpec({
      "strings.size should return size of string" {
        "hello".length shouldBe 5
        "hello" should haveLength(5)
      }
    })
    
    • โž• Added forNone for table tests, eg
    val table = table(
        headers("a", "b"),
        row(0L, 2L),
        row(2L, 2L),
        row(4L, 5L),
        row(4L, 6L)
    )
    
    forNone(table) { a, b ->
      3 shouldBe between(a, b)
    }
    
    • ๐Ÿ‘€ Interceptors have been added. Interceptors allow code to be executed before and after a test. See the main readme for more info.

    • ๐Ÿ‘€ Simplified ability to add custom matchers. Simple implement Matcher<T> interface. See readme for more information.

    • โž• Added shouldNot to invert matchers. Eg, "hello" shouldNot include("hallo")

    • ๐Ÿ—„ Deprecated matchers which do not implement Matcher. Eg, should have substring(x) has been deprecated in favour of "hello" should include("l"). This is because instances of Matcher can be combined with or and and and can be negated with shouldNot.

    • โž• Added between matcher for int and long, eg

    3 shouldBe between(2, 5)

    • Added singleElement matcher for collections, eg

    x shouldBe singleElement(y)

    • โž• Added sorted matcher for collections, eg

    listOf(1,2,3) shouldBe sorted<Int>()

    • Now supports comparsion of arrays #116

    • Added Gen.oneOf to create a generator that returns one of the values for the given Enum class.

    Changed

    • Tags are objects derived from Tag class now.
    • Tags can now be included and/or exluded. It is no longer the case that all untagged tests are always executed.
    • Fixed bugs with parenthesis breaking layout in Intellij #112

    Removed

    • FlatSpec was removed because it has an irregular syntax with config and is essentially the same as StringSpec, but more complicated.
    • Deprecated method overloads with duration: Long, unit: TimeUnit
    • expecting for testing exceptions (use shouldThrow now)
  • v1.3.2 Changes

    July 05, 2016

    ๐Ÿ”„ Changed

    • โž• Added a shouldBe exactly(b) matcher for doubles

    • ๐Ÿ‘• kotlintest only pulls in mockito-core now instead of mockito-all

  • v1.3.1 Changes

    July 03, 2016

    ๐Ÿ”„ Changed

    • โฌ†๏ธ Bumped Kotlin version to 1.0.3
  • v1.3.0 Changes

    July 03, 2016

    ๐Ÿ‘• Closed Issues

    โž• Added

    • โœ… StringSpec. You can use simply use Strings as the basis for tests, eg:
    class StringSpecExample : StringSpec() {
      init {
        "strings.size should return size of string" {
          "hello".length shouldBe 5
          "hello" should haveLength(5)
        }
    
        "strings should support config" {
          "hello".length shouldBe 5
        }.config(invocations = 5)
      }
    }
    
    • โœ… Table Tests. Tables allow you to manually specific combinations of values that should be used, and are useful for โœ… edge cases and other specific values you want to test. The headers are used for when values fail, the output can show you what inputs were used for what labels. An example of using a table consisting of two-value tuples:
    class TableExample : StringSpec(), TableTesting {
      init {
        "numbers should be prime" {
          val table = table(
              headers("a", "b"),
              row(5, 5),
              row(4, 6),
              row(3, 7)
          )
          forAll(table) { a, b ->
            a + b == 10
          }
        }
      }
    }
    
    • ๐Ÿ‘• Property tests. Property tests automatically generate values for testings. You provide, or have KotlinTest provide for you, generators, which will generate a set of values and the unit test will be executed for each of those values. An example using two strings and asserting that the lengths are correct:
    class PropertyExample: StringSpec() {
    
      "String size" {
        forAll({ a: String, b: String ->
          (a + b).length == a.length + b.length
        })
      }
    
    }
    

    ๐Ÿ‘€ That test will be executed 100 times with random values in each test. See more in the readme.

    • autoClose. Fields of type Closeable can be registered for automatic resource closing:
    class StringSpecExample : StringSpec() {
      val reader = autoClose(StringReader("xyz"))
    
      ...
    }
    
    • haveLength matcher. You can now write for strings:
    someString should haveLength(10)
    
    • haveSize matcher. You can now write for collections:
    myCollection should haveSize(4)
    
    • contain matcher. You can now write
    val col = listOf(1,2,3,4,5)
    col should contain(4)
    
    • containInAnyOrder matcher. You can now write
    val col = listOf(1,2,3,4,5)
    col should containInAnyOrder(4,2,3)
    
    • haveKey Map matcher. You can now write
    val map = mapOf(Pair(1, "a"), Pair(2, "b"))
    map should haveKey(1)
    
    • haveValue Map matcher. You can now write
    val map = mapOf(Pair(1, "a"), Pair(2, "b"))
    map should haveValue("a")
    
    • contain Map matcher. You can now write
    val map = mapOf(Pair(1, "a"), Pair(2, "b"))
    map should contain(1, "a")
    
    • ๐Ÿ’… beTheSameInstanceAs reference matcher. This is an alias for x should be theSameInstanceAs(y), allowing x should beTheSameInstanceAs(y) which fits in with new matcher style.

    ๐Ÿ”„ Changed

    ๐Ÿ‘• Replaced timeout + timeUnit with Duration (#29)

    โฑ You can now write config(timeout = 2.seconds) instead of โฑ config(timeout = 2, timeoutUnit = TimeUnit.SECONDS).

    ๐Ÿ—„ Deprecated

    nothing

    โœ‚ Removed

    nothing

    ๐Ÿ›  Fixed