Skip to content

Unintuitive behaviour of afterOrEqualTo() for Instant #4241

Description

@kriegfrj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions