Before retiring, I successfully introduced unit testing in Eclipse for an embedded arm cross compiled target to my team, based on the book Test-Driven Development for Embedded C by James W. Grenning
Now I'm wanting to do the same for my own Arduino projects, but I've hit a bit of a snag
I have the Eclipse Arduino plugin working on a sample project (the target project) - the functions & classes to be unit tested are in a separate folder in this project (called 'application')
I have the CppUTest unit test libraries installed in a separate testing project
I've included the 'application' folder from the target project in this testing project
Now, This testing project can't immediately resolve the <arduino.h> include file in the target files, and if I manually include this header file into the testing project, it references other include files, and I start to disappear down a rabbit hole trying to satisfy other header file references
I've initially worked around this by removing <arduino.h> from the target functions and classes, and the only changes needed so far has been to change Arduino type defs like 'byte' to standard C 'unsigned char' - these then copile fine in both projects ad the tests run and pass
But I don't particularly like having to change the type defs, and would like to be able to include <arduino.h>, and keep the code in the usual Arduino 'style'
So, the question is - is there a better way to do this?
I did think that I should be able to add the CppUTest libraries to an Arduino Eclipse project, as a test project, but there doesn't seem to be the option to add library & include paths to an Arduino project like you can with a c/c++ project, and I don't see an easy way to add all the necessary Arduino header files to a standard C++ project, especially as I believe some of the headers are dependant on the Arduino platform chosen, which of course isn't supported in a standard C++ project
It would be nice to have a generic solution to this so that I could create other test projects with different unit testing frameworks, as my former colleagues have moved onto the Cxx unit test framework, and there are others (like google) i'd like to try
Looking forward to your suggestions