Test methods have names like testFoo
Test results are verified by assertEquals()
Test classes extend junit.framework.TestCase
A simple test for addition:
import junit.framework.TestCase;
import org.apache.commons.lang.math.*;
public class FractionTest extends TestCase {
public void testAddition() {
Fraction half = Fraction.ONE_HALF;
Fraction fourth = Fraction.ONE_QUARTER;
Fraction actual = half.add(fourth);
Fraction expected = Fraction.getFraction(3, 4);
assertEquals(expected, actual);
}
}