README 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. Introduction
  2. ------------
  3. CxxTest is a JUnit/CppUnit/xUnit-like framework for C++.
  4. Its advantages over existing alternatives are that it:
  5. - Doesn't require RTTI
  6. - Doesn't require member template functions
  7. - Doesn't require exception handling
  8. - Doesn't require any external libraries (including memory management,
  9. file/console I/O, graphics libraries)
  10. This makes it extremely portable and usable.
  11. CxxTest is available under the GNU Lesser General Public Licence (LGPL).
  12. See http://www.gnu.org/copyleft/lesser.html for the license.
  13. Simple user's guide
  14. -------------------
  15. 1. Create a test suite header file:
  16. MyTest.h:
  17. #include <cxxtest/TestSuite.h>
  18. class MyTestSuite : public CxxTest::TestSuite
  19. {
  20. public:
  21. void testAddition( void )
  22. {
  23. TS_ASSERT( 1 + 1 > 1 );
  24. TS_ASSERT_EQUALS( 1 + 1, 2 );
  25. }
  26. };
  27. 2. Generate the tests file:
  28. # cxxtestgen.pl -o tests.cpp MyTestSuite.h
  29. 3. Create a main function that runs the tests
  30. main.cpp:
  31. #include <cxxtest/ErrorPrinter.h>
  32. int main( void )
  33. {
  34. CxxText::ErrorPrinter::runAllTests();
  35. return 0;
  36. }
  37. 4. Compile and run!
  38. # g++ -o main main.cpp tests.cpp
  39. # ./main
  40. Running 1 test(s).OK!
  41. Advanced User's Guide
  42. ---------------------
  43. See docs/guide.html.