《实践白盒测试之逻辑覆盖案例课件.pptx》由会员分享,可在线阅读,更多相关《实践白盒测试之逻辑覆盖案例课件.pptx(36页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、例子程序:if(a1)&(b=0)x=x/a;if(a=2)|(x1)x=x+1;Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第1页/共36页程序框图(语句覆盖)(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyrigh
2、t 2004-2011 Aspose Pty Ltd.第2页/共36页1.1.语句覆盖设计若干条测试用例,使程序中每条可执行语句至少执行一次。用例ABX执行路径Case1aceCase2abe语句覆盖Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第3页/共36页1.1.语句覆盖设计若干条测试用例,使程序中每条可执行语句至少执行一次。用例ABX执行路径Case1203aceCase2213abe语句覆盖Evaluati
3、on only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第4页/共36页Case1:A=2,B=0,X=3(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdc语句覆盖Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第5页/共36页Cas
4、e2:A=2,B=1,X=3(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdc此语句未覆盖此语句未覆盖语句覆盖Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第6页/共36页Case1:A=2,B=0,X=3(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdc错写成错写成OR错写成错写成AND语句覆盖是最弱的覆盖语句覆盖是最弱的覆盖语句覆盖Evaluat
5、ion only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第7页/共36页程序框图(判定覆盖)(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第8页/共36页 2.2.判定覆盖(分支覆
6、盖)设计测试用例,使程序中的每个逻辑判断的取真和取假的分支至少经历一次。用例ABX执行路径Case1aceCase3abdEvaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第9页/共36页 2.2.判定覆盖(分支覆盖)设计测试用例,使程序中的每个逻辑判断的取真和取假的分支至少经历一次。用例ABX执行路径Case1203aceCase3101abdEvaluation only.Created with Aspose.Sl
7、ides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第10页/共36页第一组:Case1:A=2,B=0,X=3(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdc判定覆盖Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第11页/共36页第二组:Case3:A=1,B=0,X=1(A1)AN
8、D(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdc判定覆盖Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第12页/共36页n 只作到判定覆盖将无法确定判定内部条件的错误。(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdc错写成错写成X1)AND(B=0)(A=2)OR(X1)X=X/AX=X+1eFFTTbdc错写成错写成X1)AND(B=0)(A=2)OR(X
9、1)aX=X/AX=X+1eFFTTbdcEvaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第15页/共36页3.3.条件覆盖设计若干测试用例,使程序的每个判定中的每个条件的可能取值至少满足一次上例中设条件:A1 T1 F1 A1 T1 F1 B=0 T2 F2 B=0 T2 F2 A=2 T3 F3 A=2 T3 F3 X1 T4 F4 X1 T4 F4取真表为取真表为取假表为取假表为Evaluation only.C
10、reated with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第16页/共36页n满足条件覆盖的一组测试用例A B X路径覆盖分支覆盖条件Case6T1 F2 T3 F4Case7F1 T2 F3 T43.3.条件覆盖条件覆盖条件覆盖Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第17页/
11、共36页n满足条件覆盖的一组测试用例A B X路径覆盖分支覆盖条件Case6 2 1 1a b eb eT1 F2 T3 F4Case7 1 0 3a b eb eF1 T2 F3 T43.3.条件覆盖条件覆盖条件覆盖Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第18页/共36页 Case6:A=2,B=1,X=1 Case7:A=1,B=0,X=3(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+
12、1eFFTTbdc 两个测试用例覆盖了四个条件八种可能取值。但未覆盖c、d分支,不满足判定覆盖的要求。条件覆盖Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第19页/共36页程序框图(判定条件覆盖)(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile
13、 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第20页/共36页4.4.判定-条件覆盖使判定中每个条件的可能取值至少满足一次,并且使每个判定分支至少执行一次。判定-条件覆盖能同时满足判定判定、条条件件两种覆盖标准。Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第21页/共36页满足判定-条件覆盖的一组测试用例A B X路径覆盖分支覆盖条件Case1c eT1 T2 T3 T4
14、Case8b dF1 F2 F3 F4Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第22页/共36页满足判定-条件覆盖的一组测试用例A B X路径覆盖分支覆盖条件Case12 0 3a c ec eT1 T2 T3 T4Case81 1 1a b db dF1 F2 F3 F4Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile
15、5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第23页/共36页(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcCase1:A=2,B=0,X=3Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第24页/共36页Case8:A=1,B=1,X=1(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluati
16、on only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第25页/共36页程序框图(条件组合覆盖)(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第26页/共36页5.5.条件组合覆盖
17、设计用例,使得每个判断表达式中条件的各种可能组合都至少出现一次;Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第27页/共36页n上例中需考虑4个条件的8种组合 A 1,B=0 T1 T2 判定一为真 A 1,B0 T1 F2 A1,B=0 F1 T2 判定一为假 A1,B0 F1 F2 A=2,X 1 T3 T4 A=2,X1 T3 F4 判定二为真 A2,X1 F3 T4 A2,X1 F3 F4 判定二为假Eva
18、luation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第28页/共36页满足条件组合覆盖的一组测试用例A B X路径 覆盖组号 覆盖条件Case1T1 T2 T3 T4Case8T1 F2 T3 F4Case9F1 T2 F3 T4Case10F1 F2 F3 F4Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyri
19、ght 2004-2011 Aspose Pty Ltd.第29页/共36页满足条件组合覆盖的一组测试用例A B X路径 覆盖组号 覆盖条件Case12 0 3a c eT1 T2 T3 T4Case82 1 1a b e T1 F2 T3 F4Case91 0 3a b e F1 T2 F3 T4Case101 1 1a b d F1 F2 F3 F4Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第30页/共36页
20、程序框图(路径覆盖)(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第31页/共36页6.6.路径覆盖设计足够多的测试用例,覆盖程序中的每条可能路径。上述满足条件组合覆盖的测试用例不能覆盖路径acd。Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile
21、 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第32页/共36页满足路径覆盖的一组测试用例用例用例ABX执行路径执行路径Case1aceCase7abdCase8abeCase11acdEvaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第33页/共36页满足路径覆盖的一组测试用例用例用例ABX执行路径执行路径Case1203aceCase7101abdCase8211abeCase11301acdEvaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第34页/共36页Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.第35页/共36页感谢您的观看。第36页/共36页
限制150内