实践白盒测试之逻辑覆盖案例.pptx
实践白盒测试之逻辑覆盖案例实践白盒测试之逻辑覆盖案例例子程序:if(a1)&(b=0)x=x/a;if(a=2)|(x1)x=x+1;Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第1页/共36页程序框图(语句覆盖)(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第2页/共36页1.语句覆盖设计若干条测试用例,使程序中每条设计若干条测试用例,使程序中每条可执行语句至少执行一次。可执行语句至少执行一次。用例ABX执行路径Case1aceCase2abe语句覆盖Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第3页/共36页1.语句覆盖设计若干条测试用例,使程序中每条设计若干条测试用例,使程序中每条可执行语句至少执行一次。可执行语句至少执行一次。用例ABX执行路径Case1203aceCase2213abe语句覆盖Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.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.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第5页/共36页Case2:A=2,B=1,X=3(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdc此语句未覆盖此语句未覆盖语句覆盖Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.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语句覆盖是最弱的覆盖语句覆盖是最弱的覆盖语句覆盖Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第7页/共36页程序框图(判定覆盖)(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第8页/共36页 2.判定覆盖(分支覆盖)设计测试用例,使程序中的每个逻辑设计测试用例,使程序中的每个逻辑判断的取真和取假的分支至少经历一判断的取真和取假的分支至少经历一次。次。用例ABX执行路径Case1aceCase3abdEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第9页/共36页 2.判定覆盖(分支覆盖)设计测试用例,使程序中的每个逻辑设计测试用例,使程序中的每个逻辑判断的取真和取假的分支至少经历一判断的取真和取假的分支至少经历一次。次。用例ABX执行路径Case1203aceCase3101abdEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.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.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第11页/共36页第二组:Case3:A=1,B=0,X=1(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdc判定覆盖Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第12页/共36页n 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(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第15页/共36页3.条件覆盖设计若干测试用例,使程序的设计若干测试用例,使程序的每个判每个判定中的每个条件定中的每个条件的可能取值至少满足的可能取值至少满足一次一次上例中设条件:上例中设条件:A1 T1 A1 T1 F1 F1 B=0 T2 B=0 T2 F2F2 A=2 T3 A=2 T3 F3F3 X1 T4 X1 T4 F4F4取真表为取真表为取假表为取假表为Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第16页/共36页n n满足条件覆盖的一组测试用例满足条件覆盖的一组测试用例A B X路径覆盖分支覆盖条件Case6T1 F2 T3 F4Case7F1 T2 F3 T43.3.条件覆盖条件覆盖条件覆盖Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第17页/共36页n 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.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第18页/共36页 Case6Case6:A=2,B=1,X=1A=2,B=1,X=1 Case7Case7:A=1,B=0,X=3A=1,B=0,X=3(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdc 两个测试用例覆盖了四个条件八种可能取值。两个测试用例覆盖了四个条件八种可能取值。但未覆盖但未覆盖c c、d d分支,不满足判定覆盖的要求。分支,不满足判定覆盖的要求。条件覆盖Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第19页/共36页程序框图(判定条件覆盖)(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第20页/共36页4.判定-条件覆盖使判定中使判定中每个条件每个条件的可能取值至少满的可能取值至少满足一次,并且使足一次,并且使每个判定分支每个判定分支至少执至少执行一次。行一次。判定判定-条件覆盖能同时满足条件覆盖能同时满足判定判定判定判定、条件条件条件条件两种覆盖标准。两种覆盖标准。Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第21页/共36页满足判定满足判定-条件覆盖的一组测试用例条件覆盖的一组测试用例A B X路径覆盖分支覆盖条件Case1c eT1 T2 T3 T4Case8b dF1 F2 F3 F4Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.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.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.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.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.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+1eFFTTbdcEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第25页/共36页程序框图(条件组合覆盖)(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第26页/共36页5.条件组合覆盖设计用例,使得每个判断表达式中设计用例,使得每个判断表达式中条条件的各种可能组合件的各种可能组合都至少出现一次;都至少出现一次;Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.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 判定二为假Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.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.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 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.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第30页/共36页程序框图(路径覆盖)(A1)AND(B=0)(A=2)OR(X1)aX=X/AX=X+1eFFTTbdcEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第31页/共36页6.路径覆盖设计足够多的测试用例,覆盖程序中设计足够多的测试用例,覆盖程序中的的每条可能路径每条可能路径。上述满足条件组合覆盖的测试用例不上述满足条件组合覆盖的测试用例不能覆盖路径能覆盖路径acdacd。Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第32页/共36页满足路径覆盖的一组测试用例满足路径覆盖的一组测试用例用例用例ABX执行路径执行路径Case1aceCase7abdCase8abeCase11acdEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第33页/共36页满足路径覆盖的一组测试用例满足路径覆盖的一组测试用例用例用例ABX执行路径执行路径Case1203aceCase7101abdCase8211abeCase11301acdEvaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第34页/共36页Evaluation only.Evaluation only.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Created with Aspose.Slides for.NET 3.5 Client Profile 5.2.0.0.Copyright 2004-2011 Aspose Pty Ltd.Copyright 2004-2011 Aspose Pty Ltd.第35页/共36页感谢您的观看。感谢您的观看。第36页/共36页