Unit Testing with CppUTest

I’ve thought a lot about strategies for testing robot code, since existing methods (directly testing hardware and Gazebo simulation) don’t seem adequate to me. I’m a big fan of unit-testing and Test Driven Development (I use them extensively in my own projects), and recently I’ve figured out a way to use the CppUTest framework with C++ robot projects that use WPILib. Step-by-step instructions for getting started are available at this blog post I wrote:

Sample code with unit tests and a mock WPILib is here:

CppUTest homepage:

https://cpputest.github.io/

For Java projects, a similar strategy that involves the JUnit framework could probably be used.

I know it’s pretty late in the season to post this, but perhaps it could be useful for some last-minute code hardening before heading off to your final competitions.

Any feedback is appreciated.

I would really like to have a nice unit testing framework for C++ FRC code. There’s been a lot of work in Java to write abstractions around WPILib for easy testing. I’d be happy to help with making something similar for C++. We would basically make a bunch of abstract classes like “Motor” that are implemented by both the real hardware SpeedController and any fake test ones you may wish to write. It’s kind of a large undertaking, as WPILib is actually pretty big, especially when you start looking at the Command stuff.