Chapter 8 Spying on the Production Code

In the previous chapter, we looked at some of the challenges of testing modules that interact with other parts of the system. I described some of the techniques needed in C to overcome these challenges. In this chapter, we’ll look at an example module that has problem hardware and OS dependencies. We’ll use interfaces, test doubles, and link-time substitution to manage the problem dependencies.

To manage dependencies on the Code Under Test execution environment, all access to the execution environment must go through defined interfaces. Interface calls can be intercepted and inspected by replacing a problem Depended on Component with a test double. The test case can control the test double’s return ...

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.