Unittesting

Unit testing in project contains next parts:

Components

 * Test generator
 * tst subdirs
 * run_tests.sh script

Test generator
To create test suite and simple unit test you have to run *derive_test.sh* script in templates directory. main.cpp and Class_Test.h files will be created. To create a new test suite for the package just create *tst* directory and copy files main.cpp Class_Test.h tst.pro into it.

tst subdirs
Each package under src directory can contain tst subdir with test. For instance src/common/tst contains for now

main.cpp tst.pro User_Test.h User_TestObj.h

All unit test have to added here.

run_tests.sh script
run_tests.sh script placed in root directiry. It searches all files *test.suite* in the source tree, runs tests and collect primitive statistics. That is why test suite should have *test.suite* name. It should be ran before pushing changes into remote repository.

Below is sample of output

kkv@Edge:/ws/geo2tag$ ./run_tests.sh Found 2 test set(s): {./src/common/tst/test.suite ./src/json/tst/test.suite} Config: Using QTest library 4.7.2, Qt 4.7.2 PASS  : Test::User_Test::initTestCase FAIL! : Test::User_Test::test1 Compared values are not the same Actual (1): 1 Expected (2): 2 Loc: [User_Test.h(79)] PASS  : Test::User_Test::cleanupTestCase Totals: 2 passed, 1 failed, 0 skipped Config: Using QTest library 4.7.2, Qt 4.7.2 PASS  : Test::JsonUser_Test::initTestCase PASS  : Test::JsonUser_Test::testId PASS  : Test::JsonUser_Test::cleanupTestCase Totals: 3 passed, 0 failed, 0 skipped
 * Start testing of Test::User_Test *********
 * Finished testing of Test::User_Test *********
 * Start testing of Test::JsonUser_Test *********
 * Finished testing of Test::JsonUser_Test *********

=
================================================ ===                  END OF RUNNING   -> 2

=
================================================

FAIL! : Test::User_Test::test1 Compared values are not the same

Requirements and agreements
We suppose following next requirements


 * All new functionality that is being developed should go to the repo with concomitant unit tests;
 * Each fixed bug (except trivial cases, by agreement with reviewer) should contain test too;
 * It's allowed to put friend class ClassName_Test to ClassName declaration (but not recommended);
 * Test should be runnable without any dependencies (like LD_LIBRARY_PATH and so on);
 * Test should not required user input and should not do any output except qDebug;