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