Question

I just upgraded to Resharper 4.5 and now see that all my BDDish test methods are marked as not conforming to the naming standard. My naming convention is like this:

public void Something_ShouldHaveThisResult()

Resharper doesn't like the underscore in the method. Is there a way to turn this off, just for test methods? I have a normal naming convention for the rest of my code.

Was it helpful?

Solution

On the menu:

Resharper | Options -> Languages -> Common -> Naming Style: remove what ever naming style you want. They should have a "disable" feature, but they don't.

OTHER TIPS

If you want to follow the Microsoft style guide with your non-test code sources - Have you tried using the StyleCop for ReSharper plugin?

As recommended before: disable the internal ReSharper naming rule set or toggle the inspection settings. StyleCop (thus the StyleCop ReSharper plugin) allows inheritance over the Settings.StyleCop files in your solution folder structure. So you are able to check for valid names in the "real" sources, while the analysis of the test code is disabled.

You could use

// ReSharper disable InconsistentNaming

// ReSharper restore InconsistentNaming

around the extremities of each class. e.g

// ReSharper disable InconsistentNaming
namespace bob
{
    [TestClass]
    public class MyTestClass
    {
        [TestMethod] 
        public void Test_Test()
        {
        }
    }
}
// ReSharper restore InconsistentNaming

This however will remove all naming warnings, and not just those on the Method name(s).

I've already added a request for this in the ReSharper bug-tracker. You can vote for it.

Resharper 4.5.1 has added this capability. You can now add a new custom naming rule that applies specifically to a test method, and allow it to contain underscores.

You can use Agent Smith for more precise code naming conventions.

Note: the version for the final R# 4.5 seems not to be compiled yet... but I'm sure it will be there soon.

There is no need to remove rules. New Rule can be added that accept underscores

Resharper | Options -> Languages -> Common -> Naming Style and add new rule to the bottom "User defined naming rules"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top