Should v3 still support user's attributes derived from StepDefinitionBaseAttribute? #833
-
We often need to use the same step from a Given and a When line in a featue file. I use below public class GivenWhenAttribute : StepDefinitionBaseAttribute
{
readonly static StepDefinitionType[] types = new[] { StepDefinitionType.Given, StepDefinitionType.When };
public GivenWhen() : this(null) { }
public GivenWhen(string regex) : base(regex, types ) { }
}
[GivenWhen("I do something")]
public async Task Do() { ... } |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
This should work IMO. Please post all the stacktrace and full error message. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I agree with @304NotModified , this should work. @adrichem which specific version of Reqnroll 2.x, version of .NET/Framework, and which test framework (and version) are you using? |
Beta Was this translation helpful? Give feedback.
-
Had a bit of a play around with this today - the issue seems to stem from the name of the input parameter for the
to:
everything seems to work okay. TL;DR - replace the |
Beta Was this translation helpful? Give feedback.
Thx for the detail analysis @UL-ChrisGlew and @clrudolphi.
As this being a special case, I would suggest extending the documentation (where?) for now and declaring that if anyone creates derived attributes, they should use the same parameter names as the base class. (It is very unlikely that we will rename them again.)
@adrichem Is it a feasible workaround for you to fix the constructor parameter names accordingly?