Test-Drive the Interface Before the Internals
A good interface is critical for a well-designed module. The first few tests drive the interface design. The focus on the interface means that we’re working from the outside of the code being developed to the inside. The test, as the first user of the interface, gives the callers (or client code) perspective of how to use the code being developed. Starting from the user’s perspective leads to more usable interfaces.
I also usually let the first few tests exercise some boundary condition in the code being developed. Choose a simple case but one that exercises a boundary.
The code behind the interface starts with hard-coded return results, so it feels like nothing is being tested. The point is ...
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.