jUnit Quickstart
jUnit is a framework for writing and running test cases—http://junit.org/. A test is a Java class containing jUnit annotations to set up the test and identify test methods. Basically, you annotate test methods with the @Test annotation and verify results using assertion. When you want to check a value dependent on the nature of the check and the type of the value, you call the appropriate assertion.
For example, if you want to check that the value of a Boolean variable is true, you would write: assertTrue(var). There are many different assertions located in package import org.junit.Assert.*. Notice that you have to import this package statically to each test class. Methods containing test code are annotated with @org.junit.Test. For example:
@Test
public void testFoo(){
..
}
To start writing your own tests, download junit-4.xx.jar from https://github.com/KentBeck/junit/downloads and add it to the class path.
Writing a simple unit test
Next, we will go through a basic test...