-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
Hey there,
I like to use assertk as an assertj drop in for kotlin code. Recently I stumbled across the assertThat().all and assertThat().each methods.
I did something like
val listOfLists = listOf(listOf(1), listOf(2), listOf(3), listOf(4))
assertThat(listOfLists).all { hasSize(1) }This assertion fails because it does not assert that each list has size one, but it asserts that the outer list has size 1.
assertThat(listOfLists).each { it.hasSize(1) } is the way to go here.
Why did I try to use all in the first place? Well there is standard-lib function all which works on lists and checks if all elements of the list match the given predicate:
assertTrue(listOfLists.all { it.size == 1 })
So I think naming of all and each assertions could be improved to save other fellow developers from the trap I fell into.
Metadata
Metadata
Assignees
Labels
No labels