Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with customized template report creation #254

Closed
ralbuh opened this issue Aug 17, 2023 · 7 comments
Closed

Error with customized template report creation #254

ralbuh opened this issue Aug 17, 2023 · 7 comments
Labels

Comments

@ralbuh
Copy link

ralbuh commented Aug 17, 2023

We are using customized templates (actually an adoc conversion of provided md templates from this repo) for a while.
Recently we upgraded to java 17 and newest springboot and the report generation started failing with the stated error.

We tried converting back to the included md templates in this repo (https://github.com/renatoathaydes/spock-reports/blob/master/src/main/resources/templateReportCreator/spec-template.md & https://github.com/renatoathaydes/spock-reports/blob/master/src/main/resources/templateReportCreator/summary-template.md) but same error there.

Our config:

spockReports {
  set 'com.athaydes.spockframework.report.IReportCreator': 'com.athaydes.spockframework.report.template.TemplateReportCreator'
  set 'com.athaydes.spockframework.report.template.TemplateReportCreator.specTemplateFile': '/templates/spec-template.md'
  set 'com.athaydes.spockframework.report.template.TemplateReportCreator.reportFileExtension': 'md'
  set 'com.athaydes.spockframework.report.template.TemplateReportCreator.summaryTemplateFile': '/templates/summary-template.md'
  set 'com.athaydes.spockframework.report.template.TemplateReportCreator.summaryFileName': 'index.md'
  set 'com.athaydes.spockframework.report.outputDir': 'src/main/asciidoc/spock-reports'
  set 'com.athaydes.spockframework.report.hideEmptyBlocks': false
}

Error:

2023-08-17 13:47:12.946  WARN [           main] c.a.s.r.t.TemplateReportCreator          : Unexpected error creating report
 java.lang.IllegalArgumentException: Cannot compare java.util.ArrayList with value '[]' and java.lang.Integer with value '0'
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareToWithEqualityCheck(DefaultTypeTransformation.java:824)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareTo(DefaultTypeTransformation.java:753)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareTo(ScriptBytecodeAdapter.java:773)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareGreaterThan(ScriptBytecodeAdapter.java:856)
        at groovy.tmp.templates.GStringTemplateScript9$_getTemplate_closure1$_closure3.doCall(GStringTemplateScript9.groovy:34)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:279)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)
        at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
        at groovy.tmp.templates.GStringTemplateScript9$_getTemplate_closure1.doCall(GStringTemplateScript9.groovy:61)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:279)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)
        at groovy.lang.Closure.call(Closure.java:418)
        at groovy.lang.Closure$WritableClosure.writeTo(Closure.java:921)
        at groovy.lang.Closure$WritableClosure.toString(Closure.java:1064)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:198)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:75)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:130)
        at com.athaydes.spockframework.report.template.TemplateReportCreator.reportFor(TemplateReportCreator.groovy:126)
        at com.athaydes.spockframework.report.template.TemplateReportCreator$reportFor.callCurrent(Unknown Source)
        at com.athaydes.spockframework.report.template.TemplateReportCreator.createReportFor(TemplateReportCreator.groovy:99)
        at com.athaydes.spockframework.report.IReportCreator$createReportFor.call(Unknown Source)
        at com.athaydes.spockframework.report.SpecInfoListener.createReport(SpockReportExtension.groovy:283)
        at com.athaydes.spockframework.report.SpecInfoListener.afterSpec(SpockReportExtension.groovy:194)
        at org.spockframework.runtime.MasterRunListener.afterSpec(MasterRunListener.java:64)
        at org.spockframework.runtime.MasterRunSupervisor.afterSpec(MasterRunSupervisor.java:128)
        at org.spockframework.runtime.PlatformSpecRunner.runSpec(PlatformSpecRunner.java:56)
        at org.spockframework.runtime.SpecNode.around(SpecNode.java:63)
        at org.spockframework.runtime.SpecNode.around(SpecNode.java:11)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
        at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
        at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
@renatoathaydes
Copy link
Owner

The default MD template is tested in every build.
Are you sure there's an error even with the MD template from this repo?
Are you on the latest version? Please make sure you are, because on Java 17, you need some fairly recent version... see the version matrix in the README page.

@ralbuh
Copy link
Author

ralbuh commented Aug 18, 2023

Yeah versions are correct afaik.

I just generated a dummy project from spring initializr and added minimal setup and one dummy test. Here you can see the same error.
https://github.com/ralbuh/spock-report-issue-254

If you run a mvn clean install on that demo project you can see the same error message

@renatoathaydes
Copy link
Owner

The MD template seems to have a bug:

if ( feature.attachments.size > 0 )

On line 32 for me...
Can you change that to this:

if ( feature.attachments.size() > 0 )

And try again?

@ralbuh
Copy link
Author

ralbuh commented Aug 18, 2023

Yeah that solved it. Very nice, thanks for you help again and you quick reply!

@ralbuh ralbuh closed this as completed Aug 18, 2023
@renatoathaydes
Copy link
Owner

I will keep this open as I'll have to release a fix.
There's another bug I wanted to fix as well so it's time for a release anyway.
Glad it works for you.

ralbuh added a commit to ralbuh/spock-report-issue-254 that referenced this issue Aug 18, 2023
ralbuh added a commit to ralbuh/spock-report-issue-254 that referenced this issue Aug 18, 2023
@renatoathaydes
Copy link
Owner

This line has been the same since 2016. There seems to be tests that check this. I just don't understand how this could break now, or how it was actually working?!

The code is printing "See: " if that condition is true:

        if ( feature.attachments.size > 0 ) {
            out << '\n#### ' << 'See:' << '\n\n'

There's a test that checks this: https://github.com/renatoathaydes/spock-reports/blob/master/src/test/resources/FakeTest.md (look for "See:")

So, this is actually working on my tests :D.

My guess is that you used a specific version of Groovy that made size stop working! Can you check which version you had running @ralbuh ?

renatoathaydes added a commit that referenced this issue Aug 21, 2023
(cherry picked from commit 9f23feb)
@renatoathaydes
Copy link
Owner

This fix is now released on versions 2.5.1-groovy-3.0 and 2.5.1-groovy-4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants