📜  分支测试

📅  最后修改于: 2020-12-04 05:59:58             🧑  作者: Mango


什么是分支测试?

分支覆盖是一种测试方法,旨在确保每个决策点的每个可能分支至少执行一次,从而确保执行所有可到达的代码。

就是说,每个分支都采取了正确和错误的方式。它有助于验证代码中的所有分支,确保没有分支会导致应用程序异常行为。

式:

Branch Testing = (Number of decisions outcomes tested / Total Number of decision Outcomes) x 100 %

例:

Read A
Read B 
IF A+B > 10 THEN 
  Print "A+B is Large" 
ENDIF 
If A > 5 THEN 
  Print "A Large"
ENDIF

上面的逻辑可以用流程图表示为:

测试生命周期中的分支测试

结果:

To calculate Branch  Coverage, one has to find out the minimum number of paths which will ensure that all the edges are covered. In this case there is no single path which will ensure coverage of  all the edges at once. The aim is to cover all possible true/false decisions.
(1) 1A-2C-3D-E-4G-5H
(2) 1A-2B-E-4F
Hence Branch Coverage is 2.