1. To judge Java code for the triangle given in Appendix 1, Apply equivalence class partitioning method to design test cases and list the design test cases in tabular form.
Error prediction in "()" in Test prophecy
Serial number |
Test input: Three edges (a,b,c) |
Test Prophecy (Oracle:illegal,regular,scalene,isoceles) |
1 |
(4,3,2) |
Scalene |
2 |
(0,5,5) |
Illegal |
3 |
(4,4,4) |
Regular |
4 |
( -1,-1,-1) |
Illegal |
5 |
(3,4,5) |
(illegal) |
6 |
(a) |
Illegal |
7 |
( -1,-1,-1) |
(Regular) |
8 |
(4,4,5) |
Isoceles |
2. Simulate the JUnit test code with the triangle given in Appendix 2, design the unit test script, and test the test case that the "1" design obtains.
Package Com.cvicse.test.junit;importStaticorg.junit.assert.*; import Org.junit.after;import org.junit.before;import org.junit.Test; Public classtriangletest {@Before Public voidsetUp () throws Exception {} @After Public voidTearDown () throws Exception {} @Test Public voidTest () {fail ("Not yet implemented"); } @Test Public voidTestlsTringle1 () {Triangle T=NewTriangle (4,3,2); Assertequals (T.gettype (t),"Scalene"); } @Test Public voidTestlsTringle2 () {Triangle T=NewTriangle (0,5,5); Assertequals (T.gettype (t),"illegal"); } @Test Public voidTestlsTringle3 () {Triangle T=NewTriangle (4,4,4); Assertequals (T.gettype (t),"Regular"); } @Test Public voidtestlsTringle4 () {Triangle T=NewTriangle (-1,-1,-1); Assertequals (T.gettype (t),"illegal"); } @Test Public voidtestlsTringle5 () {Triangle T=NewTriangle (3,4,5); Assertequals (T.gettype (t),"illegal"); } @Test Public voidTestlsTringle6 () {Triangle T=NewTriangle (1,2,3); Assertequals (T.gettype (t),"illegal"); } @Test Public voidTestlsTringle7 () {Triangle T=NewTriangle (-1,-1,-1); Assertequals (T.gettype (t),"Regular"); } @Test Public voidTestlsTringle8 () {Triangle T=NewTriangle (4,4,5); Assertequals (T.gettype (t),"Isoceles"); }}
3. Test result run diagram:
The result is the same as I imagined.
My GitHub Link: https://github.com/MocQiQi/homework/blob/master/job 8.txt
4. Experience: Because the class did not listen carefully, leading to the test of the link to touch the mind, even looking at other people's blog is also confused, in the re-study finally succeeded. I'm using JUnit 4. And under the test case, according to the equivalence division can be divided into four categories: equilateral triangle, non-equilateral triangle, isosceles triangle and general triangles. Note the @test before testing.
Unit Test Exercises