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 withor
andand
and can be negated withshouldNot
.โ 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 inmockito-core
now instead ofmockito-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 forx should be theSameInstanceAs(y)
, allowingx should beTheSameInstanceAs(y)
which fits in with new matcher style.
๐ Changed
๐ Replaced
timeout
+timeUnit
withDuration
(#29)โฑ You can now write
config(timeout = 2.seconds)
instead of โฑconfig(timeout = 2, timeoutUnit = TimeUnit.SECONDS)
.๐ Deprecated
nothing
โ Removed
nothing
๐ Fixed
- ๐ Ignored tests now display properly. https://github.com/kotlintest/kotlintest/issues/43
- ๐ Failing tests reported as a success AND a failure https://github.com/kotlintest/kotlintest/issues/42 Ad