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

before

fun before(date: <ERROR CLASS>): Matcher<<ERROR CLASS>>

Matcher that compares two Dates and checks whether one is before the other

Verifies that two Date occurs in a certain order, checking that one happened before the other. For example, 09/02/1998 00:00:00 -03:00 is before 09/02/1998 00:00:01 -03:00, and the matcher will have a positive result for this comparison

    val firstDate = Date(1998, 2, 9, 0, 0, 0, 0)
    val secondDate = Date(1998, 2, 9, 0, 0, 1, 0)

    firstDate shouldBe before(secondDate)     // Assertion passes


    val firstDate = Date(1998, 2, 9, 0, 0, 1, 0)
    val secondDate = Date(1998, 2, 9, 0, 0, 0, 0)

    firstDate shouldNotBe before(secondDate)  // Assertion passes

See Also

Date.shouldBeBefore

Date.shouldNotBeBefore