Skip to main content Skip to docs navigation

Date/Time testing

TimeProvider and testing

Document not reviewed yet, might be outdated. Please, let us know if you find something invalid here.
On this page

Klock has utilities for providing time and there are some integrations for testing.

TimeProvider

Sometimes you will need a source of time that can be mocked. Klock includes a TimeProvider interface with a default implementation using DateTime.

Testing & Kotest

Kotest is a flexible and comprehensive testing tool for Kotlin with multiplatform support. It supports Klock adding additional matchers. For a full list of Klock Kotest matchers, check this link: https://github.com/kotest/kotest/blob/master/doc/matchers.md

And you can find a sample here: https://github.com/kotest/kotest/tree/master/kotest-assertions/kotest-assertions-klock

Was this article useful?