When you’ve come up with an overall design / idea for how a part of a system should work, how do you decide where to start when doing TDD, or rather, how do you decide your first test to start with?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Lets assume I’m coding a class called
Ovento bake my deliciousPieobjects. This is how I step through the unit-test order:Oven oven = new Oven();No test for this one, I suppose.oven.turnOn(int degrees)sounds good, I’ll do that. How do I check it? Better makeoven.getTemperature(). There’s an obvious test.Pie. For that I needoven.bake(Pie p)so I’ll make that. But now what? I want to check if the pie is ready but rather than havingoven.isPieReady()I think thatoven.pastryStatus()which returns things like ‘nothing in oven’, ‘raw’, ‘almost done’, ‘cooked’ and ‘charred’ sounds good and in general should be more extendable thanoven.isPieReady()so I’ll do that.And so on and so forth. So, I’ll make my tests in order I expect to use the object refining the specification as I go. In the end I usually end up with rather simple yet powerful API which does what I want. After I’ve unit tested my API, I run coverage on my code to see what I missed and then add extra tests for those.