simple and nice!
I think, example used here is too simple ....
JUnit is a popular testing framework. This guide shows how to write a JUnit test.
A class to be tested:
class Calculator {
public int add(int i, int j) {
return i + j;
}
}
Rules for writing a JUnit testcase:
Our testcase:
import junit.framework.TestCase;
class CalculatorTestCase extends TestCase {
public void testAdd() {
try {
Calculator calc = new Calculator();
int result = calc.add(1, 2);
assertEquals(result, 3);
} catch(Exception e) {
fail();
}
}
}