-
-
Notifications
You must be signed in to change notification settings - Fork 46
StepDefinition filter attributes #254
Comments
@ursenzler any thoughts on the base attribute name? |
Depends on what else is possible with this attribute. Maybe StepConfigurationAttribute? -> method Configure(steps) |
Thanks for the suggestions. 'configuration' may be appropriate. I'm not sure about 'definition' since the steps are already defined, the attribute just adds some extra mutation to them. I think 'tweak' doesn't really convey enough. I also thought about 'customize' but that doesn't really fit. There are no 'standard' steps so every step or list of steps is custom. I think the reason I initially proposed 'filter' was from the 'pipes and filters' pattern. I.e. in a pipe, a stream is passed into a filter and different stream comes out. I admit that the analogy to physical filters is very loose since a physical filter just removes some constituents from the stream, but it is a recognised term in software, e.g. http://en.wikipedia.org/wiki/Filter_(software) and http://www.eaipatterns.com/PipesAndFilters.html To fit that pattern properly, the type would look like this: public abstract class StepDefinitionFilterAttribute : Attribute
{
public abstract IEnumerable<IStepDefinition> Filter(IEnumerable<IStepDefinition> steps);
} Moreover, we could also have an I guess your custom attribute would look something like: private class ContinueOnFailureAfterIt : StepDefinitionFilterAttribute
{
public override IEnumerable<IStepDefinition> Filter(IEnumerable<IStepDefinition> steps)
{
var it = false;
return steps.Select(step =>
{
if (it ? it : it = step.Text.StartsWith("It "))
{
step.ContinueOnFailure = true;
}
return step;
});
}
} It might be possible to improve the API to provide a builder method on private class ContinueOnFailureAfterIt : StepDefinitionFilterAttribute
{
public override IEnumerable<IStepDefinition> Filter(IEnumerable<IStepDefinition> steps)
{
var it = false;
return steps.Select(step =>
step.ContinueOnFailure(it ? it : it = step.Text.StartsWith("It ")));
}
} I guess some further functional wizardry (using |
I like this idea. |
then it shall be done 😃 |
@ursenzler I came up with a slightly different way of doing it (I've updated the example in the description). The step builder method is now Your custom attribute does not have to inherit from any base attribute. All it has to do is implement The work is done, but not set in stone, so it would be great to hear your thoughts on this before I push out RC3. |
FWIW, RC3 is out - https://www.nuget.org/packages/Xbehave/2.0.0-rc003-build581 There's still time to change things if required. |
An extensibility point to allow the filtering of step definitions in a scenario before execution.
E.g. emulation of the undocumented 1.x
ContinueOnFailureAfterAttribute
:The text was updated successfully, but these errors were encountered: