Author: James Grenning
Target Audience: Any
Jacob’s Rating: 5+ Stars
Test-Driven Development for Embedded C is one of those foundational books that every embedded software engineer should read. I first read the book probably back in 2013 or 2014 just as I was starting to become a full-time consultant. The book was fantastic and challenged the way that I thought about writing embedded software. The idea of writing an automated test case that fails before writing any code was completely foreign to me. Honestly, the idea was intriguing, but at the time I was quite skeptical, and it took me several years before I really dug in and started to understand just how important the concepts in this book are to embedded developers.
James Grenning’s style presents test driven development to embedded developers in an easy to digest and practical manner. He takes the reader through the phases of TDD and provides the reader with a ton of practical examples and the source code to go with it. The author is also very familiar with the challenge’s developers face in adopting TDD and does a great job guiding the reader into the right mindset and demonstrating the advantages. The examples make it really easy for readers to get started and I think getting hands-on is the only way to successfully absorb the concepts and maximize value.
There were plenty of things that I liked about the book. First, there are two different test harnesses that are used in the examples, unity and cpputest (My preference is cpputest). This gives the reader the opportunity to see the differences between harnesses, even if the two are similar in nature. Next, I like how the book reinforces how a developer should design tests. Examples that are provided include an LED driver, a light scheduler and a circular buffer. A third thing I really found useful is the review of design principles such as SOLID and how they relate to TDD.
There are certainly plenty of topics that are covered beyond these. For example, the author discusses how developers can develop their software for dual targets; one for the embedded hardware and one for the test machine. This often requires mocking or faking out the test code to believe that the low-level hardware is there. The techniques make it possible for developers to create their embedded software application code while the hardware is still under development and not available. The benefits to such techniques certainly include more robust code and faster time to market.
I would highly recommend this book to any engineer who is interested in improving how they test their code, want to spend less time debugging and accelerate their development cycle. Many big technology companies have already adopted techniques for embedded software that are discussed in this book. I think it is well overdue for medium, small and start-up businesses to start taking advantage of these techniques as well. Read the book and run through all the exercises. I think you’ll find that will dramatically change how you write and test your embedded software.