Problems injecting services in integration test

298 Views Asked by At

I have a similar problem that Integration testing Grails services with injection with this code:

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

When the test is executed myService is always null. Why myService is not being injected? I'm using grails 2.1

Updated (2/6/2013) following Burt Beckwith's instructions:

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

Now documentosService is null too.

1

There are 1 best solutions below

4
Burt Beckwith On

Remove @TestFor(DocumentosService) since that's for unit tests. Add a regular dependency injection for the service, in this case it looks like it would be def documentosService