Breaking Dependencies
Real code has dependencies. One module interacts with several others to get its job done. Code resists automated tests when it interacts with the operating system, hardware devices, or sometimes other modules. The bad news is that these problem dependencies make test automation difficult or maybe prohibitively expensive. The good news is that we can design code to be testable; we can break problem dependencies.
The key to breaking dependencies is a more rigorous use of interfaces, encapsulation, and data hiding and less reliance on unprotected global data. To design more modular and testable C, we employ a header file to publish the interface of a module. A testable module is one that interacts with other modules through ...
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.