Per-Test Setup and Tear-Down : TestCase « JUnit « Java Tutorial






import java.sql.Connection;

import junit.framework.TestCase;

public class TestDB extends TestCase {
  private Connection dbConn;

  protected void setUp() {
    // connect to database
  }

  protected void tearDown() {
    // disconnect from database
  }

  public void testAccountAccess() {
  }

  public void testEmployeeAccess() {
  }
}








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