How to write unit tests for wxWidgets
=====================================
- Unit tests for wxWidgets are written using small cppunit framework. To compile
+Unit tests for wxWidgets are written using small cppunit framework. To compile
(but not to run) them you need to have it installed. Hence the first part of
this note explains how to do it while the second one explains how to write the
test.
- build everything in CppUnitLibraries.dsw work space
- add include and lib subdirectories of the directory
where you installed cppunit to the compiler search path
- using "Tools|Options" menu in VC IDEA
+ using "Tools|Options" menu in VC IDE
b) Under Unix: run configure && make && make install as usual
// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION(MBConvTestCase);
- // also include in it's own registry so that these tests can be run alone
+ // also include in its own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(MBConvTestCase, "MBConvTestCase");
Read CppUnit documentation for more.
event type. It disconnects again once it is out of scope. It simply reduces
the amount of typing required to count events.
-3. add a '<sources>' tag for your source file to tests/test.bkl
+3. add a '<sources>' tag for your source file to tests/test.bkl. Make sure it's
+ in the correct section: the one starting '<exe id="test_gui"' for a gui test,
+ the one starting '<exe id="test" template="wx_sample_console' otherwise.
III. Running the tests
2. Build the test program using one of the make/project files in the tests
subdirectory.
-3. Run the test program with no arguments to run the default set of tests
- (which are all those registered with CPPUNIT_TEST_SUITE_REGISTRATION).
+3. Run the test program by using the command 'test' for the console tests,
+ 'test_gui' for the gui ones. With no arguments, all the default set of tests
+ (all those registered with CPPUNIT_TEST_SUITE_REGISTRATION) are run.
Or to list the test suites without running them:
- test -l
+ test -l or test_gui -l
4. Tests that have been registered under a name using
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION can also be run separately. For
example:
- test MBConvTestCase
- or to list the tests:
+ test_gui ButtonTestCase
+ or to list the tests done by a particular testcase:
test -L MBConvTestCase
5. Fault navigation.
//CPPUNIT_TEST_SUITE_REGISTRATION(wxRegExTestCase);
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(wxRegExTestCase, "fixme");
- // also include in it's own registry so that these tests can be run alone
+ // also include in its own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(wxRegExTestCase, "wxRegExTestCase");
4. Tests which take a long time to execute can be registered under "advanced"