pytest-ordering icon indicating copy to clipboard operation
pytest-ordering copied to clipboard

Ordering with multiple files

Open naggappan opened this issue 9 years ago • 7 comments

Use case:

  • creaet a test file "test_example1.py"
  • Mark order from 1 to 5 for different test_methods
  • Now create another test file "test_example2.py"
  • Mark order from 1 to 5 for different test_methods
  • py.test executes order 1 from both the files first even the test_method names are diffrent
  • And it goes in similar pattern, executing order=1 in all files then goes to order=2 in all files etc.

It becomes very difficutl when we have more than 100 test case , If any one test case is added in single file we need to change the order number in all test case files. More info in "http://stackoverflow.com/questions/35909656/pytest-ordered-plugin-doesnt-work-with-combination-of-multiple-files"

naggappan avatar Mar 23 '16 07:03 naggappan

Hi @naggappan, Did you managed to work it out? we have the same exact issue we are trying to solve. I don't mind switching tools - I just need it to work :)

Formartha avatar Jul 31 '18 04:07 Formartha

@Formartha no it did not worked in that way. So we made our test cases not dependent . setup class then do the test for that particular class and then tear down class thats it. more number of test case py files but that solved the issue

naggappan avatar Jul 31 '18 08:07 naggappan

I have the same issue.....Have a lot of test cases, add sequence for them, if add new one between, have to update all sequence which after new added test case.

chrisyang0604 avatar Jul 10 '20 07:07 chrisyang0604

Have same issue, the workaround is to list all files on the commandline in the order they should run and drop the sequence althogether.

fenchu avatar Oct 07 '20 07:10 fenchu

In case that helps someone: I added a command line option to set the order scope in my fork - by using --order-scope=module you will get the needed behavior (e.g. ordering is done per module).

mrbean-bremen avatar Nov 02 '20 16:11 mrbean-bremen

this link help me to resolve this issue https://stackoverflow.com/questions/35909656/pytest-ordered-plugin-doesnt-work-with-combination-of-multiple-files/67395190#67395190

shakthifuture avatar May 05 '21 04:05 shakthifuture

@shakthifuture - that answer uses the forked pytest-order which I mentioned in my comment above - it does not resolve the problem for pytest-ordering. If you use that fork, you also have to change your order markers (for example from pytest.mark.run(order=2) to pytest.mark.order(2)).

mrbean-bremen avatar May 05 '21 05:05 mrbean-bremen