0

I have two test cases test_A(a,b,c) and test_B(a,b,c) in a python file. I use parameterization ( metafunc.parametrize("a,b,c",[(a1,a2,a3),....(y1,y2,y3)]) to pass 6 set of parameters to these tests.

The parameters are like this

Params_A Params_B
(a1,a2,a3) (x1,x2,x3)
(b1,b2,b3) (y1,y2,y3)
(c1,c2,c3) (y1,y2,y3)

Right now I can execute both tests with all 6 parameters. Now I want to pass only Params_A to test_A and if test_A fails for eg., with params (b1,b2,b3), I need to execute test_B with the corresponding params (y1,y2,y3).

I don't know how to go about this. Any pointers would be very helpful

I wrote the tests. I tried using fixtures, mark.skipif, pytest_runtest_makereport but no luck so far. And test_A and test_B do the same thing. I created the second test to be able to split the 6 parameter sets equally between the tests.

  • 1
    I think easiest would be to combine test_A and test_B into one test case, then use logic within the test function. e.g. pass all six params as args to the single test `(b1,b2,b3, y1,y2,y3)` and then only do the part B if part A failed – Anentropic Jul 21 '23 at 10:53
  • Yeah, but I do not want to do that because, in the report I want to say that test a has failed and so test b was executed. This answer seems to be a close match, I used this setting scope="module" and it works. https://stackoverflow.com/questions/53545315/can-pytest-run-a-test-iff-another-fails – yowaf21832 Aug 04 '23 at 21:36

0 Answers0