Search code examples
robotframeworktestcase

Robot Framework Test Flow


It's possible to require an execution of a specific test case before the execution of the current test case?

My test cases are organized in several folder and it's possible that a test require the execution of the another test placed in the another folder (see the image below).

enter image description here

Any suggestions?


Solution

  • This is not a good / recommended / possible way to go.

    Robot framework doesn't support it, and for a good reason. It is not sustainable to create such dependencies in the long term (or even short term).

    Tests shouldn't depend on other tests. Mainly not on other tests from a different suite. What if the other suite was not run?

    You can work around the issue in two ways:

    You can define a file called

    __init__.robot 
    

    In a directory. That suite setup and suite teardown in the file would run before anything in the underlying folders.

    You can also turn the other test into a keyword so:

    Test C simply calls a keyword that makes Test C run and also updates a global variable (Test_C_already_runs)

    Test B would use then issue

    run if  '${Test_C_already_runs}'=='true'  Test_C_Keyword
    

    You would have to set a value to Test_C_already_runs before that anyway (as part of variable import, or as part of some suite_setup) to prevent variable not found error.