Search code examples
robotframework

How to run a setup before all test suites?


I know that there are Setup and Suite Setup in RobotFramework, but if I want to do something before a test, and this test package refers to multiple Test Suites. How do I achieve it.

Like below how to achieve all Test Setup & all Test Teardown

**All Test Setup**
    Suite Setup
        Case Setup
            Case1
        Case Teardown
        Case Setup
            Case2
        Case Teardown
    Suite Teardown
    Suite Setup
        Case Setup
            Case1
        Case Teardown
        Case Setup
            Case2
        Case Teardown
    Suite Teardown
**All Test Teardown**

Solution

  • Similarly than all files, all directories are test suites. Thus, for global setup and teardown, you will have to define a Suite setup and Suite teardown for your top level test suite: the directory which holds all your test directories. To do this, create __init__.robot file to this directory and define the setup and teardown there.