Reputation: 119
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?
Upvotes: 3
Views: 6286
Reputation: 1
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
Upvotes: 0
Reputation: 6935
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.
Upvotes: 2
Reputation: 16971
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):
I've already posted how to implement it here: https://stackoverflow.com/a/55745118/658497
Upvotes: 2
Reputation: 31
There is a command line option for this, the option is "--exitonfailure" Here if any critical test case fails, the test execution stops immediately.
Upvotes: 3