CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Brendan Tompkins [MVP]

Blog First. Ask Questions Later.

ReSharper as a TDD Tool

One of the things I've been thinking is awkward in the Test Driven Development process was the step where you write a test that for a method that doesn't yet exist.   If you follow the TDD process as laid out by James Newkirk, you're supposed to write your test case, code as if the method exists, then compile.  Of course your code won't compile, since you haven't yet implemented the method.  This is your “GO“ ticket for actually implementing the method.

This just seems broken, mainly because I  have to use my compiler, not NUnit as a part of my TDD process. Compiling is slow, especially compared with running a test. And compiling when I know it's going to break seems like a waste of time.   TDD has reduced the number of times I have to compile in a day, and I want to keep it that way.

But, if you've used ReSharper, it offers a great feature that eliminates this compile step.  This is really cool, and it actually makes TDD much easier.  Here's how it goes. Write your test for your method (the one that doesn't exist yet).  ReSharper will give you an option to implement this method.  Choose this option.

ReSharper will open the code file and add the method, using the types from your calling code. It even raises the System.NotImplemented exception for you!

This is cool stuff, and gets rid of this awkward step!

-Brendan



Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Brendan Tompkins

Brendan has been programming with .NET since the first public beta and is owner and operator of Port Technology Services, a consultancy company providing .NET application development services to the Maritime industry. In July, 2007, he was awarded the Microsoft MVP award for ASP.NET. He's also a proud co-founder of failed .COM startup Intrinsigo, and has had a hand in the failure of numerous other businesses. He currently runs CodeBetter.Com and Devlicio.us, and lives in Norfolk, Virgina with his wife Tiara and son Ian.

View Brendan's profile on LinkedIn

Check out Devlicio.us!

Our Sponsors