Skip to content
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

Hooks for Scenario Outlines don't work #210

Closed
gisode opened this issue Feb 17, 2012 · 3 comments
Closed

Hooks for Scenario Outlines don't work #210

gisode opened this issue Feb 17, 2012 · 3 comments

Comments

@gisode
Copy link
Contributor

gisode commented Feb 17, 2012

Given a Scenario Outline with some Examples.
And a @before hook matching the tag @tag

Given I add @tag to the Scenario Outline like so:

@tag 
Scenario Outline: Foo
    ...

    Examples:
        ...

When I run it
Then the before-hook is NOT executed.

After digging in the code I found that it should work when @tag is added like so:

Scenario Outline: Foo
    ...

    @tag 
    Examples:
        ...

But it doesn't either and here is why:

When the FeatureBuilder.examples() method is given the Gherkin Examples object containing the correctly parsed tag, it simply passes the reference to it into the current CucumberScenarioOutline which builds a new CucumberExamples instance that in turn simply stores the reference.

Later in CucumberExamples.createExampleScenarios() the tags are taken from the same Gherkin Examples instance whose reference was stored earlier and put into the newly created scenario for the current example. At that point, however, the List within the Gherkin Examples object containing the tags is empty, because that List is cleared in gherkin.formatter.FilterFormatter.replay() (examplesTags.clear(); currently at line 189).

The bug here is that Gherkin passes an object into the Formatter implementation - the FeatureBuilder - even though it is going to modify it later. Or that FeatureBuilder isn't prudent enough to make a copy of all objects that it is given.

I can't see how this can be fixed easily. For the project I use this in I guess I'll have FeatureBuilder make a copy of the Examples object, which is an ugly hack, oh well.

As an aside, I find it confusing that the tags must be added to the Examples section. I had expected that the example scenarios created at runtime would inherit all the tags from the Scenario Outline.

@gisode
Copy link
Contributor Author

gisode commented Feb 17, 2012

Whoops, seems this is a duplicate of #209. Didn't see that one until now. Sorry.

@aslakhellesoy
Copy link
Contributor

Np - closing this. Your comments are valuable in fixing #209 anyway!

@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

2 participants