Reorder test execution based on dependencies?
See original GitHub issueIs there any intent to reorder test execution according to dependencies? The current behavior I observe is that if I have two tests, where the first depends on the second, the first is just skipped. It would be preferable to reorder them so that they can both execute, rather than relying on source code order.
import pytest
@pytest.mark.dependency(depends=["test_parent"])
def test_child():
pass
@pytest.mark.dependency
def test_parent():
pass
$ pytest
==== test session starts ====
platform linux -- Python 3.6.4, pytest-3.5.0, py-1.5.3, pluggy-0.6.0 -- /usr/local/bin/python
cachedir: .pytest_cache
rootdir: /tests, inifile:
plugins: dependency-0.3.2
collected 2 items
test_file.py::test_child SKIPPED
test_file.py::test_parent PASSED
==== 2 passed, 1 skipped in 0.01 seconds ====
NOTE: https://github.com/ftobia/pytest-ordering does some of this, but requires explicit ordering. I’d rather just define the dependencies and let the system figure it out.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:20 (1 by maintainers)
Top Results From Across the Web
Dependencies and ordering of tests - Testim overview
Although we definitely prefer to endorse the best practice of isolated tests, we did leave a way to organize the execution order.
Read more >Determine the order of Tests when tests have dependencies ...
Let's consider each test case as Vertex and dependency between two tests as Edge between two vertices. So, for example, B depends on...
Read more >Test case execution order in pytest - python - Stack Overflow
Mark test dependency as fixture and pass it as an argument to dependent one. Save this answer.
Read more >The Order of Tests in JUnit - Baeldung
Learn how to run JUnit tests in a custom order. ... MethodName to sort test methods based on their names and their formal...
Read more >What are TestNG Dependent Tests and How to ... - Tools QA
Since the group and the annotation is the same, TestNG will run the methods in the alphabetical order · TestNG lets you create...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi all, I suggest to all the people interesting in this issue, to have a look to
pytest-depends
(https://pypi.org/project/pytest-depends/; https://gitlab.com/MaienM/pytest-depends).Using both plugins forces to define order twice (implicitly with pytest-dependency and explicitly with pytest-order), while pytest-dependency already determines the execution order. Plus, it’s easy to create conflicting orders:
Pytest-dependency already defines execution order, but does not enforce it in any way. It should be essential part of it.
Looking at a car, all a driver does is turning a steering wheel and pushing pedals in order to travel. But there is a lot more required in addition to supporting the steering wheel and the pedals in order to make the driver travel.