How to stop Robot Framework test execution if first testcase FAIL?

被刻印的时光 ゝ 提交于 2019-11-30 14:15:45

问题


As shown in below robot file, I have three testcases. I want to stop the test execution, if TESTCASE1 fails. TESTCASE2 should be executed only if TESTCASE1 passes.

*** Settings ***

Library         pythonLib


*** Test cases ***

TESTCASE1
    boot device

TESTCASE2
    configure device

TESTCASE3
    restart device  

Is there any keyword or custom way to do this ?


回答1:


There is a command line option for this, if you want the behavior that robot should stop running as soon as any test fails. This option is --exitonfailure. From the robot framework user guide, in a section titled Stopping when the first test fails:

If option --exitonfailure is used, test execution stops immediately if any critical test fails. Also the remaining tests are marked as failed.

You might also want to take a look at this answer to the question Automatic failing/non-execution of interdependent tests in Robot Framework, which shows how to write a keyword to implement dependencies between test cases.




回答2:


--pause_on_failure, this will stop the execution, whenever script hit the error. Script execution won't be resumed unless you explicitly start.



来源:https://stackoverflow.com/questions/33319992/how-to-stop-robot-framework-test-execution-if-first-testcase-fail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!