Use assertEquals in a test method : TestCase « JUnit « Java Tutorial






import junit.framework.TestCase;

public class TestLargest extends TestCase {
  public TestLargest(String name) {
    super(name);
  }

  public void testAdds() {
    assertEquals(2, 1 + 1);
    assertEquals(4, 2 + 2);
    assertEquals(-8, -12 + 4);
  }
}








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