mardi 30 décembre 2014

Modern UnitTest++ replacement

I'm methodically upgrading my source code to get with the C++11 times, and one of the pieces that a lot of my code interacts with is UnitTest++.


I dedicate the latter half of every one of my implementation cpp files to unit tests, so they include many



TEST(testname) {
// test code
}


declarations.


Now, UnitTest++ is about 8 years old and it still compiles great, so I have no urgent need to replace it. However I have found that it is probably no longer being maintained (though its existing features certainly seem solid enough, this is a bad sign) as the website and sourceforge are down.


So even though my code works fine now, it may benefit me now to switch to a better system earlier rather than later, because it will reduce translation burden in the future.


I looked around a bit and there seem to be a few options available to me. Particularly interesting is libunittest and others like CATCH which is header-only.


My question is for folks who have maybe had experience with UnitTest++ in the past and other unit testing systems, what has worked well for you and if you have any recommendations. I am looking for something that is extremely portable and which has zero external dependencies beyond a C++98/03 or C++11 compiler (gcc, clang, msvc) and the standard libraries, and where being header-only is a plus but not necessary.


So I guess my preferences do tend to narrow down the options quite a bit. Even with UnitTest++ I enjoy its portability and self-containedness, but I have had to write a good ~100 or so lines worth of code to extend it to be flexible for me in two ways:



  • allow me to specify specific tests to run (whether it's choosing the tests by name, or by source file in which they're implemented, or the test suite name)

  • customize reporting behavior for tests such as timing, etc


Aucun commentaire:

Enregistrer un commentaire