Closed UL-ChrisGlew closed 1 month ago
Hm... the referred code is just for the "default" expression style. I think that is OK, the question is why isn't it overridden.
@clrudolphi can hopefully find the root cause.
@gasparnagy I could use some guidance on how to proceed. As best I can understand, the ReqnrollConfigDeserializer ignores the setting. It is interested in the feature language and binding Culture settings. I can't find the code (in the VisualStudio project) that reads from the trace section of the config file. The ReqnrollProjectSettingsProvider class appears to always set the CucumberExpression trait of the ReqnrollProjectTraits enum. I can't find anywhere in the code where the trace section would override that to turn that flag off.
Oddly enough, when I attempt to recreate this through the Tests/Specs, the opposite occurs. I can get Regex to work but not Cucumber. Is that because the stubs don't support that? Please review the tests I've written on my own branch at: RnRVS_GH18 TIA
@clrudolphi I did check 😆 It is not using the config, because it is not implemented in the VS extension.... 😀
Background: In SpecFlow those who had the special cucumber expression plugin wanted cucumber expression snippets anyway. And in case of the cucumber expression plugin we were setting the special trait, so the "default" snippet calculation was "good enough" and no one missed the config. But now the trait is always set for Reqnroll, so the config is getting important again. We need to implement that.
In the Tests/Specs maybe the cuke ex trait is not set on the stubbed project and this is why you get a different default as usual. It would be good to change the stub to have the cuke ex trait by default. This can be done in StubProjectSettingsProvider
at this line. This will break one of the existing scenarios, but the scenario text can be modified accordingly. Your scenarios are good, I would only keep the second one.
The implementation might be something like:
DeveroomConfiguration
class for the snippet style (type SnippetExpressionStyle
).ReqnrollConfigDeserializer
. You need to add one more untyped property (Dictionary<string, string> Trace
) to ReqnrollJsonConfiguration
for that.SnippetService.DefaultExpressionStyle
and rework them somehow that they should give a precedence to the configured value. You can always get the configuration from a project scope with projectScope.GetDeveroomConfiguration()
.@gasparnagy : Thanks for the pointers. Almost done. One discrepancy has crept up. The Documentation for Reqnroll here indicates that the relevant Trace setting is called stepDefinitionSnippetStyle.
stepDefinitionSnippetStyle | CucumberExpressionAttribute / RegexAttribute | Specifies the default step definition style.Default: CucumberExpressionAttribute
The schema for the Reqnroll.json file however, says that the element should be "stepDefinitionSkeletonStyle" "$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json"
Which is correct? For now, I'm implementing this as if the schema is correct and the docs are wrong.
Unfortunately the "skeleton" one is the correct. https://github.com/reqnroll/Reqnroll/blob/main/Reqnroll/Configuration/JsonConfig/TraceElement.cs#L25
(The "snippet" is the cucumber compatible term and "skeleton" was a term I introduced 15 years ago, but I can't get rid of that, it seems.)
Would you like the Documentation page updated to have it match the schema?
Latest code is now at this branch: https://github.com/clrudolphi/Reqnroll.VisualStudio/tree/GH18
Since it uses the 'skeleton' term, I'll create a PR.
Fixed by #19
Used Visual Studio
Visual Studio 2022
Are the latest Visual Studio updates installed?
Yes
Content of reqnroll.json (if present)
{ "trace": { "stepDefinitionSkeletonStyle": "RegexAttribute" } }
Issue Description
It appears that the VS2022 Extension does not currently change behavior when setting the 'stepDefinitionSkeletonStyle' to 'RegexAttribute'.
The expected behavior is that the 'Define Steps' button should show Regex-based step definitions, but will always seem to show Cucumber expressions.
I have had a dig into the codebase, with @timothy-plummer-ul and it seems like the main culprit is the following line:
When using Reqnroll, the flag for 'ReqnrollProjectTraits.CucumberExpression' is always set here, and does not appear to check the config file for it's value inside the 'ReqnrollProjectSettingsProvider' class:
I have experimented with reading from the config file, which seemed to enable the expected behavior of the config point, so it seems like this is a bug in the extension.
Steps to Reproduce
{ "trace": { "stepDefinitionSkeletonStyle": "RegexAttribute" }}
Link to a project repository that reproduces the issue
No response