testng: FileAlreadyExistsException when report is generated
TestNG Version
7.6.0 7.5 is ok
Expected behavior
Generate test reports without errors in console.
Actual behavior
> Task :libs:xxx:test
Jun 01, 2022 9:01:16 AM org.testng.log4testng.Logger error
SEVERE: D:\...\build\reports\tests\test\jquery-3.6.0.min.js
java.nio.file.FileAlreadyExistsException: D:\...\build\reports\tests\test\jquery-3.6.0.min.js
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:87)
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.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:236)
at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:484)
at java.base/java.nio.file.Files.newOutputStream(Files.java:228)
at java.base/java.nio.file.Files.copy(Files.java:3160)
at org.testng.reporters.jq.Main.generateReport(Main.java:93)
at org.testng.TestNG.generateReports(TestNG.java:1134)
at org.testng.TestNG.run(TestNG.java:1072)
at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.runTests(TestNGTestClassProcessor.java:141)
at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.stop(TestNGTestClassProcessor.java:90)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java: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.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at jdk.proxy1/jdk.proxy1.$Proxy2.stop(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Is the issue reproducible on runner?
- Shell
- Maven
- [x ] Gradle
- Ant
- Eclipse
- IntelliJ
- NetBeans
Test case sample
useTestNG() { useDefaultListeners = true }
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 16 (13 by maintainers)
Commits related to this issue
- Fix #2770: FileAlreadyExistsException on copy — committed to melloware/testng by melloware 2 years ago
- Fix #2770: FileAlreadyExistsException on copy (#2827) * Fix #2770: FileAlreadyExistsException on copy — committed to testng-team/testng by melloware 2 years ago
Ok I will submit a PR.
Ok I will do. One thing to note I have a feeling this is Windows bug are you running your example in Windows or some other Os?
If you look in the stack trace is definitely mentions WindowsFileSystem which has different locking than Linux.
Thanks @melloware , I just started experiencing this issue on the latest version as well. Can’t wait for the PR to be merged! Impacted environments: Linux, Windows: Gradle, Eclipse
We have observed this issue on linux with eclipse. I’ll see if I can provide a reproducer.
@melloware - Good catch! That could be the reason. I am running on a OSX machine which perhaps is why I couldn’t reproduce it.
@melloware - Thanks for pointing out the line of code. As I mentioned here I wasn’t able to reproduce the problem with a standard Gradle project.
It would help if there’s a reproducible so that we can add a test as well that would ensure that going forward the bug doesn’t come up again.
Alternatively we would be more than glad to help merge a PR if you would like to raise one (especially since you have taken the effort to identify the line of code as well that is causing the problem).
@krmahadevan the bug is right here:
https://github.com/cbeust/testng/blob/b484be19263ded600f47206396f51a3ac3f49710/testng-core/src/main/java/org/testng/reporters/jq/Main.java#L95
it needs to be…