Testing in python
Test is integral part of sofware quality and should not be missed.
- Always use
pytestfor testing codes.unittestprovided by standard python can be used too if there is some blockage in usingpytest.
toxandnoxare vey good tools especially for CI and multiple version tests.mockshould be used for mocking data.factory_boyandfakercan be used for fixtures and fake data.hypothesiscan be used for property testing.- Testing should be broken to
unitas well asfunctional. - Use
coverageto alert yourself of test coverage. Keep a target of 80 % - 90 % coverage if 100% is not achieved. - Only test the changes you made or functionality you added when testing a codebase of well known frameworks.
seleniumas well aswebtestcan be used for web based API testing.jsonschemaandgensonlike tool can be used for JSON validity.- Always confirm the
schemawhen testing Web API response data. - Passing tests for
mergeshould be priority for all projects. - Tests should always cover:
- Unit: for your code units. Please use
mockfor external dependency and side effects. - Functional: Your program functionality.
- Integration: Your whole program integration.
- Unit: for your code units. Please use
See tools for packages links.