Unit Tests
From KatWiki
Each good software should be tested, at any time during development, again and again.
We use the cppunit (http://cppunit.sourceforge.net/cgi-bin/moin.cgi) testing framework for our unit-tests.
First of all we try to check every public method and every constructor for each object we provide.
Currently we have some tests for the core library. These tests should verify that the objects behave well for all kinds of arguments we pass onto them. Altogether that makes at the moment about 91 test cases in 1 suite. When the test suites will cover all of our code, the test cases will be hundreds.
Run the tests
In order to run the tests you have to configure, compile and install the project. Some tests only work if the project is installed (for example, language management needs the language profiles to be installed in the correct place). After that, tests can be run using this command line:
$ ./tests
Run the tests for memory leaks using Valgrind
See Valgrind API (http://developer.kde.org/~sewardj/docs-2.2.0/coregrind_core.html#clientreq) and Valgrind Manual (http://developer.kde.org/~sewardj/docs-2.2.0/manual.html).
This is how to run our tests via valgrind:
$ libtool --mode=execute valgrind --leak-check=yes -v --show-reachable=yes tests
In order to facilitate this task, we have added a bash file that can be easily run:
$ valgrindtests.sh
We have added a configure option that checks the presence of cppunit and valgrind in the system. If cppunit is not found, the tests are not compiled. If valgrind is not found, the tests will not be run in Valgrind mode, in other words it will not be possible to perform tests in order to find memory leaks and other errors related to memory management.