Testing Unit Testing
As I’ve been working on my compiler, I’ve been writing tests for each feature as it becomes available. There’s been a couple of times I’ve broken the parser while adding data type support to it. Thankfully the tests found that out as soon as I was done compiling, and I didn’t have to try and figure it out weeks later when I returned to the project. (I only get so much time to work on this project, and it’s often weeks in between times I can put significant effort in.) Thanks to these simple tests, I have been able to maintain functionality.
However, those tests really are just small executables that have asserts. They’re not bad, but after using NUnit for another project, I am thinking I want something more formal. However, I want to write tests quickly and not have to support a lot of infrastructure. I’ve been doing some research on C++ unit testing frameworks. There sure are a lot of them.
I’ve think I’ve narrowed my choice down to two: TUT looks promising, as does UnitTest++. I like TUT because it is headers only. It seems a little obtuse since it uses so many templates, but I’m not one to shy away from templates. I like UnitTest++ since it professes so much cross platform support.
Another one, cput looks like NUnit does, and is even integrated into Visual C++, but I’m looking more for simple than integrated right now. Maybe later when the compiler is further along. Then again, multi-platform is of prime importance, so maybe this one won’t be that useful to me after all.
Do you know of any good C++ testing frameworks that I should look at?