serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
722 stars 518 forks source link

Windows - task 'aggregate' throws an error if directory src\test\resources\assets exists #3271

Closed scormaq closed 1 year ago

scormaq commented 1 year ago

What happened?

When folder src\test\resources\assets exists in project (even empty dir), task aggregate throws an error when being executed on Windows environment:

c:\github\serenity-junit-starter>gradlew aggregate

> Task :aggregate
Generating Serenity Reports
  - Test Root: starter
  - Main report: file:///C:/Work/github/serenity-junit-starter/target/site/serenity/index.html
      - Test Root: starter
      - Requirements base directory: null

Failed to generate report - java.util.concurrent.ExecutionException: java.nio.file.NoSuchFileException: src\test\resources\assets
src\test\resources\assets
java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
java.util.concurrent.ExecutionException: java.nio.file.NoSuchFileException: src\test\resources\assets
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:205)
        at net.thucydides.core.reports.html.Reporter.lambda$generateReportsFor$0(Reporter.java:51)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
        at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
        at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
        at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
        at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.nio.file.NoSuchFileException: src\test\resources\assets
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:86)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:535)
        at java.base/java.nio.file.Files.newDirectoryStream(Files.java:482)
        at java.base/java.nio.file.Files.list(Files.java:3793)
        at org.gradle.internal.classpath.declarations.NioFileInterceptors.intercept_list(NioFileInterceptors.java:273)
        at net.thucydides.core.reports.html.CopyProjectSpecificResourcesTask.generateReports(CopyProjectSpecificResourcesTask.java:28)
        at net.thucydides.core.reports.html.HtmlReporter.copyProjectSpecificResources(HtmlReporter.java:80)
        at net.thucydides.core.reports.html.HtmlReporter.copyResourcesToOutputDirectory(HtmlReporter.java:72)
        at net.thucydides.core.reports.html.HtmlAggregateStoryReporter$CopyResourcesTask.generateReports(HtmlAggregateStoryReporter.java:365)
        at net.thucydides.core.reports.html.ReportExecutor.call(ReportExecutor.java:33)
        at net.thucydides.core.reports.html.ReportExecutor.call(ReportExecutor.java:12)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

> Task :aggregate
SOME REPORT PAGES COULD NOT BE GENERATED
 * Failed to generate report - java.util.concurrent.ExecutionException: java.nio.file.NoSuchFileException: src\test\resources\assets
src\test\resources\assets
java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)

What did you expect to happen?

I expect that task aggregate will be executed without any errors. Also, when being executed for serenity-cucumber project, Serenity will attach manual test evidences from it to properly tagged scenarios (https://johnfergusonsmart.com/reporting-manual-test-results-in-serenity-bdd/)

Serenity BDD version

4.0.12

JDK version

Java 18

Execution environment

Windows 10

How to reproduce the bug.

How can we make it happen?

Add it to the Serenity BDD backlog and wait for a volunteer to pick it up

wakaleo commented 1 year ago

I can't reproduce this but I don't work on Windows, so you might need to dig into this yourself and see if you can isolate the problem and propose a PR.

wakaleo commented 1 year ago

The issue seems to be happening here: https://github.com/serenity-bdd/serenity-core/blob/577a7c5f78a313c6dfb95da1d358f285ea3c455e/serenity-reports/src/main/java/net/thucydides/core/reports/html/CopyProjectSpecificResourcesTask.java#L28

It is Gradle and Windows specific. See if you can dig into the code and isolate the cause, and propose a PR. It may be related to the way Gradle defines the working directory in Windows, which is sometimes set to the Gradle installation directory and not the project directory, which will cause problems for relative paths.

Also, try setting the report.assets.directory to the absolute path of your assets folder to test this theory.

wakaleo commented 1 year ago

Fixed in 4.0.15