Compatibility with java.time¶
Control the virtual time during tests using the java.time
package.
Builds upon the virtual time control available out-of-the-box to allow instancing clocks, setting the current time or waiting for a given time.
Example¶
We want to test a Java class that makes computations based on the current time.
To allow writing multiple tests using the same class, we declare it as a prepared value. To ensure it has access to the virtual time, we inject the Java clock.
Now, we can use the helper functions to set the current time and to wait until a specific time.