grails - How to access grailsApplication and ApplicationContext in Functional Tests -
i building grails rest application , have written functional tests using spock. note these functional tests rest services only.
class loginfunctionalspec extends specification { def setup() { // here want access grailsapplication.config } } i have tried following approaches:
- injecting grailsapplication (by defining class level variable), nothing get's injected.
- using applicationholder.application.config has been deprecated , suggested approach previous point.
- tried using plugin remote-control:1.4 although grails console showed plugin installed didn't find class remotecontrol. never sure of approach
- i tried reading grails-app/conf/config.groovy file (as explained here) got filenotfoundexception.
but none of them provide me grailsapplication.config inside functional test.
is there way achieve ?
update
@dmahapatro
i not using geb because testing rest services , there no browser automation required.
as said in point#1 grails application not being auto-injected.
class loginfunctionalspec extends specification { def grailsapplication def setup() { def port = grailsapplication.config.mongo.port //throws npe } } it throws npe saying config property being invoked on null object.
i think not need inject explicitly. grailsapplication available in tests default.
class loginfunctionalspec extends specification { def setup() { grailsapplication.config.blah //should work } } note-
spock not provide direct support functional tests. need use geb proper functional tests.
Comments
Post a Comment