perl - 用 Test::More 写 "skip() unless ok()"可以吗?

标签 perl tap test-more

我已经浏览了documentation并且找不到我的查询的明确答案。

在我的许多测试中,SKIP block 的执行取决于先前测试的成功。

例如,我写的是:

ok( @results > $threshold , 'Threshold met' );

SKIP: {
        skip 'due to insufficient results', 3
          unless @results > $threshold;
        # ...
}

如果我的测试发生变化,我不想更改两个位置,所以我想要一个 DRY-er 等效项:

SKIP: {
        skip 'due to insufficient results', 3
          unless ok( @results > $threshold , 'Threshold met' );
        # ...
}

我的初步测试表明这两个片段是等效的。

但是,文档中的一些内容引起了我的注意:

Each SKIP block must have the label SKIP, or Test::More can't work its magic.

我担心的是,魔法可能会溢出到 ok(),因为它现在位于 block 内。

最佳答案

是的。为什么不会呢?

关于perl - 用 Test::More 写 "skip() unless ok()"可以吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14675150/

相关文章:

perl - 如何使用 Test::More 和 friend 来自动测试继承的行为?

perl - 仅在 Test::More 中报告失败的测试

perl - HTTPS 代理和 LWP::UserAgent

perl - 执行 perl 测试的时间指定是多少

perl - 跨多列排序 (Perl)

ios - 如何让 UITextView 在当前是第一响应者时注册触摸?

PHP 简单 HTML DOM 或 Python-BSoup : which one is the easier approach?

linux - Tap接口(interface)和/dev/net/tun设备,使用ip tuntap命令

iOS 上的 jQuery Mobile - 点击事件的目标错误

perl - 在 Test::More 中抑制通过的测试输出