[软件测试学习] 黑盒测试之因果图(Black box testing with Cause-Effect Graphs)

这次软件测试课上我们学习了因果图,根据老师的讲义&网上的资料&自己的想法总结如下

 

因果图(Cause-Effect Graphing)

Cause-Effect Graphing (CEG) is basically a Black-box testing technique that is used to create test cases according to the specifications provided. (It is a type of Requirements-Based Testing, also known as Dependency modelling)

因果图根据说明书创建测试用例,是一种黑盒测试的方法 

 

因果图适用的情况

What CEG does is that it helps capture the relationships between specific combinations of inputs (causes) and outputs (effects).

因果图用于特定的输入给出一个输出的结果。

但是对于这样的情况因果图并不适用:比如中间过程中另需要用户输入数据而不是直接由一串输入得到结果的情况。

 

因果图的表示符号 Notations used)

1.原因 --> 结果(Nodes)

每个Nodes表示两个状态中的一个:0或者是1

[软件测试学习] 黑盒测试之因果图(Black box testing with Cause-Effect Graphs)

 

2.原因之间的约束(Constraints)

E => c1 & c2 can not be 1 simultaneously(两个不可以同时为1)

I => c1, c2, c3 can not be 0 simultaneously(两个不可以同时为0)

O => One, and only one, of c1 & c2 must be 1(有且只有一个可以为1)

R => For c1 to be 1, c2 must be 1(c1为1则c2必须为1)

[软件测试学习] 黑盒测试之因果图(Black box testing with Cause-Effect Graphs)

3.结果之间的约束(“Masks” Constraint)

 

If effect e1 is 1, effect e2 is forced to 0(当e1为1时,e2则被强制为0)

[软件测试学习] 黑盒测试之因果图(Black box testing with Cause-Effect Graphs)

 

因果图测试用例的设计步骤

1.确定软件规格需求中的原因和结果

Divide the specifications into workable pieces and Identify cause & effects in the specifications.

2.确定原因和结果之间的逻辑关系

Analyze the semantic content of the specification & transform it into a Boolean graph linking the cause and effects   (Cause-Effect Graph)

3.确定因果图中的各种约束

Annotate the graph with constraints

4.画出因果图并转化为决策表

Convert graph into a limited-entry decision table.

5.根据决策表设计测试用例

 

因果图法的测试运用

[产品说明书]有一个处理单价为1元5角钱的盒装饮料的自动售货机软件。若投入1元5角硬币,按下“可乐”、“雪碧”、或“红茶”按钮,相应的饮料就送出来。若投入的是2元硬币,在送出饮料的同时退还5角硬币。

(1)确定需求中的原因与结束

原因编号 内容  
c1 投入1元5角  
c2 投入2元  
c3 按下“可乐”  
c4 按下“雪碧”  
c5 按下“红茶”  
结果编号 输出动作 需求
ef1 退还5角 c2∩(c3∪c4∪c5)
ef2 送出“可乐” (c1∪c2)∩c3
ef3 送出“雪碧” (c1∪c2)∩c4
ef4 送出“红茶” (c1∪c2)∩c5

 

(2)建立原因结果的逻辑关系

见(1)需求部分

(3)确定约束

E(c1,c2); E(c3,c4,c5)

(4) 画出因果图

[软件测试学习] 黑盒测试之因果图(Black box testing with Cause-Effect Graphs)

 

(5)决策表和设计测试用例(略)

 

学后思考

这里只是考虑了比较简单的情况。没有考虑到三个按钮同时按下、没有零钱、没有饮料等系列情况。如果加入这些情况之外会更加复杂。测试真的需要有一个清晰的逻辑!