Freigeben über


Test-Driven Properties

Zero-Friction TDD post #10:

In principle, defining properties (or fields, for that matter) while TDD'ing should be no different than defining methods. Again, the important part is to stay focused on the test at hand, and not become bogged down by implementation details.

Unfortunately, neither Visual Studio 2005 nor 2008 has a Generate property stub smart tag, so until the day arrives when we get support for such in our IDE of choice (and for the record: I have no idea about when this is going to happen), we'll have to resort to more primitive means:

Just reference the non-existing property and move on:

UndefinedProperty

As you can see from the picture, my test code gets squiggly lines under the MyProperty property because this property doesn't exist (yet).

Once more, the important point is to move on and resist the urge to fix this immediately. Don't even waste memory (your own, that is) on the fact that you need to implement this soon; just forget about it right away. The compiler will remind you in due time.

This technique is a essentially what Michael Feathers calls leaning on the compiler, although the context is different .

Comments