[ 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 |
Test input: Three edges (a,b,c) |
Test Prophecy (Oracle: Right angle, isosceles, equilateral triangle) |
1 |
(0,2,0) |
Illegal triangles |
2 |
(2,3,5) |
Illegal triangles |
3 |
( -1,-3,-3) |
Illegal triangles |
4 |
(7,7,9) |
Isosceles Triangle |
5 |
(3,7,8) |
General triangles |
6 |
(3,3,3) |
Equilateral 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 push the source code to your own github.
@Test Public voidTestlsTringle1 () {Triangle1 T=NewTriangle1 (0,2,0); Assertfalse (T.istriangle1 (t)); } @Test Public voidTestlsTringle2 () {Triangle1 T=NewTriangle1 (2,3,5); Assertfalse (T.istriangle1 (t)); } @Test Public voidTestlsTringle3 () {Triangle1 T=NewTriangle1 ( -1,-3,-3); Assertfalse (T.istriangle1 (t)); } @Test Public voidtestlsTringle4 () {Triangle1 T=NewTriangle1 (7,7,9); Assertfalse (T.istriangle1 (t)); } @Test Public voidtestlsTringle5 () {Triangle1 T=NewTriangle1 (3,7,8); Assertfalse (T.istriangle1 (t)); } @Test Public voidTestlsTringle6 () {Triangle1 T=NewTriangle1 (3,3,3); Assertfalse (T.istriangle1 (t)); }
Run the test class to get the result
The results are consistent with the test case table.
[ 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.
The classification of my triangles is divided into general triangles, isosceles triangle, equilateral triangle, and illegal triangles. In the test case, in addition to the general situation, a negative number ( -1,-3,-3) is considered, there are two equal sides but not triangles (0,2,0) and other special cases. Because before to how to test the unskilled, but also check the data, step-to-step test script, in the teacher gave examples to add and modify the test script, and then test with MyEclipse in the JUNIT4, the results are also consistent with expectations. In the process, I think test case testing is a very tedious thing, the test process is very difficult to test people's attention and patience. The problem often occurs in the unknown place this sentence does not mean that there is no problem in the known place, so as to guarantee the correctness of the program.
GitHub Link: https://github.com/liuyutianlyt/Triangle
Unit Test Exercises