Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support coverage badge generation from pytest --junitxml file #36

Open
pixelpicnic opened this issue Feb 16, 2024 · 2 comments
Open

support coverage badge generation from pytest --junitxml file #36

pixelpicnic opened this issue Feb 16, 2024 · 2 comments

Comments

@pixelpicnic
Copy link

It would be great if we could leverage the same xml from the pytest report generation to generate the coverage badge without needing to install the coverage module.

currently the workflow would be:

# generate reports:
# test report
pytest --cov-report=html:reports/coverage --junitxml=reports/coverage/pytest_coverage.xml
# coverage report
coverage xml -o reports/coverage/coverage.xml

# generate badges
# tests badge
genbadge tests -i < reports/coverage/pytest_coverage.xml -o reports/badges/tests-badge.svg
# coverage badge
genbadge coverage -i reports/coverage/coverage.xml -o reports/badges/coverage-badge.svg

is it possible to consolidate these steps?

pytest --cov-report=html:reports/coverage --junitxml=reports/coverage/pytest_coverage.xml
genbadge tests coverage -i reports/coverage/pytest_coverage.xml -o reports/coverage/

where -o reports/coverage/ will generate badges with default names, and specifying names would require badges to be generated individually.

appreciate the project!
Thanks very much

@smarie
Copy link
Owner

smarie commented Mar 11, 2024

Thanks @pixelpicnic for the suggestion!

without needing to install the coverage module

pytest-cov is just a tiny wrapper of coverage so you install it already :) : https://github.com/pytest-dev/pytest-cov/blob/master/setup.py#L133

Does it change your opinion about this feature ? Otherwise I'll accept any non-destructive PR (i.e. all existing features must continue to work as is) that would implement it.

You might need to leverage click's multi command design https://stackoverflow.com/a/59391691/7262247 , hopefully this won't get too complex.

@pixelpicnic
Copy link
Author

Cheers @smarie, I'll give that a shot.
Thanks for the info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants