Test - DigitalHolography/Holovibes GitHub Wiki

Holovibes supports unit and functional testing.

Unit testing

The framework used is Gtest.

Add a test

Create a new file inside Holovibes/tests/.

Here a small example:

#include "gtest/gtest.h"
#include "test_disable_log.hh" // Disable logging to avoid messing up with gtest

TEST(BasicTest, MoreThanSimpleTestExample)
{
    ASSERT_EQ(0.0, 0.0);
    ASSERT_NE(0, 1);
}

Don't forget to add the path of your test file inside Holovibes/tests/CMakLists.txt in the UNIT_TEST_SOURCES.

[!NOTE]

  • If you want to create an utility header you can create it under Holovibes/tests/includes/.
  • It's recommanded to disable logging since it will mess up the consols and interfer with gtest. To do so you can include the test_disable_log.hh header.

Run test

Simply run

./dev.py test

Functional testing

The framework used is PyTest. Integration testing is done using the CLI mode of Holovibes.

Add a test

Create a folder with the name of your test in the tests/data/ folder. Then put:

  • an optional input.holo (if you provide no input, the default one in the input folder will be chosen. You can provide different default inputs by making the name of the input match a part of your test name).
  • a ref.holo file as intended output.
  • an optional holovibes.json containing parameters.
  • an oprional cli_argument.json containing CLI arguments.

Build Reference Outputs

At the root of a stable branch run:

./dev.py build_ref [test_name]

If no test_name is given, all refs will be built. It will generate a ref.holo or a error.txt and a ref_time.txt for each test. CAREFULL : this command should only be runned in a stable branch and for newly-added tests for which the behavior has been verified and validated by hand, or when the software's output has improved, and if you know for sure that it's stable.

Run tests

Build the project in Release or Debug mode. If you want all tests run:

python -m pytest -v

OR

./dev.py build pytest

If you want to run one or specific tests run:

./dev.py build pytest --specific-tests=names

Where names is a comma separated list of folders

Both will generate a last_generated_output.holo, or an output_error.txt.