1. 作业要求
见《软件测试基础》P49,Q7——a)b)c)d)。
2. 作业内容
a)为printPrimes()方法画控制流程图:
b) 考虑测试用例t1=(n=3)和t2=(n=5)。即使这些测试用例游历printPrimes()方法中相同的主路径,他们不一定找出相同的错误。设计一个简单的错误,使得t2比t1更容易发现。
数组越界问题
c) 针对printPrimes(),找到一个测试用例,使得响应的测试路径访问连接while语句开始到for语句的边,而不用通过while循环体。
t3=(n=0)(或者n=1)
d) 针对printPrimes()的图例列举每个节点覆盖,边覆盖和主路径覆盖的测试需求。
节点覆盖:
TR={0,1,2,3,4,5,6,7,8,9,10,11,12,13}
边覆盖:
TR={(0,1),(1,2),(2,3),(3,4),(4,5),(4,6),(5,6),(6,3),(3,7),(7,8),(7,9),(8,9),(9,1),(1,10),(10,11), (10,13),(11,12),(12,10)}
主路径覆盖:
TR={
[4,5,6,3,7,9,1,10,13]
[4,5,6,3,7,8,9,1,10,13]
[4,5,6,3,7,9,1,10,11,12]
[4,5,6,3,7,8,9,1,10,11,12]
[2,3,7,8,9,1,10,11,12]
[2,3,7,8,9,1,10,13]
[4,5,6,3,7,8,9,1,2]
[7,8,9,1,2,3,4,5,6]
[2,3,7,9,1,10,11,12]
[4,5,6,3,7,9,1,2]
[7,8,9,1,2,3,4,6]
[7,9,1,2,3,4,5,6]
[0,1,2,3,4,5,6]
[0,1,2,3,7,8,9]
[7,9,1,2,3,4,6]
[0,1,10,13]
[0,1,10,11,12]
[11,12,10,13]
[2,3,7,8,9,1,2]*
[3,7,8,9,1,2,3]*
[7,8,9,1,2,3,7]*
[8,9,1,2,3,7,8]*
[9,1,2,3,7,8,9]*
[1,2,3,7,8,9,1]*
[3,7,9,1,2,3]*
[7,9,1,2,3,7]*
[9,1,2,3,7,9]*
[3,4,5,6,3]*
[4,5,6,3,4]*
[5,6,3,4,5]*
[6,3,4,5,6]*
[3,4,6,3]*
[4,6,3,4]*
[6,3,4,6]*
[10,11,12,10]*
[11,12,10,11]*
[12,10,11,12]*
}