Spying on the Code Under Test
The spy is on a covert operation. It intercepts the inputs destined for the production code, later providing it to the test case. As part of its covert mission, it may also feed return results to the client code, getting the CUT to do the test’s bidding. Very sneaky indeed.
After setting up the initial LightScheduler files (I use the shell scripts provided with CppUTest to create the initial files), write a test case that helps you envision the roles of the LightControllerSpy and FakeTimeService in the testing of LightScheduler. This tests helps you decide what facilities are needed in the test fixture.
tests/HomeAutomation/LightSchedulerTest.cpp | |
| TEST(LightScheduler, ScheduleOnEverydayNotTimeYet) |
| { |
| LightScheduler_ScheduleTurnOn(3, ... |
Get Test Driven Development for Embedded C 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.