grailsApplication access in Grails unit Test

后端 未结 3 1674
猫巷女王i
猫巷女王i 2021-02-15 04:20

I am trying to write unit tests for a service which use grailsApplication.config to do some settings. It seems that in my unit tests that service instance could not access the c

3条回答
  •  遇见更好的自我
    2021-02-15 04:33

    Constructing grailsApp using DefaultGrailsApplication would work.

    class ZazzercodeUnitTestCase extends GrailsUnitTestCase {
        def grailsApplication = new org.codehaus.groovy.grails.commons.DefaultGrailsApplication()
        def chortIndex= grailsApplication.config.zazzercode.chortIndex
    }
    

提交回复
热议问题