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

shouldBeAfter

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

Asserts that this is after date

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

Opposite of LocalDateTime.shouldNotBeAfter

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

    firstDate shouldBeAfter secondDate  // Assertion passes


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

    firstDate shouldBeAfter secondDate  // Assertion fails, firstDate is NOT after secondDate

See Also

LocalDateTime.shouldNotBeBefore