Robot Framework running multiple testcases using csv and for loop

纵然是瞬间 提交于 2019-12-11 03:17:44

问题


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.

  1. Read the entire file using OperatingSystem GetFile
  2. As there is a new testcase on every line, split file contents on newline using String keyword Split To Lines
  3. Use String keyword Split String to split line into testcase and inputs.
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!