set
Advances the virtual time until it reaches instant.
Comparison with delayUntil
This function is identical in behavior to delayUntil. It exists because tests often read better when using it to set the initial date:
test("Some test") {
// Given:
time.set(Instant.parse("2024-02-13T21:32:41Z"))
// When:
// …
delayUntil(Instant.parse("2024-02-13T21:35:01Z"))
// …
// Then:
// …
}
We recommend using set to set the initial date at the very start of a test, and using delayUntil inside the test logic.
It is not possible to set the time to a date in the past.
Advances the virtual time until it reaches isoString, formatted as an ISO 8601 timestamp.
It is not possible to set the time to a date in the past.
Example
test("Everything should behave the same on December 31st") {
time.set("2022-12-31T23:37:00Z")
// …
}
Comparison with delayUntil
This function is identical in behavior to delayUntil. It exists because tests often read better when using it to set the initial date:
test("Some test") {
// Given:
time.set("2024-02-13T21:32:41Z")
// When:
// …
delayUntil("2024-02-13T21:35:01Z")
// …
// Then:
// …
}
We recommend using set to set the initial date at the very start of a test, and using delayUntil inside the test logic.