Code of practice from requirements documents to design documents (IV.)

Source: Internet
Author: User
Tags comments how to write test cases

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 ()

*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.