Tuesday, February 19, 2008

Mary Had a Little Lamb

One of the techniques I use for developing test cases is "Mary had a little lamb." Sure, the name of it is kind of long, but bear with me.

Essentially, what you do in this technique is take each word of your spec and exercise it. Ask yourself: What else could this be, and how would that affect things? Not all of these will be relevant, but it's a good way to stress each portion of the spec. Then simply chuck what you don't need.

For example: Mary had a little lamb.
  • What if it's Bob? Does gender make a difference?
  • What if there are 4 people named Mary? Who has the lamb?
  • What if Mary is a nickname and her full name is something else? Does how you address it matter?
  • What if she had it but doesn't any more?
  • What if she doesn't have a lamb, but it should be here tomorrow?
  • What if the lamb belongs to her but isn't in her possession? (i.e., what if "had" is not literal)
  • What if there are no lambs?
  • What if there is more than one lamb?
  • How big is little? Is this age or size?
  • What happens if the lamb is bigger than expected?
  • What if it's a sheep?
  • What if it's a chicken? (or some other non-related animal)
  • What if it's a shovel? (or some other non-animal thing)
  • What if the lamb is somehow unusual - color, or baa-ing?
This technique doesn't yield test cases directly, but it does help you ask intelligent questions about the system.

  • This works particularly well when you're helping with requirements definition. The specs tend to be defined in a positive manner (what will the system do) rather than in a negative manner (what if the system doesn't)
  • Exercising each word can help you break out of a thought rut that is causing you to miss some test parameters.
  • It's a fast exercise to train on and can be used with non-testers fairly easily.

  • This really only works if you have a fairly short spec. I can't imagine doing this with a 20 page document.
  • Non-comprehensive. I don't know of any technique that is fully comprehensive!
  • It can bring up overlapping test areas. Post-processing is necessary to distill this to testable items.
  • It can be tedious if you have a long example. Schedule this one in chunks so people don't burn out.

Good luck! Oh, and don't worry about sounding funny walking around saying, "MARY had a little lamb. Mary HAD a little lamb. Mary had A little lamb." It really does help.

No comments:

Post a Comment