I am experimenting with test-driven development, and I found that I often come to a following situation:I write tests for some functionality X. Those tests fail.While trying to implement X, I see that I need to implement some feature Y in a lower layer of my code. So...I write tests for Y. Now both tests for X and Y fail.Once I had 4 features in different layers of code being worked on at the same time, and I was losing my focus on what I am actually doing (too many tests failing at the same time).I think I could solve this by putting more effort into planning my tasks even before I start writing tests. But in some cases I didn't know that I will need to go deeper, because e.g. I didn't know the API of lower layer very well.What should I do in such cases? Does TDD have any recommendations?
TDD, new tests while old ones not implemented yet
language agnostic;tdd
The good thing is that you realize your code under test needs assistance. Rather than implementing it right away, create an interface and use mocks to make sure your tests are tageting the correct code. After you get those tests passing, you can then move on to implementing the code it relies on.