TDD means to test before you start writing production code. So I start writing a test for
MyClassTest. It fails and I start to implement the wanted functionality in
During the implementation phase of
MyClass I encounter that changes on another class (e.g.
MyClassUtils) are needed to be done.
MyClassUtils has a test class of its own. Following TDD I should test first before implementing any new functionality. So should I interrupt the work on
MyClass for the first test and implement the needed methods in
MyClassUtilsTest first? Or is it better to somehow track (e.g. writing it down on paper, TODOs in the code etc.) the test methods that need to be added and disregard "test first"?
I often encounter that problem and I am not sure what is the best way to deal with it. The first possibility leads to bigger and messed up commits with changes in at least four classes and longer time periods without commits. The second one disregards the test first principle, leads to a backlog of unimplemented tests and lowers the code coverage.
How do you deal with it? I am thankful for any advice. :)