我已经浏览了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 labelSKIP
, orTest::More
can't work its magic.
我担心的是,魔法可能会溢出到 ok()
,因为它现在位于 block 内。
最佳答案
是的。为什么不会呢?
关于perl - 用 Test::More 写 "skip() unless ok()"可以吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14675150/