vendredi 25 septembre 2015

grailsApplication not available in Domain class when running all Integration tests

I'm running in to a problem when running Integration tests in Grails. One of the Domain classes in the project has a method that accesses the grailsApplication.config property. We have an integration test for one of our services that calls this method in the Domain class. When the test is run on its own using the command

grails test-app integtration: com.project.MyTestSpec

the test runs fine and the domain class can access grailsApplication. However when the whole test suite is ran using

grails test-app integration

then the test fails with the error

java.lang.NullPointerException: Cannot get property 'config' on null object

when trying to access grailsApplication.config. It seems that when the tests are all run together grailsApplication is not being injected in to the Domain class. Has anyone come across this issue before?

From what I have read it seems to be a test pollution issue but as there is no setup happening in each integration test the problem is hard to track down.

Aucun commentaire:

Enregistrer un commentaire