| 1 |
Overview |
| 2 |
-------- |
| 3 |
|
| 4 |
CxxTest is a unit testing framework for C++ that is similar in |
| 5 |
spirit to JUnit, CppUnit, and xUnit. CxxTest is easy to use because |
| 6 |
it does not require precompiling a CxxTest testing library, it |
| 7 |
employs no advanced features of C++ (e.g. RTTI) and it supports a |
| 8 |
very flexible form of test discovery. |
| 9 |
|
| 10 |
CxxTest is available under the GNU Lesser General Public Licence (LGPL). |
| 11 |
|
| 12 |
A user guide can be downloaded from http://cxxtest.com. |
| 13 |
|
| 14 |
|
| 15 |
A Simple Example |
| 16 |
---------------- |
| 17 |
|
| 18 |
1. Create a test suite header file: |
| 19 |
|
| 20 |
MyTestSuite.h: |
| 21 |
|
| 22 |
#include <cxxtest/TestSuite.h> |
| 23 |
|
| 24 |
class MyTestSuite : public CxxTest::TestSuite |
| 25 |
{ |
| 26 |
public: |
| 27 |
void testAddition( void ) |
| 28 |
{ |
| 29 |
TS_ASSERT( 1 + 1 > 1 ); |
| 30 |
TS_ASSERT_EQUALS( 1 + 1, 2 ); |
| 31 |
} |
| 32 |
}; |
| 33 |
|
| 34 |
|
| 35 |
2. Generate the tests file: |
| 36 |
|
| 37 |
# cxxtestgen --error-printer -o tests.cpp MyTestSuite.h |
| 38 |
|
| 39 |
3. Compile and run! |
| 40 |
|
| 41 |
# g++ -o main tests.cpp |
| 42 |
# ./main |
| 43 |
Running cxxtest tests (1 test).OK! |
| 44 |
|