MockApplicationContext context = new MockApplicationContext();
MockServletContext servletContext = new MockServletContext();
servletContext.setAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT,context);
GrailsApplication app = new DefaultGrailsApplication(classes,gcl);
app.initialise();
context.registerMockBean(GrailsApplication.APPLICATION_ID,app);
GrailsClass[] controllers = app.getArtefacts(ControllerArtefactHandler.TYPE);
for (int i = 0; i < controllers.length; i++) {
context.registerMockBean(controllers[i].getFullName(), controllers[i].newInstance());