For normal methods I use the Pascal casing convention (or UperCamelCase as it is called by ReSharper). But in unit tests readability rules and therefore I use very long names like:
ReSharper marks them as violating the naming style, which is quite annoying because this distracts from real problems. Luckily there is a way to tell ReSharper to use a different naming convention for test methods. It is a little bit hidden in the ReSharper options, but here is the way to go:
ReSharper Options –> Naming Style –> Advanced settings
In “Affected entities” mark “Test method (property)” and disable inspections.
Now you have no warnings in your tests anymore that complain of inconsistent naming styles. Naming styles for non test classes and methods are still working as before. This was tested with ReSharper 5.1.
Hi Christian!
ReplyDeleteFunny that I came across your blog while trying to solve exactly this problem :-) Thanks for the (obvious) solution.
Say hi to everybody from me!
Greetings from Dublin,
Raphael
Thanks for the post, it's quite helpful.
ReplyDeleteDo you have a suggestion about what to do about the names of methods for event handlers that Visual Studio generates when you hit tab after typing += when you want to subscribe to an event?
e.g: Button1_Clicked
??
Thanks!
@wtheronjones
ReplyDeleteReSharper has settings for those, in the same "Advanced settings" window that is mentioned in this post.
See:
http://imagebin.org/131988
Thanks for saving my brain from further unnecessary expenditure of effort by relieving it from the task of compensating for this annoyance.
ReplyDeleteThanks, this worked fine for me as well - even on ReSharper 6.0.
ReplyDeleteWell, it worked, then it stopped working, then I deleted the ReSharper.user file, then it worked again.
/Brian
Instead of disable inspections for your test classes and methods, you can also add for them aditional naming styles, e.g. "all_lower", or "First_upper" - top rights in your last screenshot
ReplyDeleteThanks very much for this. All those wavy blue lines in my test classes were driving me nuts!
ReplyDeleteAwesome!
ReplyDeleteSomething to note is that the 'Access rights' in the new rule have to include Private if your test classes or methods are private.
ReplyDeleteBeautiful! Thanks... +1
ReplyDeleteGreat write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. shoes brand names
ReplyDeleteWow, this is fascinating reading. I am glad I found this and got to read it. Great job on this content. I liked it a lot. Thanks for the great and unique info. unique business names
ReplyDeletePretty good post. I have just stumbled upon your blog and enjoyed reading your blog posts very much. I am looking for new posts to get more precious info. Big thanks for the useful info. creative brand names
ReplyDelete