How to Tag Data Driven Template Tests in Robot Framework

 ̄綄美尐妖づ 提交于 2021-01-28 00:10:39

问题


I have numerous data driven tests so that I can run the same test with multiple rows of data, which works well. However, we also use TestRail and link RF tests to TestRail via a Tag on the RF test. Currently I'm only tagging one TestRailID per template. Eg:

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

I would like each row of data to have a unique tag for the TestRailID. How can I add a tag for each data row in the above example?


回答1:


One simple solution would be to modify your template to accept a tag as one of the arguments, then call set tags within your keyword.

Example:

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


来源:https://stackoverflow.com/questions/48631160/how-to-tag-data-driven-template-tests-in-robot-framework

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