如何在Robot Framework中标记数据驱动的模板测试

时间:2018-02-05 20:44:34

标签: tags robotframework testrail

我有许多数据驱动测试,因此我可以使用多行数据运行相同的测试,这很有效。但是,我们还使用TestRail并通过RF测试中的标签将RF测试链接到TestRail。目前我只为每个模板标记一个TestRailID。例如:

*** Test Cases ***
Verify Registering For An Event with each CC Type
  [Template]  Register For An Event with a Credit Card
  [Tags]    TestRailID=1211  Smoke    
  ${cc_intl}   ${personInfo}  ${visaCardInfo}
  ${cc_intl}   ${personInfo}  ${masterCardInfo}
  ${cc_intl}   ${personInfo}  ${americanCardInfo}
  #etc

我希望每行数据都有一个TestRailID的唯一标记。如何在上面的示例中为每个数据行添加标记?

1 个答案:

答案 0 :(得分:4)

一个简单的解决方案是修改模板以接受标记作为参数之一,然后在关键字中调用set tags

示例:

*** Keywords ***
Register For An Event with a Credit Card
    [Arguments]  ${tag}  ${personInfo}  ${cardInfo}
    set tags  ${tag}
    log  personInfo: ${personInfo} cardInfo: ${cardInfo}

*** Test Cases ***
Verify Registering For An Event with each CC Type
  [Template]  Register For An Event with a Credit Card
  [Tags]    TestRailID=1211  Smoke    
  TestRailID=1  person one    visa
  TestRailID=2  person two    mastercard
  TestRailID=3  person three  american express