JUnit Test Composition : TestCase « JUnit « Java Tutorial






import junit.framework.*;
public class TestClassOne extends TestCase {

  public TestClassOne(String method) {
    super(method);
  }
  public void testAddition() {
    assertEquals(4, 2+2);
  }
  public void testSubtraction() {
    assertEquals(0, 2-2);
  }
}








39.2.TestCase
39.2.1.extends TestCase
39.2.2.Use assertEquals in a test method
39.2.3.JUnit Test Composition
39.2.4.Per-Test Setup and Tear-Down
39.2.5.Test Skeleton
39.2.6.Test your stack structure
39.2.7.Test algorithm
39.2.8.Init class being tested in test case method