Skip to content

jugaldb/pytest-tcp

 
 

Repository files navigation

pytest-tcp

pre-commit.ci status

A Pytest plugin for test-case prioritization.

This pytest plugin allows you to find failures faster and receive sooner debugging feedback from CI. It does so by prioritizing running tests that have shorter execution time and/or recently failed.

Installation

To install "pytest-tcp" via pip from PyPI:

pip install pytest-tcp

Usage

Pytest will automatically find the plugin and use it when you run pytest. You can use the default prioritization heuristic, which runs tests that have shorter execution time first by passing the --tcp option:

pytest --tcp

The terminal output will tell you the current configurations and runtime overhead of this plugin:

Using TCP weights 1-0
Collect TCP features took 0.0029001235961914062s.
Compute TCP order took 0.0002548694610595703s.

You can configure the weights of different prioritization heuristics by additionally passing the `--tcp-weight flag with formatted values:

pytest --tcp --tcp-weight=0-1

Weights are separated by hyphens -. The 1st weight is for running faster tests, the 2nd weight is for running recently failed tests. The sum of all weights must equal to 1. A higher weight means that a corresponding heuristic is favored. The default value is 1-0, meaning it entirely favors running faster tests.

You can make these options always apply by adding them to the addopts setting in your pytest.ini:

[pytest]
addopts = --tcp --tcp-weight=0.5-0.5

Contributing

Contributions are very welcome. Tests can be run with tox.

License

Distributed under the terms of the MIT license, "pytest-tcp" is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

About

A Pytest plugin for doing test prioritization on python tests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%