【发布时间】: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(),因为它现在在块内。
【问题讨论】: