mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
added documentation on unit testing with catch2
This commit is contained in:
parent
6b0baf8b1d
commit
761bfc5349
2 changed files with 27 additions and 1 deletions
|
|
@ -45,7 +45,7 @@ Prerequisites
|
|||
Running Tests
|
||||
-------------
|
||||
|
||||
To execute the test suite, go to the ``tests/`` directory and run::
|
||||
To execute the Python test suite, go to the ``tests/`` directory and run::
|
||||
|
||||
pytest
|
||||
|
||||
|
|
@ -55,6 +55,14 @@ installed and run::
|
|||
|
||||
pytest --cov=../openmc --cov-report=html
|
||||
|
||||
To execute the C++ test suite, go to your build directory and run::
|
||||
|
||||
ctest
|
||||
|
||||
If you want to view testing output on failure run::
|
||||
|
||||
ctest --output-on-failure
|
||||
|
||||
Generating XML Inputs
|
||||
---------------------
|
||||
|
||||
|
|
@ -66,6 +74,23 @@ run::
|
|||
|
||||
pytest --build-inputs <name-of-test>
|
||||
|
||||
Adding C++ Unit Tests
|
||||
---------------------
|
||||
|
||||
The C++ test suite uses Catch2 integrated with CTest. Each header file should
|
||||
have a corresponding test file in ``tests/cpp_unit_tests/``. If the test file
|
||||
does not exist run::
|
||||
|
||||
touch test_<name-of-header-file>.cpp
|
||||
|
||||
The file must be added to the CMake build system in
|
||||
``tests/cpp_unit_tests/CMakeLists.txt``. ``test_<name-of-header-file>`` should
|
||||
be added to ``TEST_NAMES``.
|
||||
|
||||
To add a test case to ``test_<name-of-header-file>.cpp`` ensure
|
||||
``catch2/catch_test_macros.hpp`` is included. A unit test can then be added
|
||||
using the ``TEST_CASE`` macro and the ``REQUIRE`` assertion from Catch2.
|
||||
|
||||
Adding Tests to the Regression Suite
|
||||
------------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue