Loading ...
Sorry, an error occurred while loading the content.

92722Re[2]: Why preserve TDD tests anyway (was RE: [XP] Testing Leftover)

Expand Messages
  • Michael Feathers
    Jun 1, 2004
    • 0 Attachment
      Hello Lior,

      Tuesday, June 1, 2004, 3:03:58 AM, you wrote:


      LF> I want to focus on the point several people have made about the ability
      LF> to test all the classes by using only public interfaces.

      LF> I agree!

      LF> If the behavior of all the interfaces is correct than I do not care what
      LF> the class does inside.
      LF> However if I go back to my case it all started out as you said
      LF> I wrote down the tests I thought needed to test the class behavior (via
      LF> using the interfaces only)
      LF> And than I started coding. At some point ive got all the tests working
      LF> and I said "ok now lets
      LF> make the code cleaner" I don't want to use the refacturing term cause I
      LF> don't really think I truly used any refacturing mechanisms,
      LF> but the intention was the same.

      LF> So after doing this for a while ive got to the point when one of my
      LF> tests broke
      LF> The reason was that I made a stupid mistake in changing the registration
      LF> method a mistake that was only caught later on by a test to the
      LF> monitoring part.

      LF> Now it took me a while to find this out so I wanted to make sure that
      LF> this wont happen again
      LF> And here is were this thread came into being. I didn't have a way to
      LF> check it.

      LF> So ive added a function that searched the list of the registered
      LF> components to check if after I register a component it is there.
      LF> Now I needed to place this function. So ok it's a basic getter/finder
      LF> function lets add it to the class.
      LF> But wait no one outside the testing actually need it so I don't want to
      LF> add a chunk of unused code into the class so lets put it in the test
      LF> class and make the test class a friend, It actually stayed this way for
      LF> a couple of weeks until I wanted to publicate the whole thing and I
      LF> noticed I just did something very bad. Left testing code in the
      LF> operational code.
      LF> And this is the story of this thread.

      Lior, I know this has been mentioned before but I didn't see you
      respond. If you have a class A which registers components with B why
      not have a mock B which allows you to search and use it under test?
      That way, you don't have this finder in your production code and you
      are able to see A's impact on B.

      Michael Feathers
      www.objectmentor.com
    • Show all 12 messages in this topic