diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2283158..594f25e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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/codecov-action@v4.0.1 + 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 diff --git a/Makefile b/Makefile index 06da49a..6d9eea6 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/assets/database.db b/assets/database.db index e4940a3..fcbebd0 100644 Binary files a/assets/database.db and b/assets/database.db differ diff --git a/requirements.test.txt b/requirements.test.txt index 9fabd91..b932f6e 100644 --- a/requirements.test.txt +++ b/requirements.test.txt @@ -1,5 +1,7 @@ pytest pytest-forked +coverage +pytest-cov flake8 pyproject-flake8 black diff --git a/tests/test_load.py b/tests/test_load.py index 201f6ca..597e185 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -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")