Sample program to teach software testing concepts.
Create virtual environment
pyenv virtualenv mlp-esbd
pyenv activate mlp-esbd
cd IdentifierPy
pip install -r requirements.txt
pip install -e .
python src/IdentifierMain.py abc
python -m pytest -v tests/src/test_validate.py
pytest -v tests/src/test_validate.py
pyinstaller --onefile src/IdentifierMain.py
coverage run --source=src.Identifier -m pytest tests
coverage run --source=src.Identifier --branch -m pytest tests
coverage report
coverage html -d coverage
It 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