Test setup inheritance in Robot Framework
10,229
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.
Related videos on Youtube
Author by
Roy Reznik
Updated on September 16, 2022Comments
-
Roy Reznik over 1 year
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.
-
Roy Reznik over 10 yearsInteresting stuff. I ended implementing it another way, also by using a Resource file and a stub function inside that resource file (that doesn't do anything) that the test suite could override. so in any case both test cases would run. But your solution is very good, maybe better.. I'll consider moving :)