I'm trying to test some code that's in src/groovy using Spock. The code I'm testing references grailsApplication. Since it's in src/groovy, I used dependency injection to inject grailsApplication into the bean, like so:
ticketRequestEmailInfo(TicketRequestEmailInfo) {
grailsApplication = ref('grailsApplication')
}
The problem I'm having is when the test code hits the line of code that references grailsApplication, I'm getting 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?