Information on JUnit4
- successor to most widely used unit-testing framework for Java, JUnit3
- under active development (last JUnit3 release 3.8.2 2006-03-03)
- JUnit 4 released 2006-02-16
- 4.1 2006-04-27
- 4.2 2006-11-16
- 4.3 2006-11-16
- 4.4 (current as of 071204) 2007-07-18
- based on Java 5 annotations
- no longer need to extend class TestCase
- test-method names do not have to start with the prefix test
- mark your test method with a @Test annotation
import junit.framework.TestCase;
import org.junit.Test;
import static org.junit.Assert.*;;
public class CalculatorTest extends TestCase {
@Test
public void testadd() {
....
assertEquals(4, calculator.add( 1, 3 ));
}
}