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

shouldNotBeBefore

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

Asserts that this is NOT before date

Verifies that this is not before date, comparing every field in the LocalDateTime. For example, 09/02/1998 00:00:01 is not before 09/02/1998 00:00:00, and this assertion should pass for this comparison.

Opposite of LocalDateTime.shouldBeBefore

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

    firstDate shouldNotBeBefore secondDate    // Assertion passes


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

    firstDate shouldNotBeBefore secondDate     // Assertion fails, firstDate is one second before secondDate and we didn't expect it

See Also

LocalDateTime.shouldBeAfter