I need to provide multiple inputs to a testcase using robot framework. I had done similarly in pytest with parameterization, is there any similar way to do in robot framework as well..
4 Answers
You can use variables for this. for example
robot --variable HOST:10.0.0.2:1234 /testfolder/
variable ${HOST} will have value 10.0.0.2:1234 in this testrun
1 Comment
I think you can use Arguments using Robot framework. Keywords can accept zero or more arguments, and some arguments may have default values. It is best way to supply parameters to your testcase/keyword based on input required. More documentation can be found at - http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-arguments
Comments
Approach that i made: As i'm calling my robot call only once for a suite and in test suite each indivdual test case may have different no and different variables. I made a json file to have: test suite name > test case name > test case params max no of params in that test suite . I'm adding a common tag as param1 param2 for test cases based on no of params for each tc and iterate the call for the robot test suite with above tags and variable as ${params} with tag name. So that only those test cases will be picked. Param details i'm reading the json file in the test case based on the variable passed ${params}.
eg,.
robot --variable params:param1 -i param1
robot --variable params:param2 -i param2
TestCase[xxx]: Sample Test Case
[Documentation] Sample Test Case
[Tags] Sanity param1 param2 param3
Comments
I found the following solution close to pytest parametrize option. You can put entire test case in a FOR loop, which will use list values as a parameter to pass into test case for each new run. Example code below:
*** Test Cases ***
Test Case
FOR ${parameter} IN @{parameters}
Log ${parameter}
END