我应该如何处理无法修复的错误的失败测试

发布于 2024-10-27 10:06:47 字数 430 浏览 0 评论 0原文

我有一组复杂的集成测试,使用 Perl 的 WWW::Mechanize 来驱动 Web 应用程序并根据特定的数据组合检查结果。有超过 20 个子例程组成了测试逻辑、循环数据等。每个测试都在不同的数据集上运行多个测试子例程。

该网络应用程序并不完美,因此有时错误会导致使用非常特定的数据组合进行测试失败。但这些组合非常罕见,以至于我们的团队很长一段时间都不会费心去修复这些错误;优先考虑构建许多其他新功能。

那么对于失败的测试我该怎么办?这只是每个数据组合的数十个测试中的几个测试。 1)我不能让它失败,因为那样整个测试套件都会失败。 2)如果我们将它们注释掉,这意味着我们错过了对所有其他数据集进行测试的机会。 3)我可以在失败的特定数据集中添加一个标志,并且如果设置了该标志,则测试不会运行,但随后我会在测试子例程中的各处传递额外的标志。

最干净、最简单的方法是什么? 或者干净和简单是互斥的?

I have a complex set of integration tests that uses Perl's WWW::Mechanize to drive a web app and check the results based on specific combinations of data. There are over 20 subroutines that make up the logic of the tests, loop through data, etc. Each test runs several of the test subroutines on a different dataset.

The web app is not perfect, so sometimes bugs cause the tests to fail with very specific combinations of data. But these combinations are rare enough that our team will not bother to fix the bugs for a long time; building many other new features takes priority.

So what should I do with the failing tests? It's just a few tests out of several dozen per combination of data.
1) I can't let it fail because then the whole test suite would fail.
2) If we comment them out, that means we miss out on making that test for all the other datasets.
3) I could add a flag in the specific dataset that fails, and have the test not run if that flag is set, but then I'm passing extra flags all over the place in my test subroutines.

What's the cleanest and easiest way to do this?
Or are clean and easy mutually exclusive?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

青朷 2024-11-03 10:06:47

这就是 TODO 的用途。

对于待办事项块,内部测试预计会失败。 Test::More 将正常运行测试,但打印出特殊标志,指示它们是“todo”。 Test::Harness 会将失败解释为正常。如果任何事情成功,它将报告为意外成功。然后您就知道您必须做的事情已经完成,并且可以删除 TODO 标志。

与简单地注释掉一组测试相比,待办事项测试的好处在于它就像有一个程序化的待办事项列表。您知道还有多少工作要做,您知道存在哪些错误,并且您会立即知道它们何时得到修复。

一旦待办事项测试开始成功,只需将其移出块即可。当块为空时,将其删除。

That's what TODO is for.

With a todo block, the tests inside are expected to fail. Test::More will run the tests normally, but print out special flags indicating they are "todo". Test::Harness will interpret failures as being ok. Should anything succeed, it will report it as an unexpected success. You then know the thing you had todo is done and can remove the TODO flag.

The nice part about todo tests, as opposed to simply commenting out a block of tests, is it's like having a programmatic todo list. You know how much work is left to be done, you're aware of what bugs there are, and you'll know immediately when they're fixed.

Once a todo test starts succeeding, simply move it outside the block. When the block is empty, delete it.

神爱温柔 2024-11-03 10:06:47

我看到两个主要选项

  1. 禁用测试(将其注释掉),并参考您的错误跟踪系统(即错误IG),可能还会在错误中保留注释,并表明已为该错误准备了测试< /p>

  2. 移动失败的内容在单独的测试套件中进行测试。您甚至可以反转失败的断言,这样您就可以运行该套件,当它是绿色时,错误仍然存​​在,如果它变成红色,则错误已经消失或有其他问题。当然,错误跟踪系统和包的链接仍然是一件好事。

I see two major options

  1. disable the test (commenting it out), with a reference to your bugtracking system (i.e. a bug ig), possibly keeping a note in the bug as well that there is a test ready for this bug

  2. move the failing tests in a seperate test suite. You could even reverse the failing assertion so you can run the suite and while it is green the bug is still there and if it becomes red either the bug is gone or something else is fishy. Of course a link to the bugtracking system and bag is still a good thing to have.

放我走吧 2024-11-03 10:06:47

如果您实际上将 Test::More 与 WWW::Mechanize 结合使用,则案例已结(请参阅@daxim 的评论)。如果没有,请考虑类似的方法:

# In your testing module
our $TODO;
# ...
if (defined $TODO) {
    # only print warnings
};

# in a test script
local $My::Test::TODO = "This bug is delayed until iteration 42";

If you actually use Test::More in conjunction with WWW::Mechanize, case closed (see comment from @daxim). If not, think of a similar approach:

# In your testing module
our $TODO;
# ...
if (defined $TODO) {
    # only print warnings
};

# in a test script
local $My::Test::TODO = "This bug is delayed until iteration 42";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文