How to use templatize a Robot Keyword than a whole test case using [Template] syntax?
Need is:
A resource file creates a Keyword in keywords.robot :
*** Keywords ***
Do Something
[Arguments] ${arg1} ${arg2}
Print args ${arg1} ${arg2}
A Robot test case file imports this resource and uses above keyword as:
Resource keywords.robot
*** Test cases ***
Some test case
Execute test step 1
Execute test step 2
Execute test step 3
#Now use the Keyword defined in resource file with [Template]
Do Something
[Template]
1 2
3 4
Is there a way to achieve above requirement? As there are test steps which need to be repeated with arguments, not the whole test case.
Thanks.
Vivek
there are many way to Rome ... one I can think of is below
keywords.robot :
*** Keywords ***
Do Something
[Arguments] ${arg1} ${arg2}
Print args ${arg1} ${arg2}
Precondition Steps
Execute test step 1 Execute test step 2 Execute test step 3
test case file imports keywords.robot and sets 'Do Something' as a Test Template and 'Precondition Steps' as Test Setup so that before each test case all 'Precondition Steps' will be executed. Then within each test case all steps which are defined in 'Do Something' will be executed with according arguments:
*** Settings ***
Resource keywords.robot
Test Template Do Something
Test Setup Precondition Steps
*** Test cases *** ARG1 ARG2
001 some test case 1 2
002 some test case 3 4
003 some test case foo bar
references: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#data-driven-style
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-templates
Cheers
Tset--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
# keywords.robot
*** Keywords ***
Do Something
[Arguments] ${arg1} ${arg2}
Print args ${arg1} ${arg2}
Precondition Steps
Execute test step 1
Execute test step 2
Execute test step 3
# test case/suite file
*** Settings ***
Resource keywords.robot
Test Template Do Something
Test Setup Precondition Steps
*** Test cases *** ARG1 ARG2
001 some test case 1 2
002 some test case 3 4
003 some test case foo bar