问题
I have a csv
file which contains TestcaseID,Testcase Description,Tag and input to the testcase like below
TUNG001,sample1,sampletag1,01
TUNG002,sample2,sampletag2,02
I want to iterate through this file and fetch each row and start a test case(which will be TestcaseID) using a common function. After researching, I found out that this feature is not implemented in Robot Framework.
Someone please suggest how I can achieve this.
回答1:
Here's how you COULD do this, below this is are better ways to do it.
- Read the entire file using OperatingSystem GetFile
- As there is a new testcase on every line, split file contents on newline using String keyword Split To Lines
- Use String keyword Split String to split line into testcase and inputs.
- Use OperatingSystem Run inside a for-loop to execute each test.
Instead of doing that way, you should instead use resource and variable files to define the input for each of the testcases, and then just execute the entire test suite (or specified test cases) with the file as input. This will essentially do all of that work for you for free.
来源:https://stackoverflow.com/questions/30076228/robot-framework-running-multiple-testcases-using-csv-and-for-loop