Chapter 34. Mocks and Clocks

Programmers: The tables that use this fixture code are given in Chapter 15.

The tests in Chapter 15 were developed to advance the clock and set the time in order to test some parts of the system. Emily and Neo handled the changing date in the application by using the system clock indirectly. That meant that they could substitute a different clock that allows the date and time to be changed by the tests.

34.1 Introduction

Emily and Neo worked together to implement the fixtures for the tests in Chapter 15.

Those tests assume that the clock and time can be changed. “However,” stressed Neo, “it would be a big mistake to try and fiddle with the real system clock.”

“Yes, I agree,” replied Emily, “so let’s use a ...

Get Fit for Developing Software: Framework for Integrated Tests now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.