Testing of program modules using JUNIT4 in Java

Source: Internet
Author: User

Today talk about how to use the JUNIT4 in ECL to test the program module, to achieve the Java program Tracking evaluation.

I. Introduction of the topic

The code I tested was a small project that I had written before-----the arithmetic of the primary school. The interface is very simple, but the basic functions can be achieved, but the program is not very perfect, some defects.

Second, the source of GitHub links.

Https://github.com/Tsir/ClassTest/tree/master

Third, the design of the module test cases, test results. The operation is as follows:

Step 1: Select the test project file, right-click to select the JUnit test case, select Junit4,setup to generate a test case, such as:

The generated test classes are as follows:

The system automatically generates a new class Demotest, which contains some empty test cases. You only need to make these test cases slightly modified to use. The complete demotest code is as follows:

Import static org.junit.assert.*;

Import Org.junit.Tset;

public class demotest{

@Test

public void Test () {

Fail ("not yet implemented");

}

}

Step 2: Click to run this test class, operation

Step 3: Run the results such as:

The results show that I have no errors with this program. Runtime 0.001.

Iv. problems and solutions, experience.

There is a serious listen to the teacher in the classroom how to use Eclipse to JUNIT4 module test, but one to the next class, alone, the brain is blank, to all feel strange, but I caught the life of a very common network, using the browser I found a solution, step by step learning, Finished the homework. At the same time, I understand that students should be good at using the resources and practice of the importance of the classroom, light on the basic knowledge, will only talk on paper, is unable to master the essence of knowledge, only through practice, can the real transformation of knowledge into their own, and then use the knowledge to learn more, to create the scientific value of knowledge, Make learning more meaningful.

Testing of program modules using JUNIT4 in Java

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.