Skip to main content

Use pytest's runner to discover and execute C++ tests

Project description

Use pytest runner to discover and execute C++ tests.

Supported Python versions version anaconda ci coverage black

Supports both Google Test and Boost::Test:

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.;


Once installed, when py.test runs it will search and run tests found in executable files, detecting if the suites are Google or Boost tests automatically.

Configuration Options


You can configure which files are tested for suites by using the cpp_files ini configuration option:

cpp_files = test_suite*

By default matches test_* and *_test executable files.


New in version 1.1.

Arguments to the C++ tests can be provided with the cpp_arguments ini configuration option.

For example:

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'


New in version 1.2.

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.

cpp_ignore_py_files = False


New in version 1.3.

This option allows the usage of tools that are used by invoking them on the console wrapping the test binary, like valgrind and memcheck:

cpp_harness = valgrind --tool=memcheck


Install using pip:

$ pip install pytest-cpp


Please consult CHANGELOG.


All feature requests and bugs are welcome, so please make sure to add feature requests and bugs to the issues page!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pytest-cpp, version 1.5.0
Filename, size File type Python version Upload date Hashes
Filename, size pytest_cpp-1.5.0-py2.py3-none-any.whl (10.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size pytest-cpp-1.5.0.tar.gz (60.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page