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

Expose the optional Background element as a property #422

Closed
wants to merge 1 commit into from
Closed

Expose the optional Background element as a property #422

wants to merge 1 commit into from

Conversation

kzu
Copy link

@kzu kzu commented Jun 27, 2018

This makes it far more discoverable.

Fixes #421

This makes it far more discoverable. 

Fixes #421
@aslakhellesoy
Copy link
Contributor

aslakhellesoy commented Jun 27, 2018

This will be obsolete when Gherkin.NET is updated for #416, so i don’t think we should add this now.

Why do you want to expose it?

@kzu
Copy link
Author

kzu commented Jun 28, 2018

@aslakhellesoy it just makes the API more discoverable. The Children thing isn't, and doing Of<ScenarioDefinition> and Of<Background> for something that are the two core use cases for the Feature type itself, doesn't make a lot of sense. I'd expect to "dot into" properties to discover what's there, and having a 1..1 mapping between the few concepts Gherkin provides to top-level properties in the object model, would make the API easier to use.

When processing the gherkin file via the object model, you need to aggregate steps from the background to each of the scenarios, so you'd typically iterate scenarios, and prepend the steps from background, so it would make sense to make both first-class properties on Feature.

@aslakhellesoy
Copy link
Contributor

Can you tell us a bit more about what sort of software you're building that needs to use this? I might be able to suggest an alternative way to solve the problem you're trying to solve.

On a different note, with #416 we're switching to protocol buffers to represent the AST as well as pickles. Take a look at messages.proto.

The generated classes will let you write code like this in Java (and, I expect, similarly in C#):

https://github.com/cucumber/cucumber/blob/7f826f0a719231066b20b5917c6c783c5ca6de3c/gherkin/java/src/main/java/gherkin/pickles/PickleCompiler.java#L51-L64

@aslakhellesoy
Copy link
Contributor

I think I found it: https://github.com/kzu/Gherkinator

So, when we move to protobuf, you'll have a slightly different AST API, which I hope will give you what you need.

Have you considered using Gherkin's Pickle compiler to process the AST? It takes care of traversal of the AST, inlinging background steps and expanding Scenario Outlines. And the final Pickle model is easier to deal with. It's what Cucumber uses.

@kzu
Copy link
Author

kzu commented Jul 13, 2018

If there's no .NET "binding" for it, it's a no-go for my little thingy :(. Didn't find any candidate nugets: https://www.nuget.org/packages?q=Pickle

@lock
Copy link

lock bot commented Jul 13, 2019

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 Jul 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Background not exposed in the C#/dotnet Feature type
2 participants