renatoathaydes / spock-reports

This project creates a global extension to Spock to create test reports.
Apache License 2.0
273 stars 68 forks source link

When running the internal config loader with v2.3.0, then two warnings are shown and as a consequence the featureReportCss is not loaded #229

Closed iwt-ttaskov closed 2 years ago

iwt-ttaskov commented 2 years ago

Potential Bug:

These are the info messages in console:

2022-05-17 16:07:58,192 INFO [com.athaydes.spockframework.report.SpockReportExtension] Got configuration from Spock: com.athaydes.spockframework.report.internal.SpockReportsConfiguration([:]) 2022-05-17 16:07:58,415 INFO [com.athaydes.spockframework.report.internal.ConfigLoader] SpockReports config loaded: {com.athaydes.spockframework.report.projectVersion=Unknown, com.athaydes.spockframework.report.aggregatedJsonReportDir=, com.athaydes.spockframework.report.template.TemplateReportCreator.enabled=true, com.athaydes.spockframework.report.internal.HtmlReportCreator.printThrowableStackTrace=false, com.athaydes.spockframework.report.template.TemplateReportCreator.specTemplateFile=/templateReportCreator/spec-template.md, com.athaydes.spockframework.report.template.TemplateReportCreator.reportFileExtension=md, com.athaydes.spockframework.report.hideEmptyBlocks=false, com.athaydes.spockframework.report.template.TemplateReportCreator.summaryTemplateFile=/templateReportCreator/summary-template.md, com.athaydes.spockframework.report.template.TemplateReportCreator.summaryFileName=summary.md, com.athaydes.spockframework.report.internal.HtmlReportCreator.enabled=true, com.athaydes.spockframework.report.outputDir=build/spock-reports-local, com.athaydes.spockframework.report.projectName=userauth-systemtest-spock against [local], com.athaydes.spockframework.report.showCodeBlocks=true, com.athaydes.spockframework.report.internal.HtmlReportCreator.specSummaryNameOption=class_name_and_title, com.athaydes.spockframework.report.internal.HtmlReportCreator.inlineCss=true, com.athaydes.spockframework.report.internal.HtmlReportCreator.featureReportCss=spock-feature-report.css, com.athaydes.spockframework.report.testSourceRoots=src/test/groovy, com.athaydes.spockframework.report.internal.HtmlReportCreator.summaryReportCss=spock-summary-report.css, com.athaydes.spockframework.report.internal.HtmlReportCreator.excludeToc=false, com.athaydes.spockframework.report.IReportCreator=com.athaydes.spockframework.report.internal.HtmlReportCreator}

The option "com.athaydes.spockframework.report.internal.HtmlReportCreator.featureReportCss=spock-feature-report.css" should contain the path to the featureReportCss and it looks correct but in the console the following warnings are displayed:

2022-05-17 16:07:58,607 WARN [com.athaydes.spockframework.report.internal.ConfigLoader] Invalid property value for property 'featureReportCss' 2022-05-17 16:07:58,617 WARN [com.athaydes.spockframework.report.internal.ConfigLoader] Invalid property value for property 'testSourceRoots'

Both options above are assigned the default values and they have not been additionally set as system properties.

Problem:

The CSS "spock-feature-report.css" for featureReportCss is not loaded and the test results are not styled. The test results in the report are simply shown in plain text.

Expected:

The default values for featureReportCss and testSourceRoots should work and no warnings should be thrown.

renatoathaydes commented 2 years ago

We can see in this log that the report creator class is com.athaydes.spockframework.report.internal.HtmlReportCreator. This class contains properties featureReportCss and testSourceRoots as setters:

void setFeatureReportCss( String css )
void setTestSourceRoots( roots )

These methods are called dynamically because the actual report class is configurable. If you see a problem like this, your Groovy runtime is doing something funky.

Can you show your Java, Spock and Groovy versions? Please look at the README page for the recommended versions.

iwt-ttaskov commented 2 years ago

Hi @renatoathaydes , thank you very much for your reply and for the hint. These are my dependencies:

testImplementation 'org.apache.groovy:groovy:4.0.2' testImplementation "org.spockframework:spock-core:2.2-M1-groovy-4.0" testImplementation("com.athaydes:spock-reports:2.3.0-groovy-3.0") { exclude group: 'org.codehaus.groovy' }

And this is my java version:

openjdk version "17.0.3" 2022-04-19 LTS OpenJDK Runtime Environment Corretto-17.0.3.6.1 (build 17.0.3+6-LTS) OpenJDK 64-Bit Server VM Corretto-17.0.3.6.1 (build 17.0.3+6-LTS, mixed mode, sharing)

Based on the README they seem to be compatible.

renatoathaydes commented 2 years ago

Can you try with latest Groovy 3? We haven't yet added tests on Groovy 4 so this could be a problem.

iwt-ttaskov commented 2 years ago

Hi @renatoathaydes , thanks for your hint :) It works with 'org.codehaus.groovy:groovy:3.0.11'.

renatoathaydes commented 2 years ago

I will add support for Groovy 4 as soon as Spock itself stabilizes a little bit and officially does it (I may do it earlier anyway depending on my time).