Content-Length: 51534 | pFad | http://osherove.com/tdd-kata-2/
If you have an online video of you performing this kata or parts of it, please ping me and I’ll link to it here so other people can learn from you.
This kata is based on the previous String Calculator Kata. It is meant to be a continuation of the teaching process about unit testing and TDD. In this part of the teaching process, the kata forces you to think about interacting with the user, and subsequently to perform interation testing using mocks, and possible some stubs (what’s the difference?)
Becuase this kata requires interaction testing, many students find this kata much harder to accomplish than the first string calculator kata. That’s ok. Getting interaction testing takes longer. Don’t worry if you find yourself struggling with this for a day or even two or three. even in class, with me there, students can take a couple of hours and sometimes up to five hours to accomplish the steps in the kata in this page, with me coaching them.
The biggest problem that people face is that they get so mired in the details of how to fake this and that,they end up faking too much, and not really testing anything. Sometimes students will lose track of what it is they are trying to test in the first place. now, more than ever, good test names can save you. by writing down in the test name the three main parts of the test (what’s being tested, under what conditions, and what should the expected behavior be under those condistions).
When you are lost, the test name becomes your map and guide, to make sure your test follows what you wrote down in the test name, in each of its parts. The end behavior is what the mock should be asserting. the conditions are the setup code. the “what” is the “act” part of the test. that’s the thing you invoke. people get those mixed up a lot when getting through this, be careful!
I would recommend NOT to write any code in the test method body until you get the name good enough to explain as an english sentence. this can even take 30 minutes at first, and that’s perfectly OK. it’s part of you getting to grips with the actual problem and how to solve it.
Add the following features to String Calculator (either in the same class, or using any other structure or design you’d like). Make sure to go through them one at a time and try not to look ahead. Imagine this is a real project where each feature is requested the day after you’ve finished implementing the feature before it.
Fetched URL: http://osherove.com/tdd-kata-2/
Alternative Proxies: