Resharper templates for Unit Tests

I am sharing here my resharper templates that I use. You should be able to easily import them.

The most useful one is the TestMethod template:

[sourcecode language=”css”]
public void MethodUnderTestScenarioExpectedBehaviour()
Assert.Fail("Not yet implemented");

It follows the unit test naming convention proposed by Roy Osherove in his book “The Art Of Unit Testing”. Naming your unit tests like this it helps you in writing good unit tests, because it foces you to keep your tests simple and test only one thing. If you cannot name the test method like this either you’re testing more than one thing, either your test is too complex, so you cannot name the test scenario. If you’re in the last case consider to refactor your production code.

Another great advantage I’ve found by following Roy’s convention is that I can easily know, just by looking at the test run report, where the bug is when a test fails. This way I reduce my debug time to almost zero for the code under unit tests and this gives me a higher efficiency.

Florin Coros

Read more posts by this author.