0

For the data driven testing, if there are 10 data sets, and the assertion fails for 3rd data set, then the rest of the 7 data sets are not considered for execution and the program gets stopped at that point completely. I have tried by removeing the "raise e" line and that time all the data sets are considered for execution but at the end, the status is showing as PASSED which is absolutely not correct as I need to report failure for 3rd data set. Please let me know if you have any solutions for the same.

I have tried the following 2 methods, and it did not work. For the first one, test case executed 10 times for 10 datasets but even after a failure for the 3rd dataset, the test execution status is showing as PASSED which is not correct as the test case should be failed in the report.

For the second one, the test execution gets stopped completely after assertion failure in the 3rd dataset and the remaining data sets are not considered for execution.

My goal is to execute the test case for all data sets at once and then check the report for any failure.

    try:
        assert len(json_response_plan) == 1
    except Exception:
        pytest.raises(Exception)


    try:
        assert len(json_response_plan) == 1
    except Exception as e:
        raise e
2
  • 1
    It's not entirely clear how you've set up these tests, but it sounds like you have a loop inside a single test. Why not use e.g. parameterised tests instead?
    – jonrsharpe
    Nov 24 at 7:29
  • Please find below my code for your reference
    – user51563
    Nov 24 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.