JUnit 4 usage in eclipse

Source: Internet
Author: User
Tags garbage collection

JUnit is a unit test framework for the Java language. Founded by Kent Beck and Erich Gamma, it became the most successful of the Xunit family of Sunit from Kent Beck. JUnit has its own JUnit expansion biosphere. Most Java development environments have integrated JUnit as a unit test tool.
JUnit is a regression testing framework (regression testing framework) written by Erich Gamma and Kent Beck. JUnit testing is a programmer's test, the so-called white-box test, because the programmer knows how the software being tested (how) accomplishes the function and what it does. JUnit is a set of frameworks that inherit the TestCase class and can be automatically tested with JUnit.

Here's a look at how to configure the utility JUnit 4 in ECLIPSE-LUNA-SR2.

On your project, right click on the bottom of the properties, select Java Build Path in the navigation bar on the left side of the popup window, select Libraries on the Top tab;

Then click on the Add Library on the right ..., select JUnit in the pop-up window and click next>;

By default, JUnit 4 is selected, followed by finish;

In this way, the Test toolkit for JUnit 4 is added, so let's look at how to use it.

First, right-clicking on the->new->junit test case on the class file we want to test pops up the dialog box for the new JUnit test cases, where you can select the JUnit version, the path name, and so on, or use the default, The setup () and teardown () functions are selected on the basis of the default configuration for initialization and garbage collection work;

Then click Next> to perform the selection of the function to be tested in the class, we choose the Plus, minus, times, divide four functions that were previously written;

Click Finish, will automatically Shanghai, a test class named Testcalculate, which contains the corresponding function of the empty test case, now only need to do the test content code you want to fill in it;

We then right-click Run As->junit test on the test class to run the test and pop the result on the left.

JUnit 4 usage in eclipse

Related Article

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.