JUnit example - a JUnit JBuilder template

Here is a JUnit template I use with JBuilder:

package PACKAGE;

import junit.framework.*;

public class CLASSNAME extends TestCase
{

  /**
   * Set up work to be done before test cases.
   */
  protected void setUp()
  {
  }

  /**
   * do a tear down after each test
   */
  protected void tearDown()
  {
  }


  public void testPOBox123()
  {
    String address = "P.O. Box 123";
    String numericAddress = AddressTool.convertAddress(address);
    String expectedResult = "123";
    assert( "\ntestNull, EXPECTED: " + expectedResult + ", GOT: " + numericAddress, numericAddress.equals(expectedResult) );
  }


  public void testBlank()
  {
    String address = "";
    String numericAddress = AddressTool.convertAddress(address);
    String expectedResult = "";
    assert( "\ntestNull, EXPECTED: " + expectedResult + ", GOT: " + numericAddress, numericAddress.equals(expectedResult) );
  }


  public void testNull()
  {
    String address = null;
    String numericAddress = AddressTool.convertAddress(address);
    String expectedResult = "";
    assert( "\ntestNull, EXPECTED: " + expectedResult + ", GOT: " + numericAddress, numericAddress.equals(expectedResult) );
  }


  public static void main(String args[])
  {
    junit.textui.TestRunner.run(CLASSNAME.class);
  }

  public CLASSNAME(String name)
  {
    super(name);
  }

  /**
   * add one line here for each test in the suite
   */
  public static Test suite()
  {
    TestSuite suite = new TestSuite();

    // run tests manually
    //suite.addTest( new CLASSNAME("testBlank") );
    //suite.addTest( new CLASSNAME("testNull") );
    //return suite;

    // or, run tests dynamically
    return new TestSuite(CLASSNAME.class);
  }

}

Some of this stuff isn't needed every time, but I keep it in the template as a reminder. Inside of JBuilder I name this template junitTestCase.