Difference between revisions of "Testing"
Line 1: | Line 1: | ||
+ | All library code is tested by means of unit tests. Unit tests provide verification, are good examples and prevent regressions. | ||
+ | |||
=Basic usage= | =Basic usage= | ||
Line 8: | Line 10: | ||
Tests are written in Google test framework: | Tests are written in Google test framework: | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="c++" line> |
TEST(Group, Name) { | TEST(Group, Name) { | ||
EXPECT_EQ(a, b); | EXPECT_EQ(a, b); |
Revision as of 15:59, 1 November 2016
All library code is tested by means of unit tests. Unit tests provide verification, are good examples and prevent regressions.
Basic usage
Tests can be run all at once via make
run_all_tests
or individually via eg. make basisfunc_run_tests
.
Each header file should be accompanied by a <util_name>_test.cpp
with examples
for all functionalities and unit tests.
Tests are written in Google test framework:
1 TEST(Group, Name) {
2 EXPECT_EQ(a, b);
3 }
Compiled binary supports running only specified test. Use ./main --gtest_filter=Domain*
for filtering and ./main --help
for more options.
Before pushing run ./util/run_tests.sh
.
This script makes and executes all <util_name>_test.cpp
test files, checks coding style and
documentation. You can check them separately as well.
1 Usage: ./run_tests.sh
2 Options:
3 -c run only configuration
4 -t run only tests
5 -s run only stylechecks
6 -d run only docscheck
7 -h print this help
8 Example:
9 ./run_tests.sh -sd
If anything is wrong you will get pretty little red error, but if you see green, you're good to go.
Philosophy behind testing
TO DO: JURE