I am trying to test the code used in src / groovy with Spock. The code I'm testing refers to grailsApplication. Since it's in src / groovy, I used dependency injection to inject grailsApplication into a bean, for example:
ticketRequestEmailInfo(TicketRequestEmailInfo) {
grailsApplication = ref('grailsApplication')
}
The problem I ran into is when the test code falls into a line of code that references grailsApplication, I get a NullPointerException:
java.lang.NullPointerException: Cannot get property 'config' on null object
My test class has the following:
@TestMixin(GrailsUnitTestMixin)
class TicketRequestEmailInfoSpec extends Specification {
def setup() {
grailsApplication.config.acme.purchase.trsUrlBase = "http://localhost:8082/purchase/order/"
}
Does anyone have any suggestions?
source
share