Doc.Policy.UnitTests - JETSCAPE/X-SCAPE GitHub Wiki

Unit Tests

Unit tests can be found in the examples/unittests directory. The tests are turned on by default as shown in the file JETSCAPE/CMakeLists.txt file.

# Unit Tests. Turn off with 'cmake -Dunittests=OFF'.
option(unittests "Build all unittests." ON)

Please include additional unit tests to accompany the development of your classes and functionality. Place your test code .cc file implemented using the GoogleTest framework in the examples/unittests directory, and add your test to this examples/unittests/CMakeLists.txt file.

# add your unittests after this line
add_unittest(linear_interpolation)
add_unittest(fluid_dynamics)
add_unittest(causal_liquifier)
add_unittest(LiquifierBase)

A GitHub Actions test will run on pull requests to the main and release candidate branches to execute the included unit tests.

The tests can be executed locally by navigating to build/examples/unittests (which will have been created when compiling X-SCAPE in the build folder) and running a test executable. For example:

cd build/examples/unittests
./linear_interpolation

Terminal output from a successful test will look like the following:

Running main() from gtest_main.cc
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from LinearInterpolationTest
[ RUN      ] LinearInterpolationTest.TEST_TRUE
[       OK ] LinearInterpolationTest.TEST_TRUE (0 ms)
[ RUN      ] LinearInterpolationTest.TEST_INT
[       OK ] LinearInterpolationTest.TEST_INT (0 ms)
[----------] 2 tests from LinearInterpolationTest (0 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 1 test case ran. (0 ms total)
[  PASSED  ] 2 tests.