导读:
本文主要介绍了白盒测试的概念、特点、设计方法及案例,希望对你有帮助。 本文来自于百度,由Linda编辑、推荐。 |
本文来自于百度,由Linda编辑、推荐。 |
|
为了方便读者阅读,采用CML(Concept
Model Language powered by 火龙果软件)对本文建模如下: |
 |
面对越来越多的信息,我们的语言需要进化,CML(Concep
Model Language)的目标: |
|
所有人都能够使用:科学家、工程师、学生
可以支持各个专业:物理、数学、飞机、汽车...
建立自然语言和专业模型之上的逻辑语言 |
|
|
建模者:Linda 工具:EA |
|
正文:
什么是白盒测试

白盒测试的特点

白盒测试设计方法

测试设计方法——逻辑覆盖法
逻辑覆盖法:是通过对程序逻辑结构的遍历实现程序的覆盖。
覆盖率:是用来度量测试完整性的一个手段


测试设计方法——语句覆盖
语句覆盖:设计测试用例,使得程序中每条语句至少被执行一次。

例如:
案例代码中共有4条可执行语句
设计测试用例执行了3条,语句覆盖率为3/4=75%


测试设计方法——判定覆盖
判定覆盖:也叫分支覆盖,设计测试用例,使得程序中的每个判的“真”和“假”都至少被执行一次。即:程序中的每个分支至少执行一次。

例如:
案例代码中有判定2个,判定结果4个
设计测试用例执行了3个分支,分支覆盖率为3/4=75%


测试设计方法——条件覆盖
条件覆盖:设计测试用例,使得判定中的每个条件至少有一次取真值,有一次取假值。

例如:
案例代码中有判定2个,条件3个,条件结果6个
设计测试用例执行了5个条件结果,条件覆盖率为5/6=83%


测试设计方法——判定条件覆盖
判定条件覆盖:设计测试用例,使得被测试程序中的每个判断本身的判定结果(真假)至少满足一次,同时,每个逻辑条件的可能值(真假)也至少被满足一次。即同时满足100%判定覆盖和100%条件覆盖的标准。

例如:
案例代码中有判定2个,条件3个,判定结果4个,条件结果6个
设计测试用例执行了3个判定结果,5个条件结果,判定条件覆盖率为:(3+5)/(4+6)=80%


测试设计方法——条件组合覆盖
条件组合覆盖:设计测试用例,使得被测试程序中的每个判定中条件结果的所有可能组合至少执行一次。

例如:
案例代码中有判定2个,条件3个(判定1有2个条件,判定2有1个条件),判定1的条件组合为4个,判定2的条件组合为2个
设计测试用例执行了5个条件组合,条件组合覆盖率为:5/(4+2)=83%


测试设计方法——路径覆盖
路径覆盖:设计测试用例,覆盖程序中所有可能的路径。

例如:
案例代码中共有4条路径
设计测试用例执行了3条路径,路径覆盖率为3/4=75%


测试设计方法——逻辑覆盖

测试设计方法——基本路径测试法
基本路径测试法:在程序控制流图的基础上,通过分析程序的环路复杂性,导出基本可执行路径集合,从而设计测试用例

基本路径测试法步骤





|