ttutisani/Xunit.Gherkin.Quick

is there a way to go to step definition directly from feature file?

dimonze opened this issue · 7 comments

is there a way to go to step definition directly from feature file?
Like by pressing F12

No, there is no such way by using Xunit.Gherkin.Quick alone. F12 or something of that sort would require IDE integration via extension or something of that sort.

I will keep this issue open to see if somebody has a suggestion on how to do that.

Thank you for super fast answer, looking forward for any suggestions

I've been looking at issues around this, I've been trying to create some Rosyln Analysers for things like feature files missing/not matching the FeatureFile attribute, to give us red squiggles in the code. The issue is that the content files are not included in the roslyn syntax tree so I can't load them to do the checks.

My thought at the moment is that we could somehow cause a parsed set of feature files to be added to Roslyn's syntax tree at compile time, which we could then access through an Analyser. I'm not sure this is even possible yet, but if I can close that loop then it'll be a simple to add warnings/code fixes when a feature file doesn't match the implementing c# - you'd see warnings in your build result.

I know even this doesn't add the click-through from the feature file itself (I don't think that will be possible without adding a full extension) but it would definitely tighten up that link between text and code.

This is the creating Analyzer stuff from M$ I've been referring to. So far the only useful one I've created shows a warning if a concrete Feature class doesn't have a FeatureFile attribute but I'm sure we can do better :)
https://devblogs.microsoft.com/dotnet/how-to-write-a-roslyn-analyzer/

Related to the last response from @csurfleet:
Also note that there is now a way to handle not-implemented features, which can result in warnings or errors if you add @ignore tags: https://github.com/ttutisani/Xunit.Gherkin.Quick/blob/master/docs/handle-not-implemented-feature-files.md

This way, the test results can show you what is missing implementation.

Using the cucumberautocomplete extension (https://github.com/alexkrechik/VSCucumberAutoComplete) in VS Code actually allows you to goto definition. That extension scans text/source files (not assemblies) for patterns like "Given(...)" and assumes that defines steps with the text "..." in them. Once it has matched a step in the feature file it relates it to the line of the step-definition file (C# code) and allows you to jump to that definition.

The extension itself knows nothing about implementation languages - it simply scans source files for Gherkin-like patterns (with all the issues such an over simplification implies).