View on GitHub

Kluent

Fluent Assertion-Library for Kotlin

Collection assertions

Arrays and Iterables

The following assertions work for Array and Iterable

theIntArray shouldContain 2
theIntArray shouldNotContain 10

theIntArray shouldContainSome arrayOf(1, 10, 15, 2)
theIntArray shouldContainNone arrayOf(5, 10, 11)

arrayOf(1, 2, 3) shouldEqual arrayOf(1, 2, 3)
arrayOf(4, 5, 6) shouldNotEqual arrayOf(7, 8, 9)

theIntArray.shouldBeEmpty()
theIntArray.shouldNotBeEmpty()

2 shouldBeIn arrayOf(1, 2, 3)
2 shouldNotBeIn arrayOf(4, 5, 6)

listOf(10, 15, 20) shouldContainAll listOf(10, 15, 20)
listOf(10, 15, 20) shouldNotContainAny listOf(5, 7)

listOf(1, 2, 3) shouldContainSame listOf(3, 1, 2)

Maps

theMap shouldHaveKey "Name"
theMap shouldNotHaveKey "Age"

theMap shouldHaveValue "Peter"
theMap shouldNotHaveValue "Max"

theMap shouldContain ("Name" to "Peter")
theMap shouldNotContain ("Age" to 10)

theMap.shouldBeEmpty()
theMap.shouldNotBeEmpty()