Use pytest's runner to discover and execute C++ tests
Use pytest runner to discover and execute C++ tests.
This brings several benefits:
- Allows you to run all your tests in multi-language projects with a single command;
- Execute C++ tests in parallel using pytest-xdist plugin;
- Use --junitxml option to produce a single and uniform xml file with all your test suite results;
- Filter which tests to run using standard test filtering capabilities, such as by file names, directories, keywords by using the -k option, etc.;
Table of Contents
Once installed, pytest runs will search and run tests found in executable files, detecting if the suites are Google, Boost, or Catch2 tests automatically.
Following are the options that can be put in the pytest configuration file related to pytest-cpp.
You can configure which files are tested for suites by using the cpp_files ini configuration option:
[pytest] cpp_files = test_suite*
By default matches test_* and *_test executable files.
Arguments to the C++ tests can be provided with the cpp_arguments ini configuration option.
[pytest] cpp_arguments =-v --log-dir=logs
You can change this option directly in the command-line using pytest’s -o option:
$ pytest -o cpp_arguments='-v --log-dir=logs'
This option defaults to True and configures the plugin to ignore *.py files that would otherwise match the cpp_files option.
Set it to False if you have C++ executable files that end with the *.py extension.
[pytest] cpp_ignore_py_files = False
This option allows the usage of tools that are used by invoking them on the console wrapping the test binary, like valgrind and memcheck:
[pytest] cpp_harness = valgrind --tool=memcheck
Release history Release notifications | RSS feed
Hashes for pytest_cpp-2.1.2-py3-none-any.whl