0
我目前正在尝试运行2个不同类的相同测试用例,但遇到了setup()问题,我看到类似的问题,但还没有看到解决方案用Spock进行常规测试,我一直无法弄清楚。为groovy和spock中的不同类运行相同的测试
所以我基本上是用两种不同的方法解决同样的问题,所以相同的测试用例应该适用于这两个类,我试图保持不要重复自己(DRY)。
所以我成立了一个MainTest为抽象类和MethodOneTest和MethodTwoTest作为扩展抽象MainTest具体类:
import spock.lang.Specification
abstract class MainTest extends Specification {
private def controller
def setup() {
// controller = i_dont_know..
}
def "test canary"() {
expect:
true
}
// more tests
}
我的具体类是这样的:
class MethodOneTest extends MainTest {
def setup() {
def controller = new MethodOneTest()
}
}
class MethodTwoTest extends MainTest {
def setup() {
def controller = new MethoTwoTest()
}
}
所以没有人知道我可以从我的具体类MethodOneTest和MethodTwoTest中运行抽象MainTest中的所有测试吗?如何正确实例化安装程序?我希望我清楚。
嘿,那工作!谢谢! – ArmYourselves 2013-04-06 11:43:31