Contribute Media
A thank you to everyone who makes this possible: Read More

Code coverage through unit tests running in sub-processes/threads

Description

EuroPython 2022 - Code coverage through unit tests running in sub-processes/threads: Locally and automated on GitHub - presented by Saransh Chopra

[Liffey A on 2022-07-13]

The “Code coverage” value of a codebase depicts how much of the production/development code is covered by the running unit tests. In the world of open-source, all the maintainers try their best to keep this percentage high, and this process is often automated through tools like GitHub Actions and Codecov. Hence, code coverage becomes a good metric (not always) to check if a particular codebase is well tested and reliable.

Open source maintainers often prefer to run these unit tests in sub-processes or threads as it allows them to run in parallel and reduce the CI (continuous integration) run time on pull requests. They also make it easier to stop the tests midway if they are taking too much time (probabilistic tests).

In this talk, we will first try to use coverage.py in the default mode on the unit tests running in a sub-process or a thread. After going through the results, we will build a solution to cover the “un-covered” code in the local repository. As a final step, we will also configure a CI (continuous integration) pipeline using GitHub Actions and Codecov to automate this process in our remote repository.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License http://creativecommons.org/licenses/by-nc-sa/4.0/

Improve this page