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:

https://raw.githubusercontent.com/pytest-dev/pytest-cpp/master/images/screenshot.png

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

Usage

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

cpp_files

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.

cpp_arguments

New in version 1.1.

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

For example:

[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'

cpp_ignore_py_files

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.

[pytest]
cpp_ignore_py_files = False

cpp_harness

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:

[pytest]
cpp_harness = valgrind --tool=memcheck

Install

Install using pip:

$ pip install pytest-cpp

Changelog

Please consult CHANGELOG.

Support

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

Project details


Download files

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

Source Distribution

pytest-cpp-1.3.0.tar.gz (61.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_cpp-1.3.0-py2.py3-none-any.whl (10.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-cpp-1.3.0.tar.gz.

File metadata

  • Download URL: pytest-cpp-1.3.0.tar.gz
  • Upload date:
  • Size: 61.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.0

File hashes

Hashes for pytest-cpp-1.3.0.tar.gz
Algorithm Hash digest
SHA256 9c818455f34977b22a2bb7bafe989c23f2fd3c4b2e49fdc70cf2ad62025ac169
MD5 56225b3dfff6618766174f7d2ddcdfab
BLAKE2b-256 1910b5162daa639b0971c5fb467c02348b88d9a6ea565a298c121fa2b39a8122

See more details on using hashes here.

File details

Details for the file pytest_cpp-1.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_cpp-1.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.0

File hashes

Hashes for pytest_cpp-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b837ca89c53c7678e1ea91c485800ab1fc1e2529ca3497e22734a62085ede8f7
MD5 d4cbeeb58a3ea97ffebf247814345d6e
BLAKE2b-256 17ecaa452254b6835cca20616511dbaceff41123433f3304c58459638553539e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page