Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test setup inheritance in Robot Framework

I'm trying to create a test setup hierarchy in robot framework.

I have a sub-suite, that defines its own Test Setup - but this overrides the parent suite's Test Setup.

I want both Test setups to run - one after the other, first the Parent Test Setup (that is defined in init.txt) and after that the Test setup that is defined using the * Settings * section.

like image 840
Roy Reznik Avatar asked Sep 03 '13 09:09

Roy Reznik


1 Answers

You can achieve this kind of behavior at least with a bit of a hack way, by using set global variable, run keywords and an external resource file. This however requires you to define the test setup setting with a variable.

Example below:

Contents of __init__.txt:

*** Settings ***
Resource      Resource.txt
Suite setup   Set test setup variable
Test setup    Test setup keyword

*** Keywords ***
Set test setup variable
    Set global variable    ${test setup variable}    Test setup keyword

Contents of Resource.txt:

*** Keywords ***
Test setup keyword
    Log    Test setup from top level

Contents of Test_suite.txt:

*** Settings ***
Resource      Resource.txt
Test setup    Run keywords    ${test setup variable}    Test setup from test suite

*** Test cases ***
Test test setups
    Log    this should run two log keywords.

*** Keywords ***
Test setup from test suite
    Log    Test setup from test suite

I think this is the closest you can get.

like image 82
kontulai Avatar answered Sep 18 '22 06:09

kontulai