- Pytest not only makes it simple to write tests, it has many command line options that increase productivity, such as running the last failed tests or running a specific group of tests by name
- Customization is important and pytest goes a step further by defining a very powerful plugin system. Plugins can change several aspects of the test run, from how tests are executed to providing new fixtures and capabilities to make it eas to test many types of application frameworks.
- There are plugins that execute the tests in random order each time to ensure tests are not changing global state that might effect other tests.
- There are number of external plugins Refer Here
Writing and running tests
- Using pytest all you need to do to start writing tests is to create a new file named
test_*.pyand write test functions that start with test
- Refer Here for the changes
- We can start executing the tests just by executing the
- Refer Here for seperate folder added for tests
- Lets try to run a specific test case
pytest .\tests\test_number.py::test_iseven_negative -v
- To see which tests are there without running them use –collect-only
- Exercise: Create some basic tests for the inventory application.