标签:
1. 针对附录1给出的三角形判断Java 代码,应用等价类划分法设计测试用例,用表格形式列出设计的测试用例.
测试预言中“()”内的为错误预言
序号 |
测试输入:三条边(a,b,c) | 测试预言(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 | (1,2,3) | Illegal |
7 | (-1,-1,-1) | (Regular) |
8 | (4,4,5) | Isoceles |
2.模仿附录2给出的三角形判断Junit测试代码,设计单元测试脚本,测试 “1”设计得到的测试用例。
package com.cvicse.test.junit; import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Test; public class TriangleTest { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void test() { fail("Not yet implemented"); } @Test public void testlsTringle1(){ Triangle t=new Triangle(4,3,2); assertEquals(t.getType(t),"Scalene"); } @Test public void testlsTringle2(){ Triangle t=new Triangle(0,5,5); assertEquals(t.getType(t),"Illegal"); } @Test public void testlsTringle3(){ Triangle t=new Triangle(4,4,4); assertEquals(t.getType(t),"Regular"); } @Test public void testlsTringle4(){ Triangle t=new Triangle(-1,-1,-1); assertEquals(t.getType(t),"Illegal"); } @Test public void testlsTringle5(){ Triangle t=new Triangle(3,4,5); assertEquals(t.getType(t),"Illegal"); } @Test public void testlsTringle6(){ Triangle t=new Triangle(1,2,3); assertEquals(t.getType(t),"Illegal"); } @Test public void testlsTringle7(){ Triangle t=new Triangle(-1,-1,-1); assertEquals(t.getType(t),"Regular"); } @Test public void testlsTringle8(){ Triangle t=new Triangle(4,4,5); assertEquals(t.getType(t),"Isoceles"); } }
3.测试结果运行图:
结果显示和我设想的结果一样。
我的github链接:https://github.com/MocQiQi/homework/blob/master/作业8.txt
4.心得体会:由于上课没有认真听讲,导致对测试的环节摸不着头脑,即使看着别人的博客也是一头雾水,在重新学习下终于成功了。我用的是Junit 4。并且在测试用例下,根据等价划分可以分为四类:等边三角形,非等边三角形,等腰三角形和一般三角形。在测试之前要注明@test。
标签:
原文地址:http://www.cnblogs.com/zhangQiQi/p/5495808.html