Skip to content

Commit

Permalink
updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Formartha committed Apr 9, 2024
1 parent 5f0d639 commit 76d3848
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ How to install?
pip install pytest-node-dependency
```

how to use?
How to use?
-----------------------------------------------------
To set up a test dependency, decorate the test function with the `depends` mark and provide a list of dependencies via the `on` keyword argument to the decorator. Dependencies can be specified by name only when in the same file as the test being decorated or by the pytest node path for tests in other files/classes.

Expand All @@ -36,7 +36,38 @@ def test_first(request):
assert request.session.items[0].name == 'test_first'
```

Xdist adoption:
---------------
The way xdist plugin works is by utilizing multiple cores and spreads the tests among them.
The problem with the plugin is that if you wish to use reordering, you probably want to set some dependency among the tests,
However, the xdist plugin will break it.

For that, you should set the group for the tests. The group means that a gateway worker will collect the tests, and will
place all the grouped tests in a single gateway worker.
This will lead creation of serial testing among parallel exectuion.

```
import pytest
@pytest.mark.depends(xdist_group='a')
def test_second(request):
print("second")
assert request.session.items[1].name == 'test_second'
@pytest.mark.depends(on=["test_plugin.py::test_second"], xdist_group='a')
def test_last(request):
print("last")
assert request.session.items[2].name == 'test_last'
def test_first(request):
print("first")
assert request.session.items[0].name == 'test_first'
```


Limitations and known issues:
-----------------------------------------------------
* The plugin logic makes tests run one after the other in a serial way, as a result, x-dist isn't supported (currently).
* All the tests without depednecy (both dependent on and depends on) will run first, afterwards all tests with connections will run (e.g. the list of items will be as described)
* All the tests without dependency (both dependent-on) will run first, then, all tests with connections will run
(e.g. the list of items will be as described)

0 comments on commit 76d3848

Please sign in to comment.