Skip to content

Tags at the examples block are not treated as actual tags in scenario #849

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

Closed
williamlabrum opened this issue Apr 9, 2015 · 17 comments
Closed

Comments

@williamlabrum
Copy link

It seems as though tags specified at an examples block are not treated as such when being assigned to a scenario:

Scenario Outline: Test Stuff
  Given foo
  When bar
  Then fizz

@myTag
Examples:
  | col a |
  | data  |
    public void before(Scenario scenario){
        for(String tag : scenario.getSourceTagNames()){
            System.out.print("Tag: " + tag);
        }
    }

This ultimately prevents us from creating Hooks based on tagged Example blocks. Perhaps there is an alternative?

@aslakhellesoy
Copy link
Contributor

Sounds like a bug

@brasmusson
Copy link
Contributor

@williamlabrum Which version of Cucumber-JVM are you using? I cannot reproduce this problem in Cucumber-JVM v1.2.2. There both hooks tagged with the Examples table tag are executed for the scenarios instantiated from the Example table, and scenario.getSourceTagName() in a before hook will include the Examples table tag in the return value.

@williamlabrum
Copy link
Author

@brasmusson Yes, I am using v1.2.2. Another thing that is worth noting is that I am using java 1.6 (not by choice).

Please feel free to clone the cucumber-debugging project here: https://github.com/williamlabrum/cucumber-debugging to see an example setup.

Execution: mvn clean test -Dcucumber.options="--tags @mytag"

Here is the output seen by me (no indication of output tag data provided by the BeforeStepDefs class):
image

Also, since updating to v1.2.2, I now see a bunch of that blue text when using Scenario Outlines. Whats with that? Makes me feel like I'm skipping scenarios/steps when looking at the output (even though I'm not).

@williamlabrum
Copy link
Author

I have created a second test that shows that it works when placing the tag at the Scenario Outline level but not at the example block level.

Execution: mvn clean test

image

@brasmusson
Copy link
Contributor

Ok, @williamlabrum its a bug. But it is not as easy as that the tags on examples tables are totally ignored, they are lost when performing tag filtering.

If you remove tags = { "~@in-progress", "~@skip"} for the @CucumberOption annotation of your runner class, you will see that the @myTag tag will exist on the scenario from the examples table in question. If you change the tag value to tags = { "@myTag"} in the @CucumberOption you will see that the scenario from the examples table in question will be executed, so when filtering on the tags it will be selected, but then when it is executed, the scenario will no longer have the @myTag tag.

I have not tracked down where the bug is located, but as it is related to tag filtering, the possibility is that it is located in the gherkin library, and in that case the bug is likely to remain until the current gherkin library (gherkin2) is replaced by the gherkin3 library (since no new releases of gherkin2 is planned).

@williamlabrum
Copy link
Author

Got it. Thanks for your feedback and support.

@aoatley
Copy link

aoatley commented Aug 11, 2015

Has this bug been looked at? This still seems to be an issue?

@dkowis
Copy link
Member

dkowis commented Aug 12, 2015

Is there a test for it against gherkin3?

@aoatley
Copy link

aoatley commented Aug 12, 2015

info.cukes gherkin3 3.0.0

I am using gherkin3 and am still unable to get the example tags using either a before hook:
@before
public static void scenarioHook(Scenario sc)
{
System.out.println("Tags: " + sc.getSourceTagNames());
}
This prints just the Scenario Outline's tag
Or in my cucumber formatter class
@OverRide
public void examples(Examples examples)
{
for(Tag tag : examples.getTags())
{
tags.add(tag.getName());
}
super.examples(examples);
}
This returns empty

@aslakhellesoy
Copy link
Contributor

Cucumber-JVM doesn't use Gherkin3 yet, so adding it to the classpath has no effect

@aoatley
Copy link

aoatley commented Aug 12, 2015

Ok, I thought that might be the case...

Is there an estimate on when Gherkin3 would be added to Cucumber-JVM?

@aslakhellesoy
Copy link
Contributor

I don't do estimates. It will be ready when it's ready.

@sukeshjain
Copy link

Method examples of FilterFormatter class in Gherkin2 project has been changed to fix this problem. However, new version of Gherkin2 is not released. Can we have a new version of Gherkin2 to solve this issue?

@greenhammock
Copy link

Hello, I think I encountered the same bug, but the behavior that caught my attention is slightly different. I noticed that tags attached to 'Examples' section in 'Scenario Outline' do not appear in the JSON report. I hope the fix you are talking about in this issue will also result in correct JSON output.

@brasmusson
Copy link
Contributor

AFAIK, fixing this before v2.0 would mean to make changes to code that will be thrown away by #1035 (use Gherkin4) or it might even require a new release for Gherkin2, so I would prefer to not try to fix this before v2.0.

@brasmusson
Copy link
Contributor

Now when #1035 has been merged, the 2.0.0-SNAPSHOT version from the master branch (with the groupId io.cucumber), treats tags on the example blocks correctly.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants