docs(python): pytest-xdist reference (#16231)
Partially resolves https://github.com/microsoft/playwright-python/issues/1442. Tests: https://github.com/microsoft/playwright-pytest/pull/128.
This commit is contained in:
parent
5d7e80bed6
commit
e224159683
|
|
@ -47,6 +47,14 @@ You can run a single test, a set of tests or all tests. Tests can be run on one
|
|||
pytest test_login.py --browser webkit --browser firefox
|
||||
```
|
||||
|
||||
- Running Tests in parallel
|
||||
|
||||
```bash
|
||||
pytest --numprocesses auto
|
||||
```
|
||||
|
||||
(This assumes `pytest-xdist` is installed. For more information see [here](./test-runners.md#parallelism-running-multiple-tests-at-once).)
|
||||
|
||||
For more information see [Playwright Pytest usage](./test-runners.md) or the Pytest documentation for [general CLI usage](https://docs.pytest.org/en/stable/usage.html).
|
||||
|
||||
## Running Tests
|
||||
|
|
|
|||
|
|
@ -63,6 +63,21 @@ def test_my_app_is_working(fixture_name):
|
|||
- `browser_type_launch_args`: Override launch arguments for [`method: BrowserType.launch`]. It should return a Dict.
|
||||
- `browser_context_args`: Override the options for [`method: Browser.newContext`]. It should return a Dict.
|
||||
|
||||
## Parallelism: Running Multiple Tests at Once
|
||||
|
||||
If your tests are running on a machine with a lot of CPUs, you can speed up the overall execution time of your test suite by using [`pytest-xdist`](https://pypi.org/project/pytest-xdist/) to run multiple tests at once:
|
||||
|
||||
```bash
|
||||
# install dependency
|
||||
pip install pytest-xdist
|
||||
# use the --numprocesses flag
|
||||
pytest --numprocesses auto
|
||||
```
|
||||
|
||||
Depending on the hardware and nature of your tests, you can set `numprocesses` to be anywhere from `2` to the number of CPUs on the machine. If set too high, you may notice unexpected behavior.
|
||||
|
||||
See [Running Tests](./running-tests.md) for general information on `pytest` options.
|
||||
|
||||
## Examples
|
||||
|
||||
### Configure Mypy typings for auto-completion
|
||||
|
|
|
|||
Loading…
Reference in a new issue