3

I am running multiple test cases (within a test suite) in robot framework. If the first test case setup section fails, then I want to skip the execution of all the remaining test cases.

Please let me know if there is any way to do that?

1

4 Answers 4

3

There is a command line option for this, the option is "--exitonfailure" Here if any critical test case fails, the test execution stops immediately.

Sign up to request clarification or add additional context in comments.

2 Comments

how you please include an example on how to use this --exitonfailure option?
Try robot --exitonfailure mytests.robot
2

Until a SKIP status is implemented, you can use exitonfailure to stop further execution if a critical test failed, and then change the output.xml (and the tests results.html) to show those tests as "NOT_RUN" (gray color), rather than "FAIL" (red color):

enter image description here

I've already posted how to implement it here: https://stackoverflow.com/a/55745118/658497

Comments

2

There is currently no way to skip some tests depending on the failure of a given test. That might be implemented in the future as it is being discussed in an issue on GitHub.

In the meantime, what you can do is have a suite that groups your tests and in the Suite Setup, do some initial checks/verification (that would be similar to the test failure you mention). If the Suite Setup fails, then the tests of the suite won't be run.

1 Comment

That's good point. I would say particular test cases should be independent. I.e. failure of one test (even in setup phase of the test) shouldn't touch other tests.
0

I sort of made my own way to do this using test setup & teardown. All tests that use this setup will still run. But any test AFTER the first failure will be skipped.

*** Settings ***
Test Setup      pre check with skip read
Test Teardown    post check with suite abort

*** Variables ***
${continue}    1

*** Keywords ****
pre check with skip read
 Skip If   ${continue} != 1   msg=Skipping due to previous failure

post check with suite abort
 [Documentation]   Any test after this can be skipped if this test fails!
 Run Keyword If Test Failed   Set Suite Variable   ${continue}   0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.