How to make multi-lines test setup or teardown in RobotFramework without creating new keyword?

前端 未结 2 677
长发绾君心
长发绾君心 2021-02-01 07:25

I need to call two teardown keywords in test case but must not create new keyword for that. I am interesting if there is a such syntax for keywords as for documentation or loops

2条回答
  •  耶瑟儿~
    2021-02-01 08:04

    For executing multiple keywords in Test Teardown method use the following trick:

    Firstly, define a new keyword containing the set of keywords you want to execute.

    E.g. here Failed Case Handle is a new definition of the other two keywords take screenshot and close application. Consider this is to take a screenshot and then close the running application.

    *** Keywords ***
    Failed Case Handle
        take screenshot
        close application
    

    Basically, when you call the Failed Case Handle keyword, take screenshot and close application will be executed respectively.

    Then, in the ***Settings*** section define the Test Teardown procedure by the following example.

    *** Settings ***
    Test Teardown  run keyword if test failed  Failed Case Handle
    

    or,

    *** Settings ***
    Test Teardown  run keyword  Failed Case Handle
    

    So, in the first case Failed Case Handle keyword will be called if any test case fails. On the other-hand in the second case Failed Case Handle keyword will be called after each test cases.

提交回复
热议问题