SpecFlow method names and R# 8


I've made a naming rule that basically targets my test methods and relax R# so it will not warn me about them and it works pretty nice with xUnit but unfortunately it doesn't work with SpecFlow, what can I do?

Here is one of the methods.

public void Given_I_provided_a_valid_email()

Comment actions Permalink

This isn't supported out of the box. Test methods and test classes are methods for naming and classes that have been identified as tests or containers for tests, either by built in support (e.g. nunit, mstest), or via plugins (e.g. xunit, mspec). Since there isn't a specflow plugin, it won't pick them up. But you can write a plugin that will add support - you can write a plugin that includes a class that has one or more public static fields that can identifier new entities that will be added to the naming settings dialog. Your entities can look at an element in the source tree (e.g. class or method declaration) and see if matches what you're looking for - e.g. a method with either a [Given], [When] or [Then] attribute applied (the user will supply access rights and "static-ness" in the rule declaration). If it matches, ReSharper will apply that rule.

You can see an example of this kind of extension in the mspec test runner - https://github.com/machine/machine.specifications/blob/master/Source/Runners/Machine.Specifications.ReSharperRunner.6.1/MSpecElementNaming.cs

Comment actions Permalink

Yes, I know that but thank you, I guess I'll do that. ;)


Please sign in to leave a comment.