How do you add tags to data-driven tests in Robot Framework?

I am trying to add tags to data-driven tests in Robot Framework. I have created keywords for the templatized tests and tables for the data similar to the following:

# Test case file
*** settings ***
Resource       libraries.txt
Test Template  My Test Template

*** test cases ***       parameter1   parameter2  ER
testa                    value1a      value2a     ERa
testb                    value1b      value2b     ERb

# Template file
*** Keywords ***
My Test Template
  [Arguments]  ${parameter1}  ${parameter2}  ${ER}
  ${result}=  Do Something  ${parameter1}  ${parameter2}
  Should Be Equal As Strings  ${result}  ${ER}

How can I add (possibly distinct) tags for testa and testb?


It turned out to be PEBKAC. I was not indenting the tag statement. Those double spaces did me in (again).

Answers


There are several ways to add a tag.

Only test specific is like:

*** Test cases ***
Test A
  [tags] tagA tagB
  Log  This is test A

It is possible to add a tag to all testcases in your file by placing a Force Tags in your settings:

*** Settings ***
Force Tags  NewTag

For more information you can check the user guide: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#tagging-test-cases


Tags can be added like this:

*** test cases ***       parameter1   parameter2  ER
testa                    value1a      value2a     ERa
    [Tags]    tag1
testb                    value1b      value2b     ERb
    [Tags]    tag1

One solution is to modify your keyword to take tags as arguments. Then you could do something like this:

*** Settings ***
| Test Template | My Test Template

*** test cases ***       
| testa | value1a  | value2a | ERa | tag1 | tag2
| testb | value1b  | value2b | ERb | tag2 | tag3

*** Keywords ***
| My Test Template
| | [Arguments] | ${value1} | ${value2} | ${er} | @{tags}
| | log | value1: ${value1}
| | log | value2: ${value2}
| | log | er: ${er}
| | Set tags | @{tags}

When run, testa will have the tags tag1 and tag2, and testb will have the tags tag2 and tag3


Need Your Help

How do I fetch all CloudKit Records created by the current user?

ios swift cloudkit ckquery ckrecord

Say I have a 'Species' Record Type that contains Public Records which were created by a number of Users. Currently, my query retrieves all records of 'Species':

WebStorm debug mode doesn't hit breakpoints

google-chrome webstorm

I have WebStorm successfully launching my app when I hit debug. It runs the app in chrome and Chrome tells me that that tab is in debug mode.