java Spock-忽略子类的规范方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30664090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spock- ignore spec method for a subclass
提问by ps-aux
I have a test spec in Spock
and I want to apply the same tests to another alternative with exception of one method. I extend the original spec, implement some custom stuff related to the alternative and would really like to exclude the execution of one test method.
我有一个测试规范Spock
,我想将相同的测试应用于另一种替代方法,但一种方法除外。我扩展了原始规范,实现了一些与替代方案相关的自定义内容,并且真的很想排除执行一种测试方法。
I tried it with
我试过了
@Ignore
def "Something must work in a certain way"() {
//No implementation
}
but it seems that the method is called anyway.
但似乎无论如何都会调用该方法。
Can this be achieved?
这能实现吗?
回答by dmahapatro
Verify the import statement for @Ignore
. It should be imported from spock library instead of JUnit:
验证 的导入语句@Ignore
。它应该从 spock 库而不是 JUnit 导入:
import spock.lang.Ignore
instead of
代替
import org.junit.Ignore