Saturday, July 23, 2011

MissingMethodException when running test with baseUrl in Grails

Running functional test with baseUrl option can end with exception:

Error executing script TestApp: groovy.lang.MissingMethodException: No signature of method: static java.lang.System.setProperty() is applicable for argument types: (java.lang.String, java.lang.Boolean)
Possible solutions: setProperty(java.lang.String, java.lang.String), getProperty(java.lang.String), getProperty(java.lang.String, java.lang.String), hasProperty(java.lang.String), getProperties(), getP
groovy.lang.MissingMethodException: No signature of method: static java.lang.System.setProperty() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [grails.testing.functio
Possible solutions: setProperty(java.lang.String, java.lang.String), getProperty(java.lang.String), getProperty(java.lang.String, java.lang.String), hasProperty(java.lang.String), getProperties(), getP
        at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:391)
        at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
        at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
        at gant.Gant.withBuildListeners(Gant.groovy:427)
        at gant.Gant.this$2$withBuildListeners(Gant.groovy)
        at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
        at gant.Gant.dispatch(Gant.groovy:415)
        at gant.Gant.this$2$dispatch(Gant.groovy)
        at gant.Gant.invokeMethod(Gant.groovy)
        at gant.Gant.executeTargets(Gant.groovy:590)
        at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: groovy.lang.MissingMethodException: No signature of method: static java.lang.System.setProperty() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [grails.test
Possible solutions: setProperty(java.lang.String, java.lang.String), getProperty(java.lang.String), getProperty(java.lang.String, java.lang.String), hasProperty(java.lang.String), getProperties(), getP
        at _GrailsTest_groovy$_run_closure11.doCall(_GrailsTest_groovy:366)
        at _GrailsTest_groovy$_run_closure11.doCall(_GrailsTest_groovy)
        at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:184)
        at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:174)
        at TestApp$_run_closure1.doCall(TestApp.groovy:82)
        at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
        ... 10 more

This can be easily worked around by running tests in interactive mode. Just run:

grails interactive

and you can execute your tests from there like:

test test-app functional: MyTests -baseUrl="http://..."

Apart from that it works, this gives also additional benefits like: you can debug with single attachment from IDE (remember to use grails-debug); also you can run grails application before executing tests which allows to use in-memory db with functional testing.

No comments:

Post a Comment