The installation of JUnit, Hamcrest, and Eclemma.
1.junit and Hamcrest add Junit-4.12.jar and Hamcrest-all-1.3.jar in build path by adding external jars after creating a new JUNITHW1 project.
2.eclemma Click Help-eclipse Marketplace-find-eclemma Install under Eclipse to restart Eclipse.
Second, the programming judgment triangle is equilateral triangle, isosceles triangle or not equilateral triangle.
Public classTriangle {Private Static intError = 0; Private Static intEquilateral = 1; Private Static intIsosceles = 2; Private Static intScalene = 3; Public Static intTriangletype (intAintBintc) { if(A <= 0 | | b <= 0 | | c <= 0){ return0; }Else if(A + B > C && a + C > B && B + C >a) { if(A = = b && b = =c) {System.out.println ("This is a equilateral triangle."); return1; }Else if(A = = b | | a = = c | | b = =c) {System.out.println ("This is a isosceles triangle."); return2; }Else{System.out.println ("This is a scalene triangle."); return3; } }Else{ return0; } } }
To create a test class
Public classTriangle {Private Static intError = 0; Private Static intEquilateral = 1; Private Static intIsosceles = 2; Private Static intScalene = 3; Public Static intTriangletype (intAintBintc) { if(A <= 0 | | b <= 0 | | c <= 0){ return0; }Else if(A + B > C && a + C > B && B + C >a) { if(A = = b && b = =c) {System.out.println ("This is a equilateral triangle."); return1; }Else if(A = = b | | a = = c | | b = =c) {System.out.println ("This is a isosceles triangle."); return2; }Else{System.out.println ("This is a scalene triangle."); return3; } }Else{ return0; } } }
Third, test results
Software testing on-machine jobs