【发布时间】:2017-10-03 19:48:39
【问题描述】:
在我的测试中,我有一些只需要在某些情况下运行的功能方法。我的代码如下所示:
class MyTest extends GebReportingSpec{
def "Feature method 1"(){
when:
blah()
then:
doSomeStuff()
}
def "Feature method 2"(){
if(someCondition){
when:
blah()
then:
doSomeMoreStuff()
}
}
def "Feature method 3"(){
when:
blah()
then:
doTheFinalStuff()
}
}
我应该注意我正在使用自定义 spock 扩展,它允许我运行规范的所有功能方法,即使之前的功能方法失败。
我刚刚意识到的事情以及我发布这篇文章的原因是因为“特征方法 2”由于某种原因没有出现在我的测试结果中,但方法 1 和 3 出现了。即使someCondition 设置为true,它也不会出现在构建结果中。所以我想知道为什么会这样,以及如何使这个功能方法有条件
【问题讨论】:
-
“我应该注意我正在使用一个自定义 spock 扩展,它允许我运行规范的所有功能方法,即使之前的功能方法失败。”这是正常的行为。您是否在使用
@Stepwise而并不真正想要它的行为?