Sample program to teach software testing concepts.
Create virtual environment
pyenv virtualenv mlp-esbdpyenv activate mlp-esbdcd IdentifierPypip install -r requirements.txtpip install -e .python src/IdentifierMain.py abcpython -m pytest -v tests/src/test_validate.pypytest -v tests/src/test_validate.pypyinstaller --onefile src/IdentifierMain.pycoverage run --source=src.Identifier -m pytest tests
coverage run --source=src.Identifier --branch -m pytest tests
coverage report
coverage html -d coverageIt is also possible to configure a .coveragerc file
[run]
source = src
branch = True
omit = */tests/*
coverage run --omit='*/tests/*' --branch -m pytest # Run pytest with coverage (fail if coverage < 80%). Include "--cov-branch \" below to use branch coverage
- name: Run tests with coverage
run: |
pytest --cov=./ \
--cov-report=xml \
--cov-fail-under=60 \
test_pipeline.py
- name: Upload to Codecov
if: success() # Only run if previous steps succeed
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # Uses the secret
file: ./coverage.xml # Explicit path to coverage file
flags: github-actions # Optional: tag this upload
override_commit: ${{ github.event.pull_request.head.sha }}
override_branch: ${{ github.event.pull_request.head.ref }}Berofe run this tool, make sure to install requirements.txt dependencies.
mut.py -t src/Identifier.py -u tests/test_validate.py --runner pytest --report-html mutpy