如何在数据驱动程序测试中为Robot Framework设置标签?

问题描述 投票:0回答:1

我正在尝试根据文档添加标签https://github.com/Snooz82/robotframework-datadriver

这是我的示例:

*** 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.

我也看到了此解决方案:How to Tag Data Driven Template Tests in Robot Framework

但是在这种情况下,我无法使用-i test_tag运行特定的测试

tags robotframework data-driven-tests
1个回答
0
投票

欢迎。

您还可以像这样设置默认标签:

*** Settings ***
Default Tags    smoke

没有标签的所有测试用例都会收到定义为默认标签的标签。

或者您可以使用强制标记:

Force Tags      req-882

文件中的所有测试用例都将收到此类标记。

但是,您的示例还有另一个问题。您将3个参数传递给Template关键字,测试用例表中有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 --include smoke test.robot时,我得到:

enter image description here

当我运行$ robot --exclude smoke test.robot时,我得到:

enter image description here

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.