qiBuild documentation

Testing

This CMake module provides functions to interface gtest with ctest.

qi_create_test(name [SRC <src> ...]
    [DEPENDS <depends> ...]
    [TIMEOUT <timeout>]
    [WORKING_DIRECTORY <working_directory>]
    [NIGHTLY]
    [PERF]
    [ARGUMENTS <arguments> ...]
    [ENVIRONMENT <environment> ...]
    [<remaining args> ...]
)
Arguments:
  • name – the name of the test and the target
  • SRC – sources of the test
  • DEPENDS – the dependencies of the test
  • TIMEOUT – the timeout of the test, in seconds. Defaults to 20
  • WORKING_DIRECTORY – working directory used when running the test: default: <build>/sdk>/bin
  • NIGHTLY – : only compiled (and thus run) if QI_WITH_NIGHTLY_TESTS is ON
  • PERF – : only compiled (and thus run) if QI_WITH_PERF_TESTS is ON It is assumed that the executable will understand an option named “–output <out.xml>” and generate such a file. You can for instance use the qiperf library for that.
  • ARGUMENTS – arguments to be passed to the executable
  • ENVIRONMENT – list of environment variables for the tests, in the form “key1=value1;key2=value2”
  • args (remaining) – source files (will be merged with the SRC group of arguments)

Create a new test that can be run by qibuild test

Notes:
  • The test can be installed using qibuild install --with-tests
  • The name of the test will always be the name of the target.
  • The test won’t be configured or built if QI_WITH_TESTS is OFF
qi_create_test_helper()

Add a test helper Create a binary that will not be run as a test, but rather used by an other test.

The helper can be installed along the proper tests using qibuild install --with-tests

Arguments are the same as qi_create_bin

qi_create_test_lib()

Add a test library.

The library can be installed along the other tests binaries using qibuild install --with-tests

Arguments are the same as qi_create_lib

qi_add_test()
Add a test using an existing binary. Arguments are the same as
qi_create_test
The target_name should match either:
  • a target
  • a binary found by find_program(${target_name})
  • the name of a package defining ${${target_name}_EXECUTABLE}}

This can be used for instance to create several tests with one target:

qi_create_test_helper(test_foo test_foo.cpp)
qi_add_test(test_foo_one test_foo ARGUMENTS --one)
qi_add_test(test_foo_two test_foo ARGUMENTS --two)
qi_create_gtest()

Same as qi_create_test, excepts it adds a dependency to the gtest libraries

qi_create_gmock()

Same as qi_create_test, excepts it adds a dependency to the gmock libraries

qi_create_perf_test()

Shortcut for qi_create_test(... PERF)