Hi there,
Do you know soft assertions provided by AssertJ?
In many cases, one test case has one assertion.
But sometimes we’d like to collect some assertions within one assertion, and then we can use SoftAssertions() for the purpose.
Of course, we can use AssertJ in JUnit. In addition, we can use it in Kotlin like the following.
SoftAssertions().apply {
assertThat(1 + 1).isEqualTo(1)
assertThat(1 + 3).isEqualTo(2)
assertThat(1 + 1).isEqualTo(3)
}.assertAll()
So useful syntax 🙂