William said:
| What *exactly* do you mean by stubbing out? Creating the methods in the
| production class, or creating methods in the test class to match the
| ones in the production class.
Sorry, was not clear. I mean either.
You can create your class with just its "interface/signatures" with
NotImplementedExceptions until you dev each method. You could
also add methods to your Tests that throw Inconclusive (or what
ever) until you implement the methods in the class.
I don't want to write *any* code (not even the signatures) until I've
written a test though. The question is how it makes that.
| My point is that if I've got a single method in the production class, I
| may well want three or four test methods with names indicating what
| aspect of that method they'll be testing. Sometimes two methods are
| tested by the same set of tests. In other words, creating a "matching"
| set of methods in the test code has never seemed that useful to me.
I understand. TMK, it only adds one-for-one by default. Naturally, in
DoSomethingTest() above, you could add multiple "tests" inside that
one method and each test would need to pass that particular Assert or
you get the respective Assert fails.
Eek no - having multiple logical tests within a single test should be
avoided. It makes it harder to work out how much is wrong, because the
first assertion that fails masks later ones which *would* have failed
(unless assertions are handled a very different way in VSTS...)
You could call any number of helper
methods, or create multiple Test methods with a diff name (i.e.
DoSomethingTestNull, etc) as you need. Not sure how a tool would
"know" you wanted 2 or 4 test methods for the same overload (or what
to call them)?
It can't - which is sort of my point. I can't say I find any of the
skeleton-generators helpful, and can't see how they're likely to
*become* helpful. In other words, whether or not a system includes one
doesn't sway me in favour of it.
| No, that's not test-driven development. With test-driven development
| you don't know what methods you'll have in your class until you've
| written your tests.
You could do that above if you wanted. If class1.DoSomething() did not exist yet,
do what you need to do in the DoSomething() Test method. Are you thinking of
something else?
I'm not sure whether or not we're talking past each other - see
below...
| Yes, but different IDE features can certainly help TDD. I seem to
| remember that 2005 is capable of creating methods that you call even
| when they don't exist just like Eclipse does. That's what really helps
| TDD.
Forgive me. How would this help you? There is nothing being tested.
You want that test to fail anyway until you dev the logic. So why call ghost
methods? Just Assert.Inconclusive("Not implemented") in that test method
until you hook-up the class logic. I am surely missing something.
The point of TDD is that you write the test before you write the method
which implements it - including the signature, often. That way, you
design the API in terms of how to make it usable and testable, rather
than trying to imagine how you *might* want to use it. So, I'd write a
test which called imaginary methods, get the IDE to create dummy
implementations for those methods, and then run the test (which would
fail).
The important thing is that the IDE has to make it easy to generate the
dummy methods given a test which calls them - that's what helps TDD.
| I'm not entirely clear about what "VSDev" is. I'll have to look through
| my MSDN discs to find it. I have VS 2005 Pro installed, and that
| *doesn't* have the MS test stuff. Have they released the testing stuff
| as a free add-in? (I've been gently prodding MS for this for a
Sorry, all those VS versions confuse me. Mine is VSTS Software Developer. With
your MSDN pkg, you had to pick if you wanted Developer or Tester - IIRC. You may
have it already. If not, contact your lead and they may be able to change things
around for you. HTH
Ah, so you *do* need VSTS, as I thought. That's the problem - not
everyone (far from everyone) will have VSTS. If it were available in
Pro but not Express, I'd still view that as a pity - but not being
available in Pro? Bad mistake IMO.
Jon