-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Description
I've witnessed a very strange behavior of strikt 0.29.0 (as well as 0.30.0) today. Please consider the following self-contained test:
import org.junit.jupiter.api.Test
import strikt.api.expectThat
import strikt.assertions.hasSize
import strikt.assertions.single
class StriktTest {
@Test
fun thisWillFailAsIntended(){
val list = listOf("hello", "foo")
expectThat(list).hasSize(3).and { // fails the "hasSize" condition, as it should.
get { this.filter { it == "foo" } }.single()
}
}
@Test
fun thisWillActuallyPass() {
val list = listOf("hello", "foo")
expectThat(list) {
hasSize(3) // we have 2 items in the list, yet the test passes
get { this.filter { it == "foo" } }.single()
}
}
@Test
fun thisWillActuallyPassToo() {
val list = listOf("hello", "foo")
expectThat(list) {
get { this.filter { it == "foo" } }.single()
get { this.filter { it == "bar" } }.single() // "bar" is not even in the list - yet the test passes!
}
}
}To my amazement, the second and third test will actually pass. Even though the list certainly doesn't match all of the given criteria.
I can't explain why that's the case. Did I do something horribly wrong with the API? Did I mis-interpret some of the methods?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels