- [ must do 1] for the triangle given in Appendix 1 to Judge Java code, the use of equivalent class partitioning method to design test cases, tabular form of the design of the test cases, written to the blog. (10 points)
Test Cases |
Serial number |
Test input: Three edges (a,b,c) |
Test Prophecy (Oracle: Right angle, isosceles, equilateral triangle) |
1 |
Input (1,1,1) |
Equilateral triangle |
2 |
Input (* * *) |
*** |
[ must do 2] imitate Appendix 2 gives the triangle judgment junit test Code, Design Unit test script, test [ must do 1] design of the test case. Note the order in which the test cases appear in the test script is consistent with the order listed in the [ required title 1] table. Run the resulting test script, truncate the result graph, write to the blog, and push the source code to your own github. (20 points)
[ must do title 3] experience. Write down the Knowledge points (PS: Test Case design methods and steps; test script design steps or main content) that you gain from this exercise. (10 points)
"Must do 1"
Tabular format Test Cases:
Serial number |
Test input: Three edges (a,b,c) |
Test language (Oracle: Right angle, isosceles, equilateral triangle) |
1 |
Input (2,2,2) |
Equilateral triangle |
2 |
Input (3,4,5) |
General triangles |
3 |
Input (3,3,2) |
Isosceles Triangle |
4 |
Input (1,1,2) |
Not a triangle. |
5 |
Input (0,2,3) |
Not a triangle. |
"Must do 2"
Import Staticorg.junit.assert.*;Importorg.junit.Test; Public classtriangletest {@Test Public voidTest () {fail ("Not yet implemented"); } @Test Public voidTestIsTriangle1 () {Triangle T=NewTriangle (2,2,2); Assertequals (T.gettype (t),"Regular");//Equilateral} @Test Public voidTestIsTriangle2 () {//according to the mutant, this test case should failTriangle T =NewTriangle (3,4,5); Assertequals (T.gettype (t),"Scalene");//General} @Test Public voidTestIsTriangle3 () {Triangle T=NewTriangle (3,3,2); Assertequals (T.gettype (t),"Isoceles");//isosceles} @Test Public voidtestIsTriangle4 () {Triangle T=NewTriangle (1,1,2); Assertequals (T.gettype (t),"Illegal");//Illegal Data} @Test Public voidtestIsTriangle5 () {Triangle T=NewTriangle (0,2,3); Assertequals (T.gettype (t),"Illegal");//Illegal Data } }
Test results:
"Must do 3"
This assignment let me know:
The design test case should consider the valid equivalence class and the invalid equivalence class to improve the reliability of the code, divide equivalence class to consider a variety of cases, triangle equivalence class is divided into equilateral triangle, isosceles triangle, General triangle and non-triangular, the design of test cases should contain various equivalence classes.
Unit tests note that the test method modifier is public, the return type is void, there are no method arguments, and the method name begins with test. JUnit is the framework for testing code, and unit tests are used to test the results of a program with the same values as you expect.
Job 8: Unit test Exercise (personal practice)