Skip to content

Commit

Permalink
🔧 Fix #27 Added code coverage (#28)
Browse files Browse the repository at this point in the history
closes #27
  • Loading branch information
AyslanBatista authored Apr 20, 2024
1 parent e02ed1c commit 53863a3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ jobs:
run: pip install '.[test]' # instalando o programa em forma de test

- name: Run tests
run: pytest -v --forked --junitxml=test-results.xml # Rodando os test e gerando um arquivo como relatorio
run: pytest -v --cov=dundie --forked --junitxml=test-results.xml && coverage xml # Rodando os test e gerando um arquivo como relatorio

- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2 # publicar os test unitarios que viram no arquivo xml
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ fmt:
@.venv/bin/black dundie tests integration

test:
@.venv/bin/pytest --forked
@.venv/bin/pytest --cov=dundie --forked
@.venv/bin/coverage xml
@.venv/bin/coverage html



Expand Down
Binary file modified assets/database.db
Binary file not shown.
2 changes: 2 additions & 0 deletions requirements.test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pytest
pytest-forked
coverage
pytest-cov
flake8
pyproject-flake8
black
Expand Down
8 changes: 8 additions & 0 deletions tests/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ def test_load_positive_has_2_people(request):
def test_load_positive_first_name_starts_with_j(request):
"""Test function load function."""
assert load(PEOPLE_FILE)[0]["name"] == "Jim Halpert"


@pytest.mark.unit
@pytest.mark.high
def test_negative_filenotfound(request):
"""Test function load function."""
with pytest.raises(FileNotFoundError):
load("assets/invalid.csv")

0 comments on commit 53863a3

Please sign in to comment.