Search code examples
tagsrobotframework

Why excluding tag with a variable doesn't work in robot framework?


I am trying to exclude specific test cases using tags with a variable. I have added an Initialization init.robot

*** Settings ***
Suite Setup       INIT
Test Setup

*** Keywords ***
INIT
    Set Global Variable    ${hw_version}    v1

And test cases

*** Test Cases ***
excludetest
    [Tags]    ${hw_version}
    [Setup]
    Log    test passed

includetest
    No Operation

Despite the excluding of v1 tag with the command : robot -e v1 -s Test-tag . all tests are executed.


Solution

  • It is because the choice to include or exclude tests happen before the first test is run. Before the test is run, the tag is not set on the test and thus can't be used to include or exclude the test.