25 Juli 2010

How to change the ReSharper naming style for test methods

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:

public void MethodUnderTest_Scenario_ExpectedResult()

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 settingsimage
image
In “Affected entities” mark “Test method (property)” and disable inspections.image

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.

05 Juli 2010

Don’t use keyword substitution if you use branches

Many version control systems use some kind of keyword substitution, e.g. in Subversion the keyword $Author:$ gets replaced on every commit through the committing author, say $Author: crodemeyer$. Now imagine that you have several branches of your trunk and that each branch is modified in parallel. When the time comes to merge back the changes to the trunk you will get many conflicts. They cannot be resolved automatically because in every branch the same line of code has been changed. Indeed you have entirely broken  automatic reintegration of branches if you use keyword replacement.

Fortunately Subversion has the possibility to control keyword substitution with the svn:keywords property. Be a hero and use “svn pd svn:keywords –R” to disable keyword substitution completely.