I need to check that a method-under-test is setting a java.sql.Timestamp correctly using System.currentTimeMillis().
To avoid test flakiness because of timing issues, I typically record the timestamp before and after invoking the method-under-test, and then check that the timestamp set by the method-under-test falls in the range. This pattern works successfully but very fast methods, it is not sufficient to use isAfter() and isBefore() - I must use isAfterOrEqualTo().
This pattern was working fine until I switched from passing a java.sql.Timestamp in to isAfterOrEqualTo(), and for convenience started using java.time.Instant. The assertion started to fail when the Instant was equal to the Timestamp.
I upgraded to 3.27.7 but still had the same problem.
I can work around this by changing my arguments back into a Timestamp, but thought I would raise it anyway.
I need to check that a method-under-test is setting a
java.sql.Timestampcorrectly usingSystem.currentTimeMillis().To avoid test flakiness because of timing issues, I typically record the timestamp before and after invoking the method-under-test, and then check that the timestamp set by the method-under-test falls in the range. This pattern works successfully but very fast methods, it is not sufficient to use
isAfter()andisBefore()- I must useisAfterOrEqualTo().This pattern was working fine until I switched from passing a
java.sql.Timestampin toisAfterOrEqualTo(), and for convenience started usingjava.time.Instant. The assertion started to fail when theInstantwas equal to theTimestamp.I upgraded to 3.27.7 but still had the same problem.
I can work around this by changing my arguments back into a Timestamp, but thought I would raise it anyway.