Skip to main content

Coverage-based regression test selection (RTS) plugin for pytest

Project description

Coverage-based regression test selection (RTS) plugin for pytest

Usage

Plugin is supposed to be used to execute tests related to changes done locally on developer's machine and in CI environment to test pull requests.

Initialization

To start using pytest-rts build of coverage DB is needed. For Trunk Based Development mapping database from master branch should be used, for A successful Git branching model - develop

  1. Install pytest-cov with pip install pytest-cov
  2. Create a .coveragerc file with the following contents inside to configure pytest-cov:
[run] 
relative_files = True
  1. Execute pytest --cov=[path to your package] --cov-context=test which will run the entire test suite and build a mapping database in .coverage file
  2. Rename the coverage file .coverage produced by pytest-cov to your liking. Example: mv .coverage pytest-rts-coverage

Local usage

  1. Install pytest-rts with pip install pytest-rts
  2. Create a branch git checkout -b feat/new-feature
  3. Make changes in your code
  4. Run the tool with pytest --rts --rts-coverage-db=[path to database]

As a result only tests related to changes in working directory and branch will be executed.

Usage in CI

  • In the main branch (master or develop) make sure you run entire test suite and
    • commit back coverage database
    • or, if the database size is big, upload it to some storage
  • In pull requests:
    • make sure you have coverage database from the main branch located next to the code
    • run pytest --rts --rts-coverage-db=[path to database]

Troubleshooting

  • pytest --rts returns non-zero code: command returns one of the pytest exit codes. For example if pytest-rts module found no tests to execute resulting code will be 5 "No tests were collected"

Development

See DEVELOPER.md for more info

Contributing

Contributing Guidelines

Read through our contributing guidelines to learn about our submission process, coding rules and more.

Code of Conduct

Help us keep the project open and inclusive. Please read and follow our Code of Conduct.

Acknowledgement

The package was developed by F-Secure Corporation and University of Helsinki in scope of IVVES project. This work was labelled by ITEA3 and funded by local authorities under grant agreement “ITEA-2019-18022-IVVES”

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-rts-2.2.0.tar.gz (55.5 kB view hashes)

Uploaded Source

Built Distribution

pytest_rts-2.2.0-py3-none-any.whl (11.5 kB view hashes)

Uploaded Python 3

Supported by

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