The most exciting thing about this world is its ever changing quality.

Tuesday, April 21, 2009

C++ Test Framework

I am in the process of helping my team to get a grip on test-driven development, with most of them have no experience nor exposure to automation test framework. In the middle of hunting, thanks to Jiayao, (who seems to determinate to save the digital resource for the planet hence not to update his blog anymore) an alternative light weight test framework is introduced - GTest, another xUnit type of testing package. (Is there anything those people do not do?) However, if you only prepare to spend 10 minutes on this subject, you should be looking at Olve's QUnit right now and shut this tab down. Olve has a pretty concise TDD presentation on his blog. Officially you do not have agree with his attitude to all other frameworks :-). There is a quite comprehensive in wiki.

Anyway, what I need is a simple test framework for cross-platform c++ projects. And I put my hands up to say I am a crappy tester and programmer. So this is really just an attempt to clear my own threads. So do not be surprised if you saw some terms you never heard before - it has to be my invention. Candidates on the short list finally come down to:


There was a good summary from Snappy Touch about using unit test framework in game and iPhone development. My list is much simpler:

  • Licensce free (I am sorry, but this has to be on top of my list. It is not about price; it is the principle :-))
  • Passed my 30 mins HW test. (30 minutes for me to run a Hello World program successfully, officially in this case is Hello Test World.)
  • Robust. I REALLY do not want to spend a second in debugging the framework itself!
  • Most of test framework is about predefined macros, fixtures etc. To me, it has to be just as easy as using a probe. Minimum code snippets required for invoking the actually test and output test results. 
  • Support good test template for input of expected results (whether it is a value, condition check, status machine transition, whatever). This is actually the most tricky one, in my opinion.
  • Test code itself MUST be easy to port. In addition to the no-dependencies on non-standard libraries contraint, I found it is extremely important to leave those compiler-dependent features out, otherwise, we will spend awful a lot of time in figuring out what the heck has went wrong when test failed miserably after you come out from Microsoft illusion to the reality, on target device, not mention after tools such as Lint is applied to assure the code quality itself.
  • Handles exceptions well. Remember my days in Symbian, one thing I really loved is the replacement concept to exception as in Panic!
  • It would be very nice if it comes with some scripts available to kick off the automated build and run process.
Maybe I should cook out my own test framework someday, just for fun...

No comments: