Tags 如何在数据驱动程序测试中为Robot框架设置标记?
我正试图根据文档添加标签 以下是我的例子:Tags 如何在数据驱动程序测试中为Robot框架设置标记?,tags,robotframework,data-driven-tests,Tags,Robotframework,Data Driven Tests,我正试图根据文档添加标签 以下是我的例子: *** Settings *** Test Template Template *** Test Cases *** ${first} ${second} [Tags] [Documentation] Test1 xxx 111 123 Test2 yyy 222 126 Test3 zzz
*** Settings ***
Test Template Template
*** Test Cases *** ${first} ${second} [Tags] [Documentation]
Test1 xxx 111 123
Test2 yyy 222 126
Test3 zzz 333 124
*** Keywords ***
Template
[Arguments] ${first} ${second}
Should be true ${TRUE}
但在这种情况下,我得到了一个错误:
Keyword 'Template' expected 2 arguments, got 3.
我也看到了这个解决方案:
但是在这种情况下,我不能使用-I test\u标签运行特定的测试
您还可以设置默认标记,如下所示:
*** Settings ***
Default Tags smoke
所有没有自己标记的测试用例都将接收定义为默认标记的标记
或者可以使用强制标记:
Force Tags req-882
文件中的所有测试用例都将收到这样的标记
然而,您的示例还包含另一个问题。将3个参数传递给模板关键字,测试用例表中有3列参数。应该是这样的:
*** Test Cases *** ${first} ${second}
Test1 xxx 111
Test2 yyy 222
Test3 zzz 333
因此,整个工作示例:
*** Settings ***
Default Tags smoke
Test Template Template
*** Test Cases *** ${first} ${second}
Test1 xxx 111
Test2 yyy 222
Test3 zzz 333
*** Keywords ***
Template
[Arguments] ${first} ${second}
Should be true ${TRUE}
当我运行$robot--包括烟雾测试.robot
时,我得到:
当我运行$robot--exclude smoke test.robot
时,我得到:
编辑:
如果要为每个测试用例设置标记,语法为:
*** Test Cases *** ${first} ${second}
Test1 xxx 111
[Tags] smoke
Test2 yyy 222
Test3 zzz 333
在这种情况下,当您发出$robot-i smoke test.robot
时,只执行Test1:
谢谢你的回答。但是我需要为每个测试添加不同的标签。好的,我更新了我的答案,所以它符合你的要求。