cucumber-reporting
cucumber-reporting copied to clipboard
Regression: Json files must be inside the output directory
After switching from 3.9.0 to 3.19.0, I had to convert the cucumberOutput
parameter to the jsonFiles
param. This worked fine for most projects, but I have one where the desired output directory for the generated HTML report is a subdirectory in my target dir (set by a property), while the json files are in a different subdirectory. Since the jsonFiles
param is no longer a full path, but rather treated as a filter for files within the outputDirectory
path, this no longer works.
The old config (3.9.0) looked like this:
<configuration>
<projectName>Regression</projectName>
<outputDirectory>${project.build.directory}/${reportDirectory}</outputDirectory>
<cucumberOutput>${project.build.directory}/ParallelReports/</cucumberOutput>
</configuration>
The new config is this:
<configuration>
<projectName>Regression</projectName>
<outputDirectory>${project.build.directory}/${reportDirectory}</outputDirectory>
<jsonFiles>
<param>ParallelReports/*.json</param>
</jsonFiles>
<classificationFiles>
</classificationFiles>
</configuration>
However, there doesn't seem to be any working value for the jsonFiles param. If I remove the ${reportDirectory}
part of outputDirectory, it works, but I need to have that parameterized for other downstream reporting tools. Neither using ../ParallelReports/*.json
, nor ${project.build.directory}/ParallelReports/*.json
works. In any case, it cannot find any JSON files to process:
Aug 03, 2018 8:52:29 AM net.masterthought.cucumber.ReportBuilder generateErrorPage
INFO: Unexpected error
net.masterthought.cucumber.ValidationException: No report file was added!
at net.masterthought.cucumber.ReportParser.parseJsonFiles(ReportParser.java:55)
at net.masterthought.cucumber.ReportBuilder.generateReports(ReportBuilder.java:88)
at net.masterthought.cucumber.CucumberReportGeneratorMojo.execute(CucumberReportGeneratorMojo.java:108)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Please consider adding a way for the JSON directory and output directory to be specified separately like in older versions. If there is no objection to having a separate option for the JSON base directory to be specified, I can make a PR for it.
@mattventura Can you tell me what is the difference between outputDirectory and cucumberOutput tags? is cucumberOutput for where cucumber dumps its json files? If so, then what is outputDirectory for? Is that where this plugin dumps its pretty reports?
I am also trying to do parallel testing...if so, do I turn the parallelTesting tag to true? then what, do I inform this plugin of the multiple json files within params tag or do I create several cucumberoutput tags? I'm confused on how to set up parallel testing with this plugin, I cannot find ANY instructions on what all these tags do
@telangn cucumberOutput
is obsolete now - it previously was the directory to look for Cucumber JSON in (i.e. wherever your cucumber runners were set to output to).
outputDirectory
is indeed where this plugin puts its output, but it is now also used as the folder to search for Cucumber JSON files (using the jsonFiles
parameter as a filter).
As for the parallelTesting tag, I'm actually not sure. I have some projects parallelized using surefire's forkCount option, others with threadCount, and only some of them have the parallelTesting option specified. This plugin only handles reporting - the actual parallelization has to be done elsewhere.
@mattventura God Bless you for responding. so sorry for hijacking your thread. per your response, Understood. I too will be using surefire for parallelTesting. So if I have multiple runners outputting json's in different locations, how do I set up this plugin's pom to see all the jsons? I think you said it above "Since the jsonFiles param is no longer a full path, but rather treated as a filter for files within the outputDirectory path"
@telangn It still supports wildcards - e.g. in my case, "ParallelReports/*.json" works. It's just that now there's no way to have the final report go into a different subdirectory.
I see some security issue here. While I can trust developers who use this library directly while I don't think this is perfect idea to give others (eg Jenkins plugin) ability to traverse whole file system
Can't you already put an arbitrary path into the <outputDirectory>
?
If a solution that allows .. in paths is unacceptable, then what about introducing another option like the old cucumberOutput
parameter that would act as a base for the jsonFiles
paths, falling back to the current behavior of using outputDirectory
if not specified?
Another option looks acceptable so backwards compatibility is not broken.
Would you like to prepare PR for this?
https://github.com/damianszczepanik/maven-cucumber-reporting/pull/110
Looks like this bug should have been filed against that repo, my mistake.