03 Aug 2012, 16:22
Generic-user-small

Dennis Lambe (6 posts)

In chapter 12 you factor out the function Time_MatchesDaysOfWeek() into Time.c, using the existing tests as a safety net. You then say “for the long-term the new functions need their own tests.” Can you go into some detail about the best way to add those tests? If they’re added in the usual way, they’ll pass immediately and you’ll never have the opportunity to test the tests.

05 Sep 2012, 16:35
James2009_pragsmall

James Grenning (130 posts)

The added tests would pass immediately. You might feel in some cases that injecting an error temporarily into the production code is a good idea.

In the case of Time_MatchesDaysOfWeek() I would write exhaustive tests that cover each path through the function. A consequence of this refactoring is that fewer tests will be needed in the code that calls Time_MatchesDaysOfWeek().

  You must be logged in to comment