[ 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.
Test Cases |
|
|
Serial number |
Test input: Three edges |
Test prophecy |
1 |
3, 4, 5 |
Triangle |
2 |
5, 5, 5 |
Equilateral triangle |
3 |
3, 5, 3 |
Isosceles Triangle |
4 |
1, 2, 7 |
Not a triangle. |
[ 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 commit the source code to your own github. (20 points)
Import Staticorg.junit.assert.*; Importorg.junit.Test; Public classtesttriangle{@Test Public voidTestIsTriangle1 () {Triangle T=NewTriangle (3,4,5); Assertequals (T.gettype (t),"Scalene"); } @Test Public voidTestIsTriangle2 () {//according to the mutant, this test case should failTriangle T =NewTriangle (5,5,5); Assertequals (T.gettype (t),"Regular"); } @Test Public voidTestIsTriangle3 () {Triangle T=NewTriangle (3,5,3); Assertequals (T.gettype (t),"Isoceles"); } @Test Public voidtestIsTriangle4 () {Triangle T=NewTriangle (1,2,7); Assertequals (T.gettype (t),"Illegal"); } }
The test results are all in line with expectations.
[ 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)
First, create a new JUnit test file below the Java project, and then write the code in appendix two. Create a new class in the sub-directory, write the judgment code in appendix one, and change the value of the triangle three sides,
As well as the desired results of the test, you can reach the test. If you need to change the direction of the test, simply add the new judging criteria and expected values in class.
Job 8: Unit Test exercise