基本路径覆盖的重点是什么? [英] What's the point of basis path coverage?

查看:114
本文介绍了基本路径覆盖的重点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

位于 onjava 似乎暗示,由于某些线性独立/环复杂性魔术,基本路径覆盖足以替代完整路径覆盖。

The article at onjava seems to imply that basis path coverage is a sufficient substitute for full path coverage, due to some linear-independence/cyclomatic-complexity magic.

使用类似于本文的示例:

Using an example similar to the article:

public int returnInput(int x, boolean one, boolean two)
{
    int y = x;
    if(one)
    {
        y = x-1;
    }
    if(two)
    {
        x = y;
    }
    return x;
}

,其基集为{FF,TF,FT},该错误不是裸露。只有未经测试的TT路径才会暴露它。

with the basis set {FF,TF,FT}, the bug is not exposed. Only the untested TT path would expose it.

那么,基本路径覆盖率有什么用处?

So, how is basis path coverage useful? It doesn't seem much better than branch coverage.

推荐答案

[免责声明:我之前从未听说过这种技术,它看起来很有趣,所以我做了一些搜索,这就是我认为发现的内容。希望知道他们在说什么的人也会有所贡献...]

[Disclaimer: I've never heard of this technique before, it just looks interesting so I've done a few searches and here's what I think I've found out. Hopefully someone who knows what they're talking about will contribute too...]

我认为这应该是生成分支覆盖率测试的更好方法,而不是一个完整的方法代替路径覆盖。这里有一个更长的文档,可以稍微重申一下目标: http:/ /www.westfallteam.com/sites/default/files/papers/Basis_Path_Testing_Paper.pdf

I think it's supposed to be a better way of generating branch coverage tests, not a complete substitute for path coverage. There's a far longer document here which restates the goals a bit: http://www.westfallteam.com/sites/default/files/papers/Basis_Path_Testing_Paper.pdf

onjava文章说基础路径测试的目标是相互独立地测试所有决策结果。测试四个基本路径可以实现此目标,而使其他路径无关。

The onjava article says "the goal of basis path testing is to test all decision outcomes independently of one another. Testing the four basis paths achieves this goal, making the other paths extraneous"

我认为这里的多余是指,不必要基本路径测试的目标,而不是像人们想象的那样,完全浪费每个人的时间。

I think "extraneous" here means, "unnecessary to the goal of basis path testing", not as one might assume, "a complete waste of everyone's time".

我认为独立进行测试的目的是打破当我编写代码和任意一组分支覆盖率时,我自己在工作路径和测试路径之间的偶然关联以惊人的频率出现。线性独立性没有魔力,它只是产生分支覆盖率的一种系统方法,它使测试人员不愿与程序员就分支选择之间的相关性做出相同的假设。

I think the point of testing branches independently, is to break those accidental correlations between the paths which work, and the paths you test, that occur with terrifying frequency when I write both the code and an arbitrary set of branch coverage tests myself. There's no magic in the linear independence, it's just a systematic way of generating branch coverage, which discourages the tester from making the same assumptions as the programmer about correlation between branch choices.

所以您是对的,基本路径测试会遗漏您的错误,并且通常会遗漏2 ^(N-1)-N个错误,其中N是圈复杂度。它只是旨在不错过2 ^(N-1)-N条路径最有可能是越野车,因为让编码人员选择N条路径进行测试通常是;-)

So you're right, basis path testing misses your bug, and in general misses 2^(N-1)-N bugs, where N is the cyclomatic complexity. It just aims not to miss the 2^(N-1)-N paths most likely to be buggy, as letting the coder choose N paths to test typically does ;-)

这篇关于基本路径覆盖的重点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆