简体   繁体   English

路径测试和分支测试

[英]path testing and branch testing

Can you please explain me the different between Path and Branch testing? 你能解释一下Path和Branch测试之间的区别吗?

I read in many articles but still I am confused between this two. 我读过许多文章,但我仍然对这两者感到困惑。

I searched in stack overflow but I didn't find any suitable answer for this Please help me by providing the link if i am duplicate this question. 我在堆栈溢出搜索但我没有找到任何合适的答案请通过提供链接帮助我,如果我复制这个问题。

Thanks, 谢谢,

Quick Summary 快速摘要

Summarized from https://www.cs.drexel.edu/~jhk39/teaching/cs576su06/L4.pdf 摘自https://www.cs.drexel.edu/~jhk39/teaching/cs576su06/L4.pdf

Path Testing: 路径测试:

  • 100% path coverage. 100%路径覆盖率。
  • Execute all possible control flow paths through the program. 通过程序执行所有可能的控制流路径。

Statement Testing: 声明测试:

  • 100% statement coverage. 100%的声明覆盖率。
  • Execute all statements in a program at least once under some test. 在一些测试中至少执行一次程序中的所有语句。

Branch Testing: 分支测试:

  • 100% branch coverage. 100%分支机构覆盖率。
  • Execute enough tests to assure that every branch alternative has been exercised at least once under some test. 执行足够的测试以确保在某些测试下每个分支替代方案至少已被执行一次。

In general Path Testing >= Branch Testing >= Statement Testing, in terms of how much confidence they can provide in the correctness of your system. 通常路径测试> =分支测试> =语句测试,就他们在系统正确性方面可以提供多少信心而言。

Discussion 讨论

Path coverage counts the number of full paths from input to output through a program that get executed, whereas branch coverage counts the number of branches that were tested at any point in time. 路径覆盖率通过执行的程序计算从输入到输出的完整路径的数量,而分支覆盖率计算在任何时间点测试的分支的数量。 In this definition full path coverage will lead to full branch coverage. 在此定义中,完整路径覆盖将导致完整的分支覆盖。

There may be multiple paths which hit a single conditional statement, and full path coverage may test the different variants (because inside the if statement an external resource may be invoked which branch coverage would not identify). 可能存在多个路径命中单个条件语句,并且完整路径覆盖可以测试不同的变体(因为在if语句内部可以调用外部资源,哪个分支覆盖不会识别)。 Branch coverage is more like testing that the branch is hit at some point, and the argument is passed to a mock external resource correctly (not necessarily what comes afterwards). 分支覆盖更像是测试分支在某个时刻被命中,并且参数被正确地传递给模拟外部资源(不一定是后来的)。

As seen here: https://www.cs.drexel.edu/~jhk39/teaching/cs576su06/L4.pdf , we can sometimes represent the set of all paths by flow diagrams and the goal is to verify that each path from start to end works as expected in path testing. 如下所示: https//www.cs.drexel.edu/~jhk39/teaching/cs576su06/L4.pdf ,我们有时可以通过流程图表示所有路径的集合,目标是验证从开始的每个路径结束在路径测试中按预期工作。

Branch Testing Additional Notes 分支测试附加说明

From here: Branch testing 从这里: 分支测试

Testing in which all branches in the program source code are tested at least once

Path Testing Additional Notes 路径测试附加说明

From here: http://www.qualitytesting.info/forum/topics/what-is-difference-between-2 and http://www.cs.st-andrews.ac.uk/~ifs/Books/SE9/Web/Testing/PathTest.html 从这里: http//www.qualitytesting.info/forum/topics/what-is-difference-between-2http://www.cs.st-andrews.ac.uk/~ifs/Books/SE9/网络/测试/ PathTest.html

A path is a sequence of executable statements. Testers are concerned with
"entry-exit paths", which begin at the entry point into a given process and
proceed to its exit point. 

The objective of path testing is to ensure that each independent path through
the program is executed at least once. An independent program path is one that
traverses at least one new edge in the flow graph. In program terms, this means
exercising one or more new conditions. Both the true and false branches of all
conditions must be executed.

Basis path testing, a structured testing or white box testing technique used for designing test cases intended to examine all possible paths of execution at least once. 基础路径测试,结构化测试或白盒测试技术,用于设计测试用例,旨在至少检查一次所有可能的执行路径。 Creating and executing tests for all possible paths results in 100% statement coverage and 100% branch coverage. 为所有可能的路径创建和执行测试会产生100%的语句覆盖率和100%的分支覆盖率。

Branch coverage is a testing method, which aims to ensure that each one of the possible branch from each decision point is executed at least once and thereby ensuring that all reachable code is executed. 分支覆盖是一种测试方法,旨在确保每个决策点的每个可能分支至少执行一次,从而确保执行所有可到达的代码。

That is, every branch taken each way, true and false. 也就是说,每一个分支都采用各种方式,无论是真是假。 It helps in validating all the branches in the code making sure that no branch leads to abnormal behavior of the application. 它有助于验证代码中的所有分支,确保没有分支导致应用程序的异常行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM