Thursday, March 12, 2009

Unit testing with JUnit

JUnit is a simple framework for Unit testing. JUnit can be used to write repeatable test cases.

JUnit testing is java unit testing. Writing and running a JUnit test involves easy steps.

Steps to Write and run a JUnit test case:
  1. Create a class

  2. Write a test method (annotated with @Test) that asserts expected results on the object under test

  3. Although writing a main() method to run the test is much less important it is good to write a main method.

  4. Run the test