Search code examples
tagsrobotframeworktestrail

How to Tag Data Driven Template Tests in Robot Framework


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?


Solution

  • 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