Looking for a very subtle unit testing example

Posted by Stéphane Bruckert on Programmers See other posts from Programmers or by Stéphane Bruckert
Published on 2013-10-30T13:47:49Z Indexed on 2013/10/30 16:11 UTC
Read the original article Hit count: 292

In the context of Continuous Integration, I need to teach unit testing to a 20-people audience of programmers.

Everything will be all right, but I am still trying to find the perfect unit testing example.

More than writing tests like a robot, I want to show that unit testing can help prevent very subtle errors. I am thinking of the following scenario to happen when doing a live TDD demo:

  • the test cases would already be written,
  • we would have to write methods together,
  • most of us would naturally have forgotten to handle a specific case for a method,
  • everyone would then be surprised, when seeing that all tests don't pass,
  • the failing test would make us think more and realize that we forgot an important case.

My question will probably finish as "too broad" or "not clear what you are asking", but we never know, one of you might have a great idea. Your answer can use Java and JUnit, though any other language will be fine since only the idea will matter.

© Programmers or respective owner

Related posts about java

Related posts about unit-testing