Interface TimeSource

  • All Known Implementing Classes:
    FakeTimeSource

    public interface TimeSource
    An object that supplies values meant to represent the current wall-clock time.

    Using this interface (or one like it) to introduce a level of indirection between your code and the real world means that your tests can run as fast as possible, rather than having to include real-world delays in the middle of the test.

    When your code needs an implementation of TimeSource that uses real-world time, just use a lambda expression of ()->Instant.now().

    • Method Detail

      • now

        Instant now()
        Get the current wall-clock time.
        Returns:
        The current time.