Skip to content
Marcel edited this page Oct 18, 2021 · 7 revisions

Test infrastructure - build and run tests

We have several possibilities to test, if everything passes your changes. Some of them you can test on your computer if you want to: The snippets, the unit tests, the performance tests, the documentation (and makro benchmark tests). These and others will also be tested, when you create a PR. Others are codecoverage, header cycles, tests on several operating systems...

Unit tests

To build an run the unit tests:

~/build/seqan3/unit_debug$ cmake ~/Repos/seqan3/test/unit/ -DCMAKE_BUILD_TYPE=Debug

or the Release mode:

~/build/seqan3/unit_release$ cmake ~/Repos/seqan3/test/unit/ -DCMAKE_BUILD_TYPE=Release

and then build one test:

~/build/seqan3/unit_debug$ make template_inspection_test

or all tests (if possible parallel):

~/build/seqan3/unit_debug$ make -j 3

and run them

~/build/seqan3/unit_debug$ ctest -j 2

It is also possible to build and run a group of tests by going into the folder of the module

~/build/seqan3/unit_debug$ cd alignment/configuration/
~/build/seqan3/unit_debug/alignment/configuration$ make && ctest

Snippet and performance tests

Next to this there are snippets and performance (performance has only a release CMAKE_BUILD_TYPE:

~/build/seqan3/snippet_debug$ cmake ~/Repos/seqan3/test/snippet/ -DCMAKE_BUILD_TYPE=Debug
~/build/seqan3/snippet_release$ cmake ~/Repos/seqan3/test/snippet/ -DCMAKE_BUILD_TYPE=Release
~/build/seqan3/performance$ cmake ~/Repos/seqan3/test/performance/ -DCMAKE_BUILD_TYPE=Release

Documentation

for the documentation, you should grep the warnings, otherwise you would get a lot of output:

~/build/seqan3/documentation$ cmake ~/Repos/seqan3/test/documentation/
~/build/seqan3/documentation$ make -j 3 | grep warning
~/build/seqan3/documentation$ open doc_dev/html/index.html

Header, coverage, macro benchmarks

Other things you can build and test:

cmake ~/Repos/seqan3/test/header/ -DCMAKE_BUILD_TYPE=Debug
cmake ~/Repos/seqan3/test/coverage/ -DCMAKE_BUILD_TYPE=Debug
cmake ~/Repos/seqan3/test/macro_benchmark/ -DCMAKE_BUILD_TYPE=Release

Writing a test case

Basic rules

  • test the publicly specified interfaces
  • remember to test const/non-const versions
  • remember to test rvalue/lvalue versions
  • try to use generalized typed test whenever possible
  • write typed tests for your concepts and include all types that fulfill the concept

Test dependencies

  • prefer many small tests to one big test
  • try to make tests atomic, i.e. make them independent of functionality tested in other tests
  • if you need to use functionality from other tests, re-order your tests so that they only depend on previously tested functionality, not on things tested "later on"
  • never introduce circular dependencies between tests!
Clone this wiki locally