The pytest framework makes it easy to write small, readable tests, and can scale to support complex functional testing for applications and libraries.
-
Install package
pip install pytest
-
Create test
- Create a new file called test.py, containing test
- Test function should start with
test_*
-
Run tests
pytest -v test.py
-
Export Result to a file
pytest -v test.py > test_run_$(date "+%Y-%m-%d_%H:%M:%S").log
Sample test result pytest/test_run_2023-02-01_17:59:40.log
Additional:
Implement Unit testing with Git Actions as CI
- Git Actions file defined pytest.yml