Geeks With Blogs
Stefan Barrett blog

One of things I've always been interested in was to try a bit of TDD, but never seemed to be on a project where it was possible, but I thought with my current project I could do a bit of organised unit testing making use of VS2005 to generate the initial skeleton test classes. Had started going through the test code, completing the test cases, and some bits quite useful. Normally I would create an exe, which called into my code to test it, but this time I could just select a test and run it. Which was all well and good.

Then I had to do a bit of refactoring on my original code, and hit a pain point. The refactor involved changing about 12 lines of code, of which 6 were function headers (inheritance was involved). The number of tests which had to be changed, without being able to recompile the code or use intelli-sense, was not nice. Then change all the code to enable compilation.

This made me think about what seems to be a conflict between refactoring and TDD. I wonder if sites that do a lot of TDD do less refactoring or more (since it can help in ensuring the code still contains the same functionality). In my code, I could have solved my problem by introducing another function which I could have had tests for, but this would have introduced duplicate code.

So perhaps projects using TDD, do a different type of refactoring then other projects.

Posted on Friday, May 5, 2006 9:18 PM | Back to top


Comments on this post: Refactoring and tests

Comments are closed.
Comments have been closed on this topic.
Copyright © Stefan Barrett | Powered by: GeeksWithBlogs.net