Description
There is an exception due to the absence of the .sarif file during test report generation.
That is
To Reproduce
Steps to reproduce the behavior:
Example:
- Create clean project in IDEA
- Add such class to the project
public class SimpleString {
private String str = "hello";
public String getStr() {
return str;
}
}
- Use plugin to generate tests
Expected behavior
Tests are supposed to be generated.
Actual behavior
No tests, no sarif, just an exception in plugin.
Visual proofs (screenshots, logs, images)
java.io.FileNotFoundException: C:\Users\vWX1143085\IdeaProjects\idsfds\src\test\resources\utbot-sarif-report\idsfdsReport.sarif (The system cannot find the path specified)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:187)
at kotlin.io.FilesKt__FileReadWriteKt.writeBytes(FileReadWrite.kt:108)
at kotlin.io.FilesKt__FileReadWriteKt.writeText(FileReadWrite.kt:134)
at kotlin.io.FilesKt__FileReadWriteKt.writeText$default(FileReadWrite.kt:134)
at org.utbot.intellij.plugin.generator.TestGenerator.mergeSarifReports(TestGenerator.kt:100)
at org.utbot.intellij.plugin.generator.TestGenerator.generateTestsInternal(TestGenerator.kt:87)
at org.utbot.intellij.plugin.generator.TestGenerator.generateTests(TestGenerator.kt:62)
at org.utbot.intellij.plugin.ui.UtTestsDialogProcessor$createTests$2$1$run$$inlined$invokeLater$1.run(actions.kt:61)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:322)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:132)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:188)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:967)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:839)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:450)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:744)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:449)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:497)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Environment
Java 8, fresh project.
Additional context
The issue is probably within the logic of Denis's fix