Sunday, March 25, 2007

Need for JUnit Framework for testing:

Yes ! this was exactly the question that was there in my mind for quite some time. It is interesting to spot the difference between my thought process before and after reading JUnit literature.

Before:
- Who needs the test cases for minor methods, after all can they really be broken ?!
- I can test my units by running them repeatedly, manually.
- If need be I can write a driver program that can run my units to be put under test.
- I understand JUnit is a standard framework, but who has the time to learn a new framework - My manager doesn't want 'JUnit' test cases either.

Then I read about the thumbrules for writing test cases:
- Each unit test must run independent of the other.
- Errors must be detected and reported, effectively.
- It must be easy to identify and selectively run unit tests.

Also, that the Framework provides following infrastructure support;
- each test is loaded using a separate class-loader, that makes running and failing different cases practically independent of each other.
- registering and introspecting methods, using which one can select which tests to run in particular.
- reports all errors on a case by case basis.


After:
How can you do it with out JUnit !! :-)