8000 Allow removing tags using `-tag` syntax also in `Test Tags` · Issue #5250 · robotframework/robotframework · GitHub
[go: up one dir, main page]

Skip to content

Allow removing tags using -tag syntax also in Test Tags #5250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
romanliv opened this issue Oct 30, 2024 · 1 comment
Open

Allow removing tags using -tag syntax also in Test Tags #5250

romanliv opened this issue Oct 30, 2024 · 1 comment

Comments

@romanliv
Copy link
romanliv commented Oct 30, 2024

Test Tags from *** Settings *** and [Tags] from Test Case behave differently when removing tags: while it is possible to remove tags with Test Case's [Tag] -something, Settings Test Tags -something introduces a new tag -something.
Running tests with these robot files (also attached):

  • __init__.robot:
    *** Settings ***
    Test Tags    something
    
  • -SomethingInSettings.robot:
    *** Settings ***
    Test Tags         -something
    
    
    *** Test Cases ***
    -Something In Settings
        Should Be Empty    ${TEST TAGS}
    
  • -SomethingInTestCase.robot:
    *** Test Cases ***
    -Something In Test Case
        [Tags]    -something
        Should Be Empty    ${TEST TAGS}
    

gives the following output:

> robot .
==============================================================================
TagsTest
==============================================================================
TagsTest.-SomethingInSettings
==============================================================================
-Something In Settings                                                | FAIL |
'['-something', 'something']' should be empty.
------------------------------------------------------------------------------
TagsTest.-SomethingInSettings                                         | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
TagsTest.-SomethingInTestCase
==============================================================================
-Something In Test Case                                               | PASS |
------------------------------------------------------------------------------
TagsTest.-SomethingInTestCase                                         | PASS |
1 test, 1 passed, 0 failed
==============================================================================
TagsTest                                                              | FAIL |
2 tests, 1 passed, 1 failed
==============================================================================

(https://forum.robotframework.org/t/removing-tags-from-the-test-tags-setting/7513/6?u=romanliv confirms this as an issue to be fixed)

@pekkaklarck
Copy link
Member
pekkaklarck commented Nov 1, 2024

The current behavior is actually be design. When the -tag syntax was introduced in RF 7.0 (#4374), it was specifically designed to work only with [Tags]. The main motivation was making the change as little backwards incompatible as possible, by not changing how tags set using Test Tags work. I also believe it didn't occur to us that someone would like to remove tags set in initialization files using this syntax.

Now that I think about this again, I believe the use case to remove tags set in initialization files is pretty important. I also agree that the current behavior that -tag works with [Tags] but not with Test Tags is inconsistent. I think it makes sense to change this, but due to the aforementioned backwards compatibility concerns, the change needs to wait for a major release and we should also deprecate using -tag syntax as a literal tag name in Test Tags first. I thus propose the following:

  1. We deprecate using -tag in Test Tags in RF 7.2. We similarly deprecated using -tag with [Tags] in RF 6.0 (Deprecate setting tags starting with a hyphen like -tag using the [Tags] setting #4380).
  2. Actually implement this behavior in RF 8.0.

Let's use this issue for actually making the change. I'll update the title accordingly and assign this to RF 8.0 scope. I'll also submit a separate issue about deprecation and assign it to RF 7.2.

@pekkaklarck pekkaklarck added this to the v8.0 milestone Nov 1, 2024
@pekkaklarck pekkaklarck changed the title Inconsistent behavior with Test Tags from Settings and [Tags] from Test Case Allow removing tags using -tag syntax also in Test Tags Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0