Another reason why Resharper is such a godsend, and why no developer’s desktop should be without it. Live Templates…
A major frustration with doing TDD is the repetitive nature of the code.
[Test]
public void SomeTest()
{
}
or
using NUnit.Framework;
namespace SomeNamespace
{
[TestFixture]
public class SomeFixture
{
[Test]
public void SomeTest()
{
}
}
}
How many times during the day do you type this? If you’re doing TDD, Im going to guess that it is quite a bit.. How much better would it be if you could type ‘test’ and hit TAB. Once you hit Tab, the method name is highlighted and you type the method name. After the method name is complete, hit TAB again and you’re in the body. Ahhhh… TDD nirvana. :)
I’ve attached my live templates for resharper that do exactly this. Type in test
to get the simple unit test, or type tf
and TAB to get the test fixture.
Update: These live templates are now available on github.
Once you’ve downloaded them, you should be able to import them into Resharper using the Resharper options dialog and be on your way to TDD bliss. Enjoy!