I get the following error...
Cannot get property 'grails' on null object
java.lang.NullPointerException: Cannot get property 'grails' on null object
at pcc.EmailSharerController.<init>(EmailSharerController.groovy)
at grails.test.MvcUnitTestCase.newInstance(MvcUnitTestCase.groovy:102)
at grails.test.ControllerUnitTestCase.super$6$newInstance(ControllerUnitTestCase.groovy)
at grails.test.ControllerUnitTestCase.newInstance(ControllerUnitTestCase.groovy:112)
at grails.test.ControllerUnitTestCase.setUp(ControllerUnitTestCase.groovy:55)
at pcc.EmailSharerControllerTests.super$7$setUp(EmailSharerControllerTests.groovy)
at pcc.EmailSharerControllerTests.setUp(EmailSharerControllerTests.groovy:12)
...when I run the unit test setUp() of my EmailSharerController
, even when it is reduced to this:
protected void setUp() {
super.setUp()
}
I have browsed the web and found nothing. I do not any guess from where it could come. Any help greatly apreciated :)
Problem was that Grails does not support the ConfigurationHolder object in unit tests. It is possible to solve it this way:
mockConfig("""
grails {
serverURL = 'my domain name'
}
""")
to call the grails.serverURL
property of Config.groovy for example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.