Testing 集成测试中的服务注入问题

Testing 集成测试中的服务注入问题,testing,grails,integration-testing,grails-2.1,Testing,Grails,Integration Testing,Grails 2.1,我有一个与此代码类似的问题: @TestFor(DocumentosService) class DocumentosServiceTest extends GroovyTestCase { def myService void testEnvioEmailDocumento() { assert myService != null } } 执行测试时,myService始终为null。 为什么myService没有被注入? 我正在使用Grails2.

我有一个与此代码类似的问题:

@TestFor(DocumentosService)
class DocumentosServiceTest extends GroovyTestCase  {
    def myService
    void testEnvioEmailDocumento() {
        assert myService != null
    }
}
执行测试时,myService始终为null。 为什么myService没有被注入? 我正在使用Grails2.1

根据Burt Beckwith的指示更新(2013年2月6日):

class DocumentosServiceTest extends GroovyTestCase  {
    def myService
    def documentosService
    void testEnvioEmailDocumento() {
        assert documentosService != null
        assert myService != null
    }
}

现在documentosService也为空。

删除
@TestFor(documentosService)
,因为这是用于单元测试的。为服务添加常规依赖项注入,在这种情况下,它看起来将是
def documentoservice

,这根本没有效果。我将根据您的建议编辑这个问题。因此服务的类名是
DocumentosService
,它位于
grails app/services
下,测试类位于
src/test/integration
下?试着运行
grailsclean
——它通常会修复类似这样的奇怪问题。
grailsclean
没有帮助,但是测试在
test/integration
下,没有在
src/test/integration
下。如果我把它放在
src/test/integration
中,我不能从GGTS运行它。我不能从命令行运行测试。还要指出,命令行在
test
文件夹下生成的测试文件不在
src/test
下。