kotest-assertions / io.kotest.matchers.date / shouldNotBeBefore

shouldNotBeBefore

infix fun <ERROR CLASS>.shouldNotBeBefore(other: <ERROR CLASS>): <ERROR CLASS>

Asserts that this is NOT before other

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

Opposite of Date.shouldBeBefore

    val firstDate = Date(1998, 2, 9, 0, 0, 1, 0, ZoneOffset.ofHours(-3))
    val secondDate = Date(1998, 2, 9, 0, 0, 0, 0, ZoneOffset.ofHours(-3))

    firstDate shouldNotBeBefore secondDate    // Assertion passes


    val firstDate = Date(1998, 2, 9, 0, 0, 0, 0, ZoneOffset.ofHours(-3))
    val secondDate = Date(1998, 2, 9, 0, 0, 1, 0, ZoneOffset.ofHours(-3))

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

See Also

Date.shouldBeAfter