Welcome to the testing sandbox: practice-driven testing instrument. It can help you to get more comfortable and skilful at writing different types of tests.
The sandbox has five different levels. Here is an approximate plan:
- Basics unit testing.
- Production-ready unit testing for simple functions (you are here, this is the second part of the level).
- Confident unit testing: advanced features, complicated mocking, tests organisation.
- End-to-end tests mastery.
- TDD and PBT.
Some levels can have sub-levels, and every level can have its process of completion.
Level 2 is about writing tests on more complex units of code: functions with IO. Make sure, that your tests doesn't user disk or network: it makes them slow and unreliable.
- Read/watch everything in a reading list.
- You have some code in
code
module. Write tests for this code with 100% branch coverage. - Push tests to your fork of the repo. Make a pull-request to this repo. This is where review will happen. No pull requests will be merged to this repo.
- Ask your colleague to make a review of your code. Fix all errors.
- Ask me (@melevir) to review your code. Fix all errors.
- Hooray!
- Use python 3.9.
- Use latest pytest.
- Don't compose tests in
TestCase
-style classes, use modules instead. - Setup CI/CD with automatic coverage calculation and badge with coverage in readme.
- Before review, make sure, that tests branch coverage is 100%.
- Review considered to be done when reviewer left 3+ comments.
- Use conventional comments.
- If you think, that some somment is not required to fix, use
non-blocking
decorator. - Every comment without
non-blocking
decorator has to be fixed by the author of code.
Read this before writing the first line of code:
Read/watch this during or after writing tests: