Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

tests coverage reporting #368

Closed
MaaniBeigy opened this issue Aug 27, 2021 · 2 comments
Closed

tests coverage reporting #368

MaaniBeigy opened this issue Aug 27, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@MaaniBeigy
Copy link

MaaniBeigy commented Aug 27, 2021

🚀 Feature Request

Tests coverage reporting.

🔈 Motivation

I found it in your ToDos. I implemented it for my own package pycvcqv using pytest-cov, coverage-badge, and, pytest-html .

🛰 Alternatives

To implement such a solution:

  1. first, edit your pyproject.toml:
[tool.poetry.dev-dependencies]
coverage = "*"
coverage-badge = "*"
pytest-html = "*"
pytest-cov = "*"

[tool.coverage.run]
source = ['package_name', 'tests_folder']

[coverage.paths]

source = 'package_name'

[coverage.run]
branch = true

[coverage.report]
fail_under = 50
show_missing = true
  1. next, mkdir assets/images/.
  2. Then, add these lines to Makefile:
.PHONY: coverage
coverage:
	poetry run pytest --cov-report html --cov packagename tests/
	poetry run coverage-badge -o assets/images/coverage.svg -f
  1. Then, run these lines:
make install
make test && make coverage && make check-codestyle && make mypy && make check-safety
  1. Finally, add this to the README.md:
[![coverage report](assets/images/coverage.svg)]

You, will have something like coverage report.

📎 Additional context

More importantly, you can open htmlcov/index.html in your browser and observe the covered/uncovered codes.

image

image

@MaaniBeigy MaaniBeigy added the enhancement New feature or request label Aug 27, 2021
@TezRomacH
Copy link
Owner

Thanks so much! It works like magic!

I have added coverage inside make test command

You now may try to create new package

cookiecutter gh:TezRomacH/python-package-template --checkout v1.1.1

@TezRomacH
Copy link
Owner

Also i have added you as a contributor in the version release notes
https://github.com/TezRomacH/python-package-template/releases/tag/v1.1.1

Thanks again, it was really helpful feature :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants