Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Robot framework: run setup for an entire test suite

Is it possible in ROBOT to run a setup for an entire test suite, rather than running the setup individually for each file? I want to run setup at the beginning of the suite, and if the setup fails, not run any of the test cases at all.

For example, given the following file:

*** Settings ***
Test Setup    Setup Fails

*** Test Cases ***
Case1
    Should Be True    1<2

Case2
    Should Be True    2<1

*** Keywords ***
Setup Fails
    Should Be True    2<1

I want neither Case1 nor Case2 to execute at all. As it is, both attempt to use Setup Fails as setup individually, and the output.xml file has a status for each test case of FAIL with a message saying "Setup failed...". Instead, I would like the xml file to have a status for the suite of 'FAIL' with a message of "Setup failed..." and the test cases to either not be included or to indicate that they have not been run.

Is this something ROBOT supports?

Instead, I would like to receive an error message

like image 856
ewok Avatar asked Dec 05 '22 19:12

ewok


1 Answers

Robot supports suite setups. For example:

*** Settings ***
Suite Setup    Setup Fails

*** Test Cases ***
Case1
    Should Be True    1<2

Case2
    Should Be True    2<1

*** Keywords ***
Setup Fails
    fail    Danger Will Robinson!

The above yields the following results:

==============================================================================
Example                                                                       
==============================================================================
Case1                                                                 | FAIL |
Parent suite setup failed:
Danger Will Robinson!
------------------------------------------------------------------------------
Case2                                                                 | FAIL |
Parent suite setup failed:
Danger Will Robinson!
------------------------------------------------------------------------------
Example                                                               | FAIL |
Suite setup failed:
Danger Will Robinson!

2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
like image 95
Bryan Oakley Avatar answered Dec 28 '22 07:12

Bryan Oakley