【发布时间】:2015-06-04 07:41:25
【问题描述】:
我有依赖服务的服务,例如:
class ParserService {
def depService;
private def parseLine(lineParts) {
...
def set = depService.findItemByName(tmpModule.name);//depService == null
...
我尝试像这样实现集成测试:
@TestFor(ParserService)
class ParserServiceTest extends IntegrationSpec {
def "should not parse comment"() {
when:
...
def resultList = service.parseAnnotations(inputStream);
resources.groovy:
beans = {
}
我有 NullPointerException: depService - null
【问题讨论】:
-
你有一个叫DepService的服务吗?确保您的拼写正确
-
我有 depService。我可以运行应用程序(不是测试) - 一切正常。
-
也尝试发布更多代码,您如何调用服务(使用服务)
标签: grails integration-testing spock