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

shouldNotBeAfter

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

Asserts that this is NOT after date

Verifies that this is not after date, comparing all fields in LocalDateTime. For example, 09/02/1998 09:00:00 is not after 09/02/1998 10:00:00, and this assertion should pass for this comparison.

Opposite of LocalDateTime.shouldBeAfter

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

    firstDate shouldNotBeAfter secondDate   // Assertion passes


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

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

See Also

LocalDateTime.shouldBeBefore