How to Tell ReSharper Underscores Are OK For Tests
Here’s the scenario – you use ReSharper and you want to use BDD style naming in your tests. You know; that style with all those underscores in the test names so that your really long test names are actually readable. The problem is, ReSharper get’s all upset at you when you do this and throws warnings in your face something like this:
Now you could always turn that rule off, but that would mean losing the benefit of picking up bad names in the rest of your code which is not ideal. What you really want is the best of both worlds (cue Hannah Montana intro music – gah! I blame my 10 year old for that. Sorry).
Anyway, here’s how to configure ReSharper to allow underscores:
Go to ReSharper->Options->Naming Style. Highlight the Method naming rule and click Edit.
Click the Add button and add in a new rule for First_upper as shown here:
Now go back and look at your source… It be blue squiggle free. Yay!
By the way, if you want to have use naming such as Upper_Case_And_Underscores then you’re out of luck as far as I can tell, since there’s no options I can see to add a new name style to R#.