February 2022
Intermediate to advanced
274 pages
6h 28m
English
Generally we’d like each of our tests to be able to run independently of all other tests. Having independent tests allows for easy debugging if something ever fails. If test order inadvertently depends on the state of the system being tested, that independence is broken. One common way to test for order independence is to randomize the test run order.
The pytest-randomly plugin is excellent randomizing test order. It also randomizes the seed value for other random tools like Faker and Factory Boy. Let’s try it out on a couple simple test files:
| | def test_one(): |
| | pass |
| | |
| | |
| | def test_two(): |
| | pass |
| | def test_three(): |
| | pass |
| | |
| | |
| | def test_four(): |
| | pass |
If we ...
Read now
Unlock full access