tednaleid/build-test-data — pull request #33 by gregopet (2014-07-10 12:15:48+00:00)
Title: Plugin causes exceptions when HibernateTestMixin is also used on a test

This is (a probably naive) attempt to enable using both the build-test-data plugin as well as the new HibernateTestMixin mixin for Grails.

I love the plugin's functionality but some tests do not work properly with Grails' mocked ORM (a named query in my case). That's why I tried using the new [HibernateTestMixin](http://grails.org/doc/latest/guide/testing.html#unitTestingDomains) annotation (at least it is new to me..) and my test was now working - but the ones using the `@Build` annotation suddenly failed with the following exception under Grails 2.4.2:
```
| org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.grails.datastore.mapping.simple.SimpleMapDatastore] is defined
at grails.test.mixin.domain.DomainClassUnitTestMixin.getSimpleDatastore(DomainClassUnitTestMixin.groovy:71)
at grails.test.mixin.domain.DomainClassUnitTestMixin.mockDomains(DomainClassUnitTestMixin.groovy:81)
at grails.buildtestdata.mixin.BuildTestDataUnitTestMixin.mockGrailsDomainClasses(BuildTestDataUnitTestMixin.groovy:133)
at grails.buildtestdata.mixin.BuildTestDataUnitTestMixin.mockForBuild(BuildTestDataUnitTestMixin.groovy:75)
at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
at org.spockframework.runtime.extension.builtin.JUnitFixtureMethodsExtension$FixtureType$FixtureMethodInterceptor.intercept(JUnitFixtureMethodsExtension.java:145)
at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:84)
at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
at org.spockframework.runtime.extension.MethodInvocation.invokeTargetMethod(MethodInvocation.java:91)
at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:85)
at org.spockframework.runtime.extension.builtin.AbstractRuleInterceptor$1.evaluate(AbstractRuleInterceptor.java:37)
at grails.test.runtime.TestRuntimeJunitAdapter$1$2.evaluate(TestRuntimeJunitAdapter.groovy:48)
at org.spockframework.runtime.extension.builtin.TestRuleInterceptor.intercept(TestRuleInterceptor.java:38)
at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:84)
at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
at org.spockframework.runtime.extension.MethodInvocation.invokeTargetMethod(MethodInvocation.java:91)
at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:85)
at org.spockframework.runtime.extension.builtin.AbstractRuleInterceptor$1.evaluate(AbstractRuleInterceptor.java:37)
at grails.test.runtime.TestRuntimeJunitAdapter$3$4.evaluate(TestRuntimeJunitAdapter.groovy:74)
at org.spockframework.runtime.extension.builtin.ClassRuleInterceptor.intercept(ClassRuleInterceptor.java:38)
at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:84)
```

The patch is my attempt at solving this issue (though I'm not intimately familiar with Grails' internals so a better solution may well exist).