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
StepArgumentTransformation stack overflow exception #2561
Comments
As the step argument transformation is limited to numbers, I changed the parameter type to int and it is working: [StepArgumentTransformation(@"(\d+)")]
public string Transform(int val)
{
Console.WriteLine($"Transform: {val}");
return val.ToString();
} |
@gasparnagy Is this a bug? |
@SabotageAndi @jrod567 The
|
Thanks @gasparnagy for clarifying. |
Hi Andreas and Gaspar - Thank you for the feedback! For our needs, we were looking at using this to convert string based dynamic info (i.e. dates, unique placeholders, etc.) back into another string so string->string transformation would be a nice feature for our team. Maybe something to put in the backlog? That said, string to string transformation appears to work without using the StepArgumentTransformation filter. Do you see issues using it in this capacity? Wasn't sure if there were any gotchas in doing so that aren't immediately evident. |
@jrod567 I did a bit more investigation and found, that indeed, we have improved the conversion logic for
I checked the code. The conversion is done by the The step argument transformations are handled reclusively by design. I.e. if you have a conversion from Because of this reclusive nature, the As you can see the code, the If you have any suggestion, feel free to provide it in a pull request. You can also submit it as a feature request, but knowing the capacity of the team and the specific nature of the issue, I don't think that it will get much attention, unless you can work on it (it is open-source!). |
Yeah, I also don't see a possibility to put this on the backlog of the team in the future. Especially as there is a workaround. |
Thanks again for looking into this! I see what you mean now. That said, the workaround above was similar to what I was considering as well so it sounds like we'd be fine going that route. |
SpecFlow Version
VS2022
Which test runner are you using?
NUnit
Test Runner Version Number
3.13.2
.NET Implementation
.NET 5.0
Project Format of the SpecFlow project
Classic project format using
<PackageReference>
tags.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation NuGet package
Test Execution Method
Visual Studio Test Explorer
SpecFlow Section in app.config or content of specflow.json
No response
Issue Description
StepArgumentTransformation throws stack overflow exception whenever one tries to filter parameter data. Further details provided on SpecFlow forum here:
https://support.specflow.org/hc/en-us/community/posts/4423434386577-StepArgumentTransformation-stack-overflow-exception?page=1#community_comment_4436919840401
Exception:
Steps to Reproduce
Apply StepArgumentTransformation binding and apply a regular expression such as:
When this goes to run a stack overflow will be thrown; remove the filter regular expression and it works fine and iterates through all parameter data such as:
Standard Output:
Given I have a value 'abc'
Transform: abc
Given: abc
-> done: StepArgExStepDefinitions.GivenIHaveAValue("abc") (0.0s)
When I have another value 'xyz'
Transform: xyz
When: xyz
-> done: StepArgExStepDefinitions.WhenIHaveAnotherValue("xyz") (0.0s)
Then I have something else '123'
Transform: 123
Then: 123
-> done: StepArgExStepDefinitions.ThenIHaveSomethingElse("123") (0.0s)
Link to Repro Project
No response
The text was updated successfully, but these errors were encountered: