infix fun LocalDateTime.shouldBeBefore(date: LocalDateTime): Unit
Asserts that this is before date
Verifies that this is before date, comparing every field in the LocalDateTime. For example, 09/02/1998 00:00:00 is before 09/02/1998 00:00:01, and this assertion should pass for this comparison.
Opposite of LocalDateTime.shouldNotBeBefore
val firstDate = LocalDateTime.of(1998, 2, 9, 0, 0, 0)
val secondDate = LocalDateTime.of(1998, 2, 9, 0, 0, 1)
firstDate shouldBeBefore secondDate // Assertion passes
val firstDate = LocalDateTime.of(1998, 2, 9, 0, 0, 1)
val secondDate = LocalDateTime.of(1998, 2, 9, 0, 0, 0)
firstDate shouldBeBefore secondDate // Assertion fails, firstDate is one second after secondDate
See Also