Skip to content

Commit 8fce3af

Browse files
chore: add coverage reporting to pytest
Add `pytest-cov` to `requirements-dev.txt` and enable coverage reporting in `run_tests.py` by including `--cov` and `--cov- report=xml` options. This provides insight into code coverage, helping to identify areas lacking test coverage.
1 parent 847d33d commit 8fce3af

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ jobs:
3737
python run_tests.py
3838
3939
- name: Upload coverage to Codecov
40-
if: matrix.python-version == '3.11'
40+
if: matrix.python-version == '3.12'
4141
uses: codecov/codecov-action@v5
4242
with:
4343
files: ./coverage.xml
44+
token: ${{ secrets.CODECOV_TOKEN }}
4445
fail_ci_if_error: false
4546

4647
validate:

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Development dependencies
22
pytest>=7.0.0
33
pytest-asyncio>=0.20.3
4+
pytest-cov
45
pytest-homeassistant-custom-component>=0.13.0
56

67
# Home Assistant testing

run_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ def run_tests():
2222
sys.executable,
2323
"-m",
2424
"pytest",
25-
"custom_components/custom_areas/tests/",
2625
"-v",
27-
"--tb=short",
26+
"--cov",
27+
"--cov-branch",
28+
"--cov-report=xml",
2829
],
2930
capture_output=True,
3031
text=True,

0 commit comments

Comments
 (0)