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.
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 bedef documentosService