【问题标题】:path testing and branch testing路径测试和分支测试
【发布时间】:2013-03-31 12:05:45
【问题描述】:

您能解释一下路径测试和分支测试之间的区别吗?

我阅读了很多文章,但我仍然对这两者感到困惑。

我在堆栈溢出中进行了搜索,但没有找到任何合适的答案如果我重复这个问题,请提供链接帮助我。

谢谢,

【问题讨论】:

    标签: java unit-testing testing integration-testing


    【解决方案1】:

    快速总结

    总结自https://www.cs.drexel.edu/~jhk39/teaching/cs576su06/L4.pdf

    路径测试:

    • 100% 路径覆盖。
    • 通过程序执行所有可能的控制流路径。

    语句测试:

    • 100% 语句覆盖率。
    • 在某个测试中至少执行一次程序中的所有语句。

    分支测试:

    • 100% 的分支覆盖率。
    • 执行足够的测试,以确保每个分支备选方案在某个测试下至少执行一次。

    一般来说,路径测试 >= 分支测试 >= 语句测试,即它们可以为您的系统的正确性提供多大的信心。

    讨论

    路径覆盖计算通过执行的程序从输入到输出的完整路径的数量,而分支覆盖计算在任何时间点测试的分支数量。在这个定义中,完整的路径覆盖将导致完整的分支覆盖。

    可能有多个路径命中单个条件语句,并且完整路径覆盖可能会测试不同的变体(因为在 if 语句中可能会调用外部资源,而分支覆盖无法识别)。分支覆盖率更像是测试分支是否在某个时间点被命中,然后将参数正确传递给模拟外部资源(不一定是之后发生的事情)。

    如此处所示:https://www.cs.drexel.edu/~jhk39/teaching/cs576su06/L4.pdf,我们有时可以用流程图表示所有路径的集合,目标是验证从开始到结束的每条路径在路径测试中是否按预期工作。

    分支测试附加说明

    从这里:Branch testing

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

    路径测试附加说明

    从这里:http://www.qualitytesting.info/forum/topics/what-is-difference-between-2 和 http://www.cs.st-andrews.ac.uk/~ifs/Books/SE9/Web/Testing/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.
    

    【讨论】:

    • 语句测试
    【解决方案2】:

    基本路径测试,一种结构化测试或白盒测试技术,用于设计测试用例,旨在至少检查一次所有可能的执行路径。为所有可能的路径创建和执行测试会导致 100% 的语句覆盖率和 100% 的分支覆盖率。

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

    也就是说,每个分支都采取不同的方式,真假。它有助于验证代码中的所有分支,确保没有分支导致应用程序的异常行为。

    【讨论】:

    • 基本路径测试是通过被测方法覆盖所有线性独立路径。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    相关资源
    最近更新 更多