【发布时间】:2015-01-21 08:45:41
【问题描述】:
我想做一个完整的集成测试,它使用将调用其他服务的服务(我使用的是 grails 2.4.3)。
这一切都很好,但是当一个服务中有一个服务时,它只会 2 级深度并且它不会更深。
问题是:如何使测试使用所有必要的子服务
class ImportServiceTests extends GroovyTestCase {
def grailsApplication
def fatherService
def setup() {
}
def cleanup() {
}
void 'test1'() {
String a= fatherService.function() // ->subService -> null
}
}
【问题讨论】:
-
使用 grails 2.4.x spock 是默认的测试框架,您的集成规范应该扩展 grails.test.spock.IntegrationSpec。你对这个基类有同样的问题吗?
-
是的,扩展 grails.test.spock.IntegrationSpec 也会发生同样的情况
-
我们没有这样的问题。你能附上你的项目吗?至少给出被测试的服务和方法的代码。
标签: grails testing groovy integration-testing