When running tests from the Gradle build tool I've been having
problems with the classnames of a test which seems to be the hashcode.
Details of the problem here:
Is there a better way than implementing my own runner to fix this?
/Jeppe
<?xml version="1.0" encoding="UTF-8"?>
<testsuite errors="0" failures="0" hostname="jnmmbp.local"
name="fleetzone.unittest.POIUnitTest" tests="7" time="0.05"
timestamp="2011-03-24T10:09:32">
<properties />
<testcase classname="org.specs.runner.ExampleTestCase" name="be
readable" time="0.0" />
<testcase classname="org.specs.runner.ExampleTestCase" name="read
all sheets" time="0.0" />
<testcase classname="org.specs.runner.ExampleTestCase" name="have
the name Sheet1" time="0.0" />
<testcase classname="org.specs.runner.ExampleTestCase" name="have
correct column headers" time="0.0" />
<testcase classname="org.specs.runner.ExampleTestCase" name="have
correct row 1 values" time="0.0" />
<testcase classname="org.specs.runner.ExampleTestCase" name="have
correct row 2 values" time="0.0" />
<testcase classname="org.specs.runner.ExampleTestCase" name="have
correct row 3 values" time="0.0010" />
<system-out><![CDATA[]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
> (a link to a sample project would be nice so I could also test how
> specs2 is behaving)
I'll try to create a test project. I'll be back
/Jeppe
I've updated my Lift sample here: https://github.com/jeppenejsum/liftstart
To run tests, just clone and do "./gradlew test"
Output is in build/reports/tests/index.html
/Jeppe
Maybe it's not clear from the example, but all the specs have the same
class "org.specs.runner.ExampleTestCase"
There's no ExampleTestCase in the source, making it very difficult to
figure which test is being run.
While example.snippet.HelloWorldTestSpecsAsTest shows up in the
results, there are no test cases attached.
/Jeppe
Thanks for looking into this ;-)
Just tried to compile my test project and it seems the compiler crashes:
15:18:07.601 [ERROR] [system.err] error: error while loading
HasResults, oversubscribed literal/length tree
15:18:08.110 [ERROR] [system.err] one error found
15:18:08.226 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: :
Compile failed with 1 error; see the compiler error output for
details.
15:18:08.227 [ERROR] [org.gradle.BuildExceptionReporter] at
scala.tools.ant.Scalac.error(Scalac.scala:460)
15:18:08.227 [ERROR] [org.gradle.BuildExceptionReporter] at
scala.tools.ant.Scalac.executeInternal(Scalac.scala:650)
15:18:08.227 [ERROR] [org.gradle.BuildExceptionReporter] at
scala.tools.ant.Scalac.execute(Scalac.scala:586)
15:18:08.228 [ERROR] [org.gradle.BuildExceptionReporter] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
15:18:08.228 [ERROR] [org.gradle.BuildExceptionReporter] at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
15:18:08.228 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:71)
15:18:08.229 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.project.AntBuilderDelegate.nodeCompleted(DefaultIsolatedAntBuilder.groovy:137)
15:18:08.240 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.tasks.scala.AntScalaCompiler$_execute_closure1.doCall(AntScalaCompiler.groovy:56)
15:18:08.241 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:61)
15:18:08.241 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:31)
15:18:08.242 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.util.ConfigureUtil$configure.call(Unknown Source)
15:18:08.242 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.project.DefaultIsolatedAntBuilder.execute(DefaultIsolatedAntBuilder.groovy:98)
15:18:08.242 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.project.IsolatedAntBuilder$execute.call(Unknown
Source)
15:18:08.243 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.tasks.scala.AntScalaCompiler.execute(AntScalaCompiler.groovy:53)
15:18:08.243 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.tasks.scala.DefaultScalaJavaJointCompiler.execute(DefaultScalaJavaJointCompiler.java:75)
15:18:08.243 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.tasks.compile.IncrementalJavaSourceCompiler.execute(IncrementalJavaSourceCompiler.java:73)
15:18:08.244 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.tasks.scala.ScalaCompile.compile(ScalaCompile.java:90)
15:18:08.244 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158)
15:18:08.245 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
15:18:08.245 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.tasks.scala.ScalaCompile_Decorated.invokeMethod(Unknown
Source)
15:18:08.245 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
15:18:08.246 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:131)
15:18:08.246 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:130)
15:18:08.247 [ERROR] [org.gradle.BuildExceptionReporter] at
org.gradle.api.internal.tasks.DefaultTaskExecuter.executeActions(DefaultTaskExecuter.java:58)
15:18:08.247 [ERROR] [org.gradle.BuildExceptionReporter] ... 27 more
When compiling our real project, gradle fails during testing
Caused by: java.lang.NullPointerException
at org.gradle.api.internal.tasks.testing.junit.JUnitXmlReportGenerator.output(JUnitXmlReportGenerator.java:59)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.BroadcastDispatch.dispatch(BroadcastDispatch.java:88)
It looks like it tries to generate an XML file for each specification,
but the XML files don't contain any tests. Eg here's an example:
<?xml version="1.0" encoding="UTF-8"?>
<testsuite errors="0" failures="0" hostname="jnmmbp.local" name="read
all sheets" tests="1" time="0.0" timestamp="2011-03-25T14:06:45">
<properties />
<system-out><![CDATA[]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
/Jeppe
Just tried deleting both the gradle cache and the build dir same
result. (I'm on OS X, dunno if that makes a difference)
> The test project is ok here (and it's even working with specs2 now!).
But did you try it with specs (not specs2) also?
That XML file looks fine.
> That being said, the NPE during the test execution might mean that
> there is still a nasty corner case.
But I think this may be caused by all the XML files being empty in my case.....
/Jeppe
Great, works now. Thanks.
One minor nitpick is that the timing info on testcase seems wrong:
<testsuite errors="0" failures="0" hostname="jnmmbp.local"
name="fleetzone.integrationtest.excel.ExcelImporterUnitTest" tests="6"
time="52.737" timestamp="2011-03-28T09:07:10">
<properties />
<testcase classname="fleetzone.integrationtest.excel.ExcelImporterSpec$"
name="parse template correctly" time="0.0030" />
<testcase classname="fleetzone.integrationtest.excel.ExcelImporterSpec$"
name="parse template correctly" time="0.0" />
<testcase classname="fleetzone.integrationtest.excel.ExcelImporterSpec$"
name="parse template with warnings correctly" time="0.0" />
<testcase classname="fleetzone.integrationtest.excel.ExcelImporterSpec$"
name="parse Dagrofa correctly twice" time="0.0010" />
<testcase classname="fleetzone.integrationtest.excel.ExcelImporterSpec$"
name="parse COOP B correctly" time="0.0" />
<testcase classname="fleetzone.integrationtest.excel.ExcelImporterSpec$"
name="parse COOP A correctly" time="0.0010" />
....
The suite takes 52 seconds (which is correct), but it seem each test
case is off.
/Jeppe
Ohh, another minor detail :-)
We have something like this:
"An Excel 2007 file" ->-(excel2007) should {
behave like "An Excel 2003 file"
}
The output doesn't seem to include this info, it repeats the testcases
twice with the same name:
<testcase classname="fleetzone.integrationtest.excel.ExcelParserSpec$"
name="be readable" time="0.0" />
...
<testcase classname="fleetzone.integrationtest.excel.ExcelParserSpec$"
name="be readable" time="0.0" />
/Jeppe
Ok, will have a look at some point. Is there a "how to upgrade" doc
somewhere or can they both exist at the same time in a project?
/Jeppe
Ohh, now just tried in IntelliJ and now it cannot find any tests :-(
I'll have to run, but will try old version later just to verify that
it is indeed the new stuff that breaks this....
/Jeppe
Oh never mind....IntelliJ crashed during compilation. Everything works
fine after full rebuild, I'll shut up now and go home :-)
/Jeppe