Python Testing Koans to understand how to write unit tests with unittest.
This is a Python project. It is compatible with both Python 2 and 3.
Required dependencies are listed in requirements.txt.
Additional exercises cover parameterized,
PyHamcrest and
assertpy.
Run pip install -r requirements.txt to install the required packages.
Alternatively the dependencies are available in the packages folder.
- Run script
run_tests(orpython -m unittest discover test). - You should see some test failures and errors (but there are no assertions).
- Go through the test code starting from Session 1:
- All assertions are commented and incomplete.
- Uncomment the assertions and complete them making the tests pass.
- You can run individual sessions using
python -m unittest test.test_session1_greeter(Note: Unittest looks for modules not files. Make sure to usetest.nottest/and no trailing.py.)