Tests - pronobis/rocs GitHub Wiki
This page describes how to create and run tests in ROCS.
ROCS is using a combination of CTest and Google Test Framework (for C++) to do the testing. The tests are divided into test cases which are further divided into tests. Each module in ROCS can define several test cases (e.g. one test case per class) which might contain multiple tests (e.g. for different features of the class).
For more information see:
- Google Test Framework - Useful for writing tests.
- CTest - For those that want to know what happens inside.
To add a new test C++ suite:
-
Create a file
<case_name>.cpp
insrc/<module>/cpp/tests
-
Use the file `src/core/cpp/tests/test_test.cpp as an example
-
Use the Google Test Framework to learn how to write good unit tests
-
Add the following to the
CMakeLists.txt
of the module, under the module definition:# Tests add_rocs_cpp_test(<case_name>)
Running tests is extremely easy in ROCS. To run all the tests corresponding to the functionality being built:
- Enable the
ROCS_BUILD_TESTS
build option - Compile:
make
- Run all the tests:
make test
- If some tests fail, see the detailed debug output in
<BUILD_DIRECTORY>/Testing/Temporary/LastTest.log
All the compiled test applications are stored in <BUILD_DIRECTORY>/tests
and can be run independently of CTest.