A new kind of developer testing kata

There are lots of code katas out there that are typically used to help developers practice test driven development and writing well-designed code. I have a new kind of kata for you today.

In my last post I talked about how developers should be able to test their own code, but as developers we need to get better and defining all of the test cases. The only way to get better is to practice.

Testing a four-function calculator

Let’s say you need to test a basic four function calculator like this one.

Calculator

What are all of the testing scenarios? Keep in mind that just from looking at the picture, you might not know the exact requirements of how the calculator works without asking some questions.

Some basic details (for those of you who are too young to ever have used one of these calculators):

  • Pressing M+ will add the current value to the value stored in memory (or 0 if there is no memory value), but not change the value on the screen
  • Pressing M- will subtract the current value to the value stored in memory (or 0 if there is no memory value), but not change the value on the screen
  • Pressing MR will load the current memory value and display it on the screen
  • Pressing MC will clear the current memory value, but not change the value on the screen

If you don’t know how something should work, write down the question that you need to ask or record the assumption that you made about how it should work (so that you could validate the assumption later). You’re also allowed to try things on your computer’s calculator to see how something should work (in real life, we often look at other implementations of our software to get ideas about how it should work), but remember to write down your assumptions so that you can validate them.

Come up with your test cases, questions, and assumptions and post your answers in the comments. You can use any format for the test cases that you would like. Let’s see what you can come up with.