1
我想做一个完整的集成测试,它使用将调用其他服务的服务(我使用的是grails 2.4.3)。 这一切都很好,但是当一个服务中有一个服务时,它只能通过2级深度和它不会更深入。
的问题是:如何让我的测试使用所必需的所有子服务Grails测试集成服务注入
class ImportServiceTests extends GroovyTestCase {
def grailsApplication
def fatherService
def setup() {
}
def cleanup() {
}
void 'test1'() {
String a= fatherService.function() // ->subService -> null
}
}
随着g rails 2.4.x spock是默认的测试框架,您的集成规范应该扩展grails.test.spock.IntegrationSpec。你对这个基类有同样的问题吗? – droggo 2015-01-21 11:34:55
是的,扩展grails.test.spock.IntegrationSpec – 2015-01-21 13:06:34
也是如此。我们没有这样的问题。你能够附加你的项目吗?至少给出经过测试的服务和方法的代码。 – droggo 2015-01-21 16:37:20