Grails 1.3.x Unit Tests

Hi,

Just wondering if IntelliJ 9.0.2 (or any other version) handles executing Grails unit tests correctly... I ask this because I've written my test using Unit 4 (which is new in Grails 1.3), instead of Grails 1.3 . IntelliJ doesn't seem to like this, exiting with the following:

/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java -Xmx256M -Dgrails.home=/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1 -Dbase.dir=/Volumes/allseas/allseas-ui -Dtools.jar=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/lib/tools.jar -Dgroovy.starter.conf=/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/conf/groovy-starter.conf -Dgrails.build.listeners=org.jetbrains.groovy.grails.tests.GrailsIdeaTestListener -Dfile.encoding=MacRoman -classpath /Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/lib/groovy-all-1.7.2.jar:/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/dist/grails-bootstrap-1.3.1.jar org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf /Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/conf/groovy-starter.conf --classpath /Applications/IntelliJ IDEA 9.0.2.app/plugins/GrailsGriffon/lib/groovy_mvc_rt.jar:/Users/erikp/.grails/1.2.2/projects/allseas-ui/plugins/tomcat-1.2.2/lib:/Users/erikp/.grails/1.2.2/projects/allseas-ui/plugins/searchable-0.5.5/lib:/Users/erikp/.grails/1.2.2/projects/allseas-ui/plugins/quartz-0.4.2/lib:/Users/erikp/.grails/1.2.2/projects/allseas-ui/plugins/codenarc-0.5/lib:/Users/erikp/.grails/1.2.2/projects/allseas-ui/plugins/quartz-0.4.2/lib/quartz-1.7.3.jar:/Users/erikp/.grails/1.2.2/projects/allseas-ui/plugins/codenarc-0.5/lib/CodeNarc-0.8.1.jar:. test-app -unit allseas.ui.RedirectTagLib.shouldRedirect
Testing started at 1:46 PM ...
Welcome to Grails null - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1
Base Directory: /Volumes/allseas/allseas-ui
maven local repo is not set, using default
Resolving dependencies...
:: problems summary ::
:::: WARNINGS
module not found: org.grails#grails-docs;null
==== grailsPlugins: tried
-- artifact org.grails#grails-docs;null!grails-docs.jar:
/Volumes/allseas/allseas-ui/lib/grails-docs-null.jar
==== grailsHome: tried
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/lib/grails-docs-null.xml
-- artifact org.grails#grails-docs;null!grails-docs.jar:
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/lib/grails-docs-null.jar
==== grailsHome: tried
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/dist/grails-docs-null.xml
-- artifact org.grails#grails-docs;null!grails-docs.jar:
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/dist/grails-docs-null.jar
==== grailsHome: tried
-- artifact org.grails#grails-docs;null!grails-docs.jar:
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/plugins/grails-grails-docs-null.jar
==== localMavenResolver: tried
/Users/erikp/.m2/repository/org/grails/grails-docs/null/grails-docs-null.pom
-- artifact org.grails#grails-docs;null!grails-docs.jar:
/Users/erikp/.m2/repository/org/grails/grails-docs/null/grails-docs-null.jar
http://repo1.maven.org/maven2/org/grails/grails-docs/null/grails-docs-null.pom
-- artifact org.grails#grails-docs;null!grails-docs.jar:
http://repo1.maven.org/maven2/org/grails/grails-docs/null/grails-docs-null.jar
module not found: org.grails#grails-bootstrap;null
==== grailsPlugins: tried
-- artifact org.grails#grails-bootstrap;null!grails-bootstrap.jar:
==== grailsHome: tried
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/lib/grails-bootstrap-null.xml
-- artifact org.grails#grails-bootstrap;null!grails-bootstrap.jar:
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/lib/grails-bootstrap-null.jar
==== grailsHome: tried
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/dist/grails-bootstrap-null.xml
-- artifact org.grails#grails-bootstrap;null!grails-bootstrap.jar:
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/dist/grails-bootstrap-null.jar
==== grailsHome: tried
-- artifact org.grails#grails-bootstrap;null!grails-bootstrap.jar:
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/plugins/grails-grails-bootstrap-null.jar
==== localMavenResolver: tried
/Users/erikp/.m2/repository/org/grails/grails-bootstrap/null/grails-bootstrap-null.pom
-- artifact org.grails#grails-bootstrap;null!grails-bootstrap.jar:
/Users/erikp/.m2/repository/org/grails/grails-bootstrap/null/grails-bootstrap-null.jar
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/lib/grails-scripts-null.xml
-- artifact org.grails#grails-scripts;null!grails-scripts.jar:
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/lib/grails-scripts-null.jar
==== grailsHome: tried
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/dist/grails-scripts-null.xml
-- artifact org.grails#grails-scripts;null!grails-scripts.jar:
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/dist/grails-scripts-null.jar
==== grailsHome: tried
-- artifact org.grails#grails-scripts;null!grails-scripts.jar:
/Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/plugins/grails-grails-scripts-null.jar
==== localMavenResolver: tried
/Users/erikp/.m2/repository/org/grails/grails-scripts/null/grails-scripts-null.pom
-- artifact org.grails#grails-scripts;null!grails-scripts.jar:
/Users/erikp/.m2/repository/org/grails/grails-scripts/null/grails-scripts-null.jar
::::::::::::::::::::::::::::::::::::::::::::::
::          UNRESOLVED DEPENDENCIES         ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.grails#grails-bootstrap;null: not found
:: org.grails#grails-core;null: not found
:: org.grails#grails-crud;null: not found
:: org.grails#grails-gorm;null: not found
:: org.grails#grails-resources;null: not found
:: org.grails#grails-spring;null: not found
:: org.grails#grails-web;null: not found
:: org.grails#grails-test;null: not found
::::::::::::::::::::::::::::::::::::::::::::::
Dependencies resolved in 59875ms.
Running script /Users/erikp/Downloads/Web/Grails/grails-1.3.1/grails-1.3.1/scripts/TestApp.groovy
Error executing script TestApp: startup failed:
TestApp: 10: unable to resolve class org.codehaus.groovy.grails.commons.GrailsApplication
@ line 10, column 1.
TestApp: 2: unable to resolve class grails.util.GrailsWebUtil
@ line 2, column 1.
TestApp: 12: unable to resolve class org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes
@ line 12, column 1.
TestApp: 11: unable to resolve class org.codehaus.groovy.grails.support.PersistenceContextInterceptor
@ line 11, column 1.
TestApp: 17: unable to resolve class grails.util.GrailsUtil
@ line 17, column 1.
5 errors
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
TestApp: 10: unable to resolve class org.codehaus.groovy.grails.commons.GrailsApplication
@ line 10, column 1.
TestApp: 2: unable to resolve class grails.util.GrailsWebUtil
@ line 2, column 1.
TestApp: 12: unable to resolve class org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes
@ line 12, column 1.
TestApp: 11: unable to resolve class org.codehaus.groovy.grails.support.PersistenceContextInterceptor
@ line 11, column 1.
TestApp: 17: unable to resolve class grails.util.GrailsUtil
@ line 17, column 1.
5 errors
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:847)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:519)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:495)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:472)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:456)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121)
at gant.Gant.compileScript(Gant.groovy:635)
at gant.Gant.this$2$compileScript(Gant.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1067)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1003)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1067)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:159)
at gant.Gant$_closure1.doCall(Gant.groovy:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:159)
at gant.Gant$_closure1.call(Gant.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1067)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:743)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:726)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:163)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeClosure(ScriptBytecodeAdapter.java:573)
at gant.Gant.loadScript(Gant.groovy:266)
at gant.Gant$loadScript.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at gant.Gant.loadScript(Gant.groovy:248)
at org.codehaus.groovy.grails.cli.GrailsScriptRunner.callPluginOrGrailsScript(GrailsScriptRunner.java:529)
at org.codehaus.groovy.grails.cli.GrailsScriptRunner.executeCommand(GrailsScriptRunner.java:317)
at org.codehaus.groovy.grails.cli.GrailsScriptRunner.main(GrailsScriptRunner.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:226)
at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:251)
Error executing script TestApp: startup failed:
TestApp: 10: unable to resolve class org.codehaus.groovy.grails.commons.GrailsApplication
@ line 10, column 1.
TestApp: 2: unable to resolve class grails.util.GrailsWebUtil
@ line 2, column 1.
TestApp: 12: unable to resolve class org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes
@ line 12, column 1.
TestApp: 11: unable to resolve class org.codehaus.groovy.grails.support.PersistenceContextInterceptor
@ line 11, column 1.
TestApp: 17: unable to resolve class grails.util.GrailsUtil
@ line 17, column 1.
5 errors
Empty test suite.

Process finished with exit code 1

5 comments

Hmm, to comment on that: IntelliJ imported the wrong Test class: it was org.framework.Test (a class) instead of org.junit.Test (an annotation).

Now IntelliJ just says:

Process finished with exit code 255

junit.framework.AssertionFailedError: No tests found in allseas.ui.RedirectTagLibTests
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)

So it seems there is no support (yet?) for Junit 4, only for Junit 3.8

0

First, it appears that IDEA again has old plugin/Grails dependencies in
either your main application module, or its -grailsPlugins module.
Second, in 1.3 Grails has changed its test running command line syntax,
so IDEA 9.0.2 doesn't know lot about it, you can edit it by hand in the
run configuration (unit:unit instead of -unit). Both problems should be
fixed in the next 9.0.3 EAP.

0

Yes, JUnit4 Grails tests are not supported yet (but they will be). Where
was the reference located which was imported wrongly? Was at least the
choice given to you?

0

Hi Peter,

Well, I'm not sure 100%, but I think I just types @Test, pressed Alt+Enter and went on. As far as I know, IntelliJ gave me only 1 choice, but I'm not 100% sure about that. ATM, I'm not using the @Test annotation but I reverted back to methods starting with test.. However, it would be nice to have to have it working with @Test, so I can rename my methods to 'should.....' . I know, not a biggy, just reads better.

Any idea when the 9.0.3 EAP will be available, so I can test it? I'll check out the old Grails 1.2.2 reference in my workspace btw. I upgraded the project from the commandline, and then upgraded the Grails support in IntelliJ (upgrade Grails or something) after that, but only the main project got updated, not the plugin modules, so I did that by hand (removed Grails 1.2.2, added Grails 1.3.1 support). I haven't restarted IntelliJ since then, so might be solved by a simple restart.

Thanks for the support,

Erik

0

EAPs are usually on Fridays, so let's hope the next one will be this Friday.

0

Please sign in to leave a comment.