Skip to content

Support for Assertions.byLessThan(Duration) and Assertions.within(Duration) #3486

Description

@khmarbaise

Feature summary

Enhance the byLessThan(..) and within to support the usage of Duration.

At the moment byLessThan(..) and within support the usage of a value combined with a TemporalUnit which looks like this:

assertThat(_07_10_20).isCloseTo(_07_11_45, byLessThan(1, ChronoUnit.MINUTES));
assertThat(_07_10_00).isCloseTo(_07_12_00, within(1, ChronoUnit.MINUTES));

Example

My suggestion is to enhance it in that way that you are able to use Duration instead of two different parameters like this:

assertThat(_07_10_20).isCloseTo(_07_11_45, byLessThan(Duration.ofMinutes(1)));
assertThat(_07_10_20).isCloseTo(_07_11_45, byLessThan(Duration.ofSeconds(45)));

or as example for within:

assertThat(_07_10_00).isCloseTo(_07_12_00, within(Duration.ofMinutes(1)));

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo