You know unit tests can help you write better embedded software, but are you still struggling to get started?
With the right tools, you can write your first tests in minutes.
Oh, there are a bunch of C "unit test frameworks" floating around, but they're not all the same. Some will need a lot more work to set up and maintain than others. Which one should you pick, and how do you actually start using it on your project? How do you make sure you don't abandon unit testing halfway through the project?
A few years ago, I didn't write any unit tests.
I had heard about software unit testing, but I didn't quite understand how I could use it in my embedded software. Then when I actually worked on a few projects with existing unit tests, I started to get it. I could see how the tests were used to exercise the code, and I could write my own tests to verify that my code did exactly what I wanted.
But these weren't embedded projects, and they weren't written in C. These other projects were developed in Visual Studio and Android Studio, where unit test support is built in. You can quickly add and run unit tests automatically. You just write the test code, and tell the IDE to run the tests. You don't have to add any boilerplate code or go through a bunch of manual steps. Running the tests is easy.
And easy is what you really want... especially when you're just starting out. You don't want to get waste time trying to figure out (or build) the test infrastructure, you just want it to work -- so you can start writing as many tests as quickly as possible.
But how can we get this same sort of unit-test magic for our embedded applications written in C?
The answer is an open-source test framework called Ceedling.
Ceedling makes creating and running unit tests for your embedded projects easy and automatic. It will automatically find and run your tests with a simple command -- just like those fancy IDEs.
Ceedling also makes it easy to test the interactions between software units with mocks. This is especially difficult in C, and requires a bit of build infrastructure to make it happen. But Ceedling can automatically create mocks in each of your unit tests. This is especially important for embedded software because you can use mocks to simulate hardware.
Because of how it can automatically generate mocks, Ceedling is really more than just a "unit test framework." It's a complete build and test system.
With Ceedling, it's easier to create and maintain a suite of tests for your embedded software.
There's still one problem though. While Ceedling is great, how to use it is not always obvious. Yes, there is documentation. But Ceedling is really flexible, so there are a lot of options. It's just not always clear what you need to do to solve your particular problem.
How do you add it to an existing project? How can you use it with your IDE? How do you test different groups of files, and how do you actually use mocks?
All of these things (and more!) are possible... with the right setup.
That's why I'm working on an book.
A Field Manual for Ceedling
How to Unit Test Embedded Software (in C)
Inside you'll learn how to use Ceedling with your real-world embedded applications. It'll answer questions like:
- How to write your first test in minutes.
- How to configure Ceedling to work with your existing project.
- How to use with your existing IDE.
- How to use Ceedling for test driven development.
- How to do unit and integration testing.
- How to use mocks effectively.
Sign up below and I'll let you know as soon as it's ready.