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
- Install pytest-cov with
pip install pytest-cov
- Create a
.coveragerc
file with the following contents inside to configurepytest-cov
:
[run]
relative_files = True
- 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 - Rename the coverage file
.coverage
produced bypytest-cov
to your liking. Example:mv .coverage pytest-rts-coverage
Local usage
- Install
pytest-rts
withpip install pytest-rts
- Create a branch
git checkout -b feat/new-feature
- Make changes in your code
- 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
ordevelop
) 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_rts-2.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f449f2f7a6c554b7cffc5278c1b0f81d4fbf212d90c822ddfaaa51fed7d4e8b4 |
|
MD5 | 39019d8e923ec814b6a3fb8c190faffc |
|
BLAKE2b-256 | d19f71c59ba0daacceb4ce3146532b44547ef2e0831b6bdabf7cb28d0648e496 |