Unit testing: Fixing the system clock with MockK
1 min readFeb 14, 2019
Unit tests involving time often leads to brittle tests because assertions on time relies on the tests executing fast enough, or slightly better, extra boilerplate test code to check that the timestamp on that object is close enough to the expected value to be correct. With MockK’s static mocks it is easy to set the system clock to a fixed instant.