Are multiple templates possible in a robot test file?

2,297 views
Skip to first unread message

Tejal Kuchangi

unread,
Aug 10, 2017, 8:24:54 AM8/10/17
to robotframework-users
I have a scenario where in I have a set of test cases that need to be run multiple times with just different arguments.
I could use template for one test case. 
For one test case that needs to be run multiple times, I have one keyword and defined its Template in the Settings. Have gone ahead with this approach of template cause I need to name test case that uses that keyword and need to have a tag for it too as I want to run particular test cases at particular times.
Referring to the below approach

*** Settings ***
Test Template    Login with invalid credentials should fail


*** Test Cases ***                USERNAME         PASSWORD
Invalid User Name                 invalid          ${VALID PASSWORD}
Invalid Password                  ${VALID USER}    invalid
Invalid User Name and Password    invalid          invalid
Empty User Name                   ${EMPTY}         ${VALID PASSWORD}
Empty Password                    ${VALID USER}    ${EMPTY}
Empty User Name and Password      ${EMPTY}         ${EMPTY}


But If I need to now have multiple keywords, which I want to run multiple times in one Robot file, is it possible?
Basically, could we have multiple templates in one robot file?Enter code here...

Geist Eng

unread,
Aug 10, 2017, 5:56:56 PM8/10/17
to robotframework-users
I believe if the Template is defined in the Settings table it applies to all test cases in the suite file.  That is how I mostly use it too.

But if left out of the Settings table one can use the [Template] syntax in a specific test case which turns that test into a data-driven test.

See User Guide section 2.2.7 Test Templates for details.  Here is the link for latest version of this section:

http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-templates
Reply all
Reply to author
Forward
0 new messages