1.2 JUnit Unit Test
Most integration tools integrate the JUnit unit test plug-in and have wizards to help write unit tests. The JUnit release package document provides a detailed description of the JUnit design concepts and the design patterns used. Here I briefly explain how to write test cases, invoke test cases in an ant configuration file, and generate test reports.
Write Test Cases
The following code is written based on the test case Testmycode file written by the Eclipse JUnit Wizard on the Mycode class:
Import Junit.framework.TestCase;
/*
* Created on 2003-4-30
*
* To change the template for this generated file go
* Window>preferences>java>code Generation>code and Comments
*/
/**
* @author Gongys
*
* To change the template for this generated type comment go
* Window>preferences>java>code Generation>code and Comments
*/
public class Testmycode extends TestCase {
Mycode Myfixture=null;
/**
* Constructor for Testtest.
* @param arg0
*/
Public Testtest (String arg0) {
Super (ARG0);
}
/*
* @see Testcase#setup ()
*/
protected void SetUp () throws Exception {
Super.setup ();
Myfixture = new Mycode ();
SYSTEM.OUT.PRINTLN ("Setup");
}
/*
* @see Testcase#teardown ()
*/