Grails unit tests: Accessing defined beans via grailsApplication
问题 I have some (non-Grails-artifact) classes that access the service layer beans via passing around the grailsApplication object. However I'm having trouble unit testing the classes implemented in this way. Why doesn't the bean get registered in the main context? @TestMixin(GrailsUnitTestMixin) class ExampleTests { void setUp() {} void tearDown() {} void testSomething() { defineBeans { myService(MyService) } assert grailsApplication.mainContext.getBean("myService") != null } } The above code