I am trying to add a tag in accordance with the documentation https://github.com/Snooz82/robotframework-datadriver
Here is my example:
*** 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}
But in this case, I got the error:
Keyword 'Template' expected 2 arguments, got 3.
I also saw this solution: How to Tag Data Driven Template Tests in Robot Framework
But in this case, I can not run a particular test by using -i test_tag
Welcome.
You can also set default tags like so:
*** Settings ***
Default Tags smoke
All test cases that do not have their own tags will receive tags defined as default tags.
Or you can use forced tags:
Force Tags req-882
All test cases in a file will receive such tags.
However, your example contains yet another problem. You're passing 3 arguments to your Template keyword, you have 3 columns of arguments in your test case table. It should be like this:
*** Test Cases *** ${first} ${second}
Test1 xxx 111
Test2 yyy 222
Test3 zzz 333
So the whole working example:
*** 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}
when I run $ robot --include smoke test.robot
, I get:
and when I run $ robot --exclude smoke test.robot
, I get:
EDIT:
If you want to set tags per test case, the syntax is:
*** Test Cases *** ${first} ${second}
Test1 xxx 111
[Tags] smoke
Test2 yyy 222
Test3 zzz 333
in which case, only Test1 will be executed when you issue $ robot -i smoke test.robot
: