Steps:
1. First create a new project called Junittest, I write a student class, and then the student's gender, age unit test;
2. In the second step, the JUNIT4 unit test package is introduced into this project: Right-click on the item, click "Properties", in the pop-up Properties window, first select "Java Build Path" on the left, then to the right of the "Library" tab, then on the far right to click on the button, Then select JUNIT4 and click OK in the new Popup dialog box.
3. Generate the JUnit test framework: In Eclipse's Package Explorer, right-click on the pop-up menu and select "Java test Case";
4. On the generated page, select ' New JUNIT4 test ', ' SetUp ' tab, click "Next", the system will automatically list the methods you include in this class, select "Student's gender, age test, then the system will automatically generate a new class studenttest, It contains a few empty test cases.
5. Finally, modify these test cases slightly, then right-click on the Studenttest class, select "Run as" and select "1 JUnit Test" to run, the test results indicate "run count 4, ignore 1, error 0,
Number of Failures 2 ", running results
Java Unit Test