step:
1. Select the current project - the right choice, build path - add libraries - JUnit 4 - Next
2. Create a Java class, unit testing.
At this Java class requirements: ① ② the class is public class provides public no-argument constructor (do not write on the line)
Test Method 3. Such units declared.
At this time, the unit test method, the method is rights public, no value is returned, there is no parameter
Example:
4. This test method requires a statement unit annotations, @ Test, and introduced into the unit test class, import org.junit.Test
5. The method of statement good after testing unit, can be tested in the method body code is related to the class.
6. After the code written, double-click the left button unit test method names, right: run as - JUnit Test
Description:
1. If the results without any exception, the green bar
2. If the results appear abnormal, red stripe