Robot Framework 使用 csv 和 for 循环运行多个测试用例 [英] Robot Framework running multiple testcases using csv and for loop

查看:140
本文介绍了Robot Framework 使用 csv 和 for 循环运行多个测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 csv 文件,其中包含 TestcaseID、Testcase Description、Tag 和测试用例的输入,如下所示

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

我想遍历这个文件并获取每一行并使用一个通用函数启动一个测试用例(这将是 TestcaseID).经过研究,我发现这个功能在Robot Framework中没有实现.

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.

推荐答案

这里是您可以这样做的方法,下面是更好的方法.

Here's how you COULD do this, below this is are better ways to do it.

  1. 使用操作系统读取整个文件 GetFile
  2. 由于每一行都有一个新的测试用例,因此使用 String 关键字在换行符上拆分文件内容 分行
  3. 使用字符串关键字拆分字符串 将行拆分为测试用例和输入.
  4. 使用操作系统 运行 在 for 循环中执行每个测试.

您应该使用资源和变量文件来定义每个测试用例的输入,然后以文件作为输入执行整个测试套件(或指定的测试用例).这基本上可以免费为您完成所有这些工作.

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.

这篇关于Robot Framework 使用 csv 和 for 循环运行多个测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆