-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorder test execution based on dependencies? #20
Comments
I took a stab at this problem separately from this package. https://gist.github.com/jwineinger/e41473cd5500554a189d8c97ac28f883 does work to reorder dependencies and does so across files and classes as well. I couldn't get it to play nice with the result tracking/skipping in this package but I'm intending to run pytest with -x anyway, so I don't care so much about that part. |
@jwineinger - seems like what I'm looking for. were you able to link tests together? |
@Formartha if by link you mean specify dependencies and reorder so that dependencies are run first, then yes. To be clear though, my linked gist is separate from pytest-dependency, so you don't get any of the features it provides. Just drop the conftest.py into your top-level test directory, install deps, and decorate your tests. |
I have a similar need, make test run in dependency order. There is another module trying this as well: https://github.com/ftobia/pytest-ordering |
I just ran into the same issue. I have a bunch of unit tests and integration tests. The integration tests have a much more complex setup and usually have much more output as well in the failure reports. So I would love to be able to skip them when the linked unit-test fails. But as the tests are run in a different order (I'm not going to rename my tests to control ordering) this will currently always skip the integration test. Even if the unit-test passes. |
Hi all, I think reordering of tests with dependencies is very useful. I used @jwineinger gist code to achieve this, I think it should be very nice to embed that idea in pytest-dependency. |
I've put together a https://gist.github.com/DevilXD/afc7f923049a5abedea55ba186e7219c
EDIT: Updated to ignore parametrization, and properly detect dependency cycles. |
Will there be a new release of pytest-dependency after 0.5.1 that fixed this? Seems this issue affects many people, see for example https://stackoverflow.com/questions/17571438/test-case-execution-order-in-pytest#comment116177289_46393615 |
FWIW: I added an option to pytest-order (a fork of pytest-ordering) to also order dependencies if needed (use |
Actually I think it is not a bad thing that |
This makes I'm considering switching to |
@DevilXD - as I wrote, I think the plugins complement each other. If you only need ordering, you are probably better of with |
Hi all, I suggest to all the people interesting in this issue, to have a look to |
Pytest-dependecy is grossly incomplete without test ordering. It actually introduces to pytest a new logical execution order, but without any engine to enforce it. "Just" skipping is implemented. |
|
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. |
Is there any way to run @mark.depends without changing the tests order? I want that my test will still run in the order they appear in the class but that some of the tests will be dependent on others,
@pytest.mark.depends(on=["test_correct_login"] In this example I want the tests will run in this order but if test_correct_login fails I don't want that test no' 3 will run. |
@LiorPelet I'd recommend taking a look at your pytest env to see if there isn't any other plugin that'd reorder your tests instead. |
@LiorPelet - you seem to use |
@mrbean-bremen I'm confused about how |
Yes, exactly. You can configure it in pytest.ini. |
Is 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.
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.
The text was updated successfully, but these errors were encountered: