kotest-assertions-core / io.kotest.matchers.date / java.time.LocalDate / shouldNotBeAfter

shouldNotBeAfter

infix fun LocalDate.shouldNotBeAfter(date: LocalDate): Unit

Asserts that this is NOT after date

Verifies that this is not after date, comparing year, month and day. For example, 09/02/1998 is not after 10/02/1998, and this assertion should pass for this comparison.

Opposite of LocalDate.shouldBeAfter

    val firstDate = LocalDate.of(1998, 2, 9)
    val secondDate = LocalDate.of(1998, 2, 10)

    firstDate shouldNotBeAfter secondDate   // Assertion passes


    val firstDate = LocalDate.of(1998, 2, 10)
    val secondDate = LocalDate.of(1998, 2, 9)

    firstDate shouldNotBeAfter secondDate   // Assertion fails, first date IS after secondDate

See Also

LocalDate.shouldBeBefore