Unit testing for C++ code
I'm working on a large c++ system that is has been in development for a few years now. As part of an effort to improve the quality of the existing code we engaged on a large long-term refactoring project.
Do you know a good tool that can help me write unit tests in C++? Maybe something similar to Junit or Nunit?
Can anyone give some good advice on the methodology of writing unit tests for modules that were written without unit testing in mind?
Applying unit tests to legacy code was the very reason Working Effectively with Legacy Code was written. Michael Feathers is the author - as mentioned in other answers, he was involved in the creation of both CppUnit and CppUnitLite.
alt text http://ecx.images-amazon.com/images/I/51RCXGPXQ8L._SL160_AA115_.jpg
Google recently released their own library for unit testing C++ apps, called Google Test.
Project on Google Code
Check out an excellent comparison between several available suites. The author of that article later developed UnitTest++.
What I particularly like about it (apart from the fact that it handles exceptions etc. well) is that there is a very limited amount of 'administration' around the test cases and test fixtures definition.
链接地址: http://www.djcxy.com/p/50804.html上一篇: 单元测试代码与文件系统依赖关系
下一篇: 对C ++代码进行单元测试