【问题标题】:Is it fine to write "skip() unless ok()" with Test::More?用 Test::More 写“skip() unless ok()”可以吗?
【发布时间】:2013-01-18 11:14:33
【问题描述】:

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

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

例如,我写的是这样的:

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' );
        # ...
}

我最初的测试表明这两个 sn-ps 是等效的。

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

每个SKIP 块必须有标签SKIP,否则Test::More 不能发挥它的魔力。

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

【问题讨论】:

    标签: perl tap test-more


    【解决方案1】:

    是的。为什么不呢?

    【讨论】:

    • "每个SKIP 块必须有标签SKIP,否则Test::More 不能发挥它的魔力。"担心的是魔法会溢出到ok()(它在街区内)
    • skip 执行last SKIP;ok 没有。
    猜你喜欢
    • 1970-01-01
    • 2013-08-22
    • 2012-09-18
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 1970-01-01
    • 1970-01-01
    • 2019-08-08
    相关资源
    最近更新 更多