IntegrationSpec with Custom plugin

49 views
Skip to first unread message

clr meno

unread,
May 8, 2017, 9:25:01 AM5/8/17
to Grails Dev Discuss
I have moved all shared service files to a custom plugin and I am including it in the applications that needs these shared files, through BuildConfig.groovy. I am using Grails 2.4.4. But one of the service file has Integration tests written which is extending grails.test.spock.IntegrationSpec. On running this Integration test case it fails indicating that grailsApplication is missing. I don't have an applicationContext file as it is a plugin and not an application. Is there a way I could get the Integration test case to execute successfully with in the plugin.



Following is the error:

Fatal error running tests: Error creating bean with name 'grailsApplication': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.codehaus.groovy.grails.commons.DefaultGrailsApplication]: Constructor threw exception; nested exception is org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: resources (Use --stacktrace to see the full trace)
.Tests FAILED 

clr meno

unread,
May 8, 2017, 9:27:13 AM5/8/17
to Grails Dev Discuss
Any advise is much appreciated!

clr meno

unread,
May 8, 2017, 12:39:43 PM5/8/17
to Grails Dev Discuss
Is there anyway to run Integration Tests in the custom plugin for service classes present in the plugin

Jeff Scott Brown

unread,
May 8, 2017, 1:52:12 PM5/8/17
to Grails Dev Discuss
On 8 May 2017, at 11:39, clr meno wrote:

> Is there anyway to run Integration Tests in the custom plugin for
> service
> classes present in the plugin
>

Yes.

If you could share a project which demonstrates the problem that you
described earlier in the thread, that would make it easier to
troubleshoot.




JSB

--
Jeff Scott Brown
OCI Grails Practice Lead
Principal Software Engineer

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

clr meno

unread,
May 8, 2017, 7:49:39 PM5/8/17
to Grails Dev Discuss
Thanks for your response Jeff!

I followed the following steps and got the exception given below when I ran the Integration test case:
1)  grails create-plugin example
2)  created a dummy domain class Book
3)grails create-integration-test book
4)Executed the integration test file


On running the integration test case file "BookIntegrationSpec" (extends IntegrationSpec) the following error gets thrown:

 "java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first

at grails.util.Holders.getApplicationContext(Holders.java:97)
at grails.test.spock.IntegrationSpec.$spock_initializeSharedFields(IntegrationSpec.groovy:41)" gets thrown.

Jeff Scott Brown

unread,
May 10, 2017, 2:42:21 PM5/10/17
to Grails Dev Discuss
On 8 May 2017, at 18:49, clr meno wrote:

> Thanks for your response Jeff!
>
> I followed the following steps and got the exception given below when
> I ran
> the Integration test case:
> 1) grails create-plugin example
> 2) created a dummy domain class Book
> 3)grails create-integration-test book
> 4)Executed the integration test file
>
>
> On running the integration test case file "BookIntegrationSpec"
> (extends
> IntegrationSpec) the following error gets thrown:
>
> "java.lang.IllegalStateException: Could not find ApplicationContext,
> configure Grails correctly first
>
> at grails.util.Holders.getApplicationContext(Holders.java:97)
> at
> grails.test.spock.IntegrationSpec.$spock_initializeSharedFields(IntegrationSpec.groovy:41)"
> gets thrown.
>

Earlier in the thread you were talking about testing services. The
above doesn’t say anything about services. The test at
https://github.com/jeffbrown/clrmeno/blob/master/test/integration/demo/BookServiceIntegrationSpec.groovy
seems to run fine. (Note that is a Grails 2.4.4 project so you cannot
use Java 8)

Without knowing what you are trying to do, it can be difficult to say
what is wrong. I suspect there is something wrong in the project but
without being able to reproduce the problem, I can’t say. As I said
in my earlier note, if you could share a project which demonstrates the
problem that you described earlier in the thread, that would make it
easier to troubleshoot. That would make better use of other people’s
time rather than having folks try to guess at what you are doing.
Reply all
Reply to author
Forward
0 new messages