Pytest Tutorial
Selected Reading
- Pytest - Discussion
- Pytest - Useful Resources
- Pytest - Quick Guide
- Pytest - Conclusion
- Pytest - Summary
- Test Execution Results in XML
- Pytest - Run Tests in Parallel
- Stop Test Suite after N Test Failures
- Pytest - Xfail/Skip Tests
- Pytest - Parameterizing Tests
- Pytest - Conftest.py
- Pytest - Fixtures
- Pytest - Grouping the Tests
- Substring Matching of Test Names
- Execute a Subset of Test Suite
- Pytest - File Execution
- Pytest - Starting With Basic Test
- Identifying Test files and Functions
- Pytest - Environment Setup
- Pytest - Introduction
- Pytest - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Pytest - Run Tests in Parallel
Pytest - Run Tests in Parallel
By default, pytest runs tests in sequential order. In a real scenario, a test suite will have a number of test files and each file will have a bunch of tests. This will lead to a large execution time. To overcome this, pytest provides us with an option to run tests in parallel.
For this, we need to first install the pytest-xdist plugin.
Install pytest-xdist by running the following command −
pip install pytest-xdist
Now, we can run tests by using the syntax pytest -n <num>
pytest -n 3
-n <num> runs the tests by using multiple workers, here it is 3.
We will not be having much time difference when there is only a few tests to run. However, it matters when the test suite is large.
Advertisements