joshua.ewer
joshua.ewer

Reputation: 3962

How do I make TDD in Visual Studio less painful?

I've become a bit of a TDD zealot lately. Explaining the concept isn't the hard part. Most people respect the purpose behind it. However, when I try to demonstrate the actual process behind the idea, the biggest complaint is:

"When I'm writing my initial tests, I hate how Visual Studio intellisense tries to guess what I'm doing. It's obviously going to be wrong because I haven't written the API yet. It takes me out of context when I have to fix all the things that Intellisense has guessed incorrectly."

which, unfortunately often comes out as:

"TDD (or Visual Studio) sucks"

It's never really bothered me before (I just delete the stuff it guesses wrong), but I see the problem. What has everyone else done to get around this issue? Obvious answers are:

  1. Turn off intellisense when writing tests, then turn it back on when writing the API.
  2. Write your tests in something like Notepad++, then copy into VS when you think you're happy
  3. Stop whining

P.S. I looked everywhere on SO (and elsewhere) for this question so feel free to flag as duplicate if I missed it... As if you needed my permission ;-)

Edit: And, yes, I have Resharper, it's awesome.

Upvotes: 1

Views: 462

Answers (5)

haku
haku

Reputation: 4505

And if your company is willing, have them purchase NCrunch extension for you guys. If they are not, try convincing them. It is a concurrent test runner and it cuts traditional TDD time in half (for me). Not having to go back and run the test after writing the implementation, or getting what the exception (assert exceptions) are right on the editor, and getting feedback right away as you write your code is simply amazing! I think this tool makes a switch to TDD much easier. I feel TDD with RGR approach is quite tedious and time consuming (without NCrunch), very much worth it though. As a point in Joel Test says, "buy the best tools money can buy" (I am aware of company budget approval is another tedious thing).

Upvotes: 0

Ray
Ray

Reputation: 1585

Err... Correct me if I am wrong but I personally love intellisense on the fly code analysis. Especially in conjuction with Resharper it makes TDD a real fun process. You write a test with not yet defined classes and methods, then extremely fast generate stubs using Resharper, make it compile, then add functionality to the point when your test runs successfuly, then you refactor as needed and rinse and repeat.

Upvotes: 3

RBarryYoung
RBarryYoung

Reputation: 56725

Turn Intellisense off temporarily.

From the menu it's: Tools..Options..Text Editor and then turn off "Auto List Members" and "Parameter Information".

Upvotes: 0

Chris Johnston
Chris Johnston

Reputation: 1919

Learn to use the Esc key and start to think about what you are programming. Intellisense is a double edge sword in that it both speeds up your coding but it also causes people to stop thinking about what they are doing. TDD is all about thinking, not mindlessly allowing the IDE to do your work for you. When the little pop-up Intellisense box appears, just hit Esc and it goes away without filling anything in.

Also, get Resharper. This is absolutely mandatory for programming in Visual Studio, but doubly so for TDD.

(Btw, Visual Studio does suck).

Upvotes: 5

lance
lance

Reputation: 16342

Learn to ignore the Intellisense, and get ReSharper. Then write the code you want and let ReSharper create the shells into which you'll eventually author your implementation code.

Upvotes: 5

Related Questions