diff --git a/docs/source/devguide/tests.rst b/docs/source/devguide/tests.rst index 922f47eb31..d076511b1d 100644 --- a/docs/source/devguide/tests.rst +++ b/docs/source/devguide/tests.rst @@ -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 +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_.cpp + +The file must be added to the CMake build system in +``tests/cpp_unit_tests/CMakeLists.txt``. ``test_`` should +be added to ``TEST_NAMES``. + +To add a test case to ``test_.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 ------------------------------------ diff --git a/tests/cpp_unit_tests/CMakeLists.txt b/tests/cpp_unit_tests/CMakeLists.txt index c26547f778..3d48545b4c 100644 --- a/tests/cpp_unit_tests/CMakeLists.txt +++ b/tests/cpp_unit_tests/CMakeLists.txt @@ -1,5 +1,6 @@ set(TEST_NAMES test_distribution + # Add additional unit test files here ) foreach(test ${TEST_NAMES})