@@ -15,7 +15,6 @@ import com.intellij.openapi.editor.Editor
15
15
import com.intellij.openapi.project.DumbService
16
16
import com.intellij.openapi.project.Project
17
17
import com.intellij.openapi.util.Computable
18
- import com.intellij.openapi.vfs.VfsUtil
19
18
import com.intellij.psi.JavaDirectoryService
20
19
import com.intellij.psi.PsiClass
21
20
import com.intellij.psi.PsiClassOwner
@@ -47,7 +46,6 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset
47
46
import org.jetbrains.kotlin.psi.psiUtil.startOffset
48
47
import org.jetbrains.kotlin.scripting.resolve.classId
49
48
import org.utbot.common.HTML_LINE_SEPARATOR
50
- import org.utbot.common.PathUtil.classFqnToPath
51
49
import org.utbot.common.PathUtil.toHtmlLinkTag
52
50
import org.utbot.common.appendHtmlLine
53
51
import org.utbot.framework.codegen.Import
@@ -56,7 +54,6 @@ import org.utbot.framework.codegen.RegularImport
56
54
import org.utbot.framework.codegen.StaticImport
57
55
import org.utbot.framework.codegen.model.CodeGenerator
58
56
import org.utbot.framework.codegen.model.TestsCodeWithTestReport
59
- import org.utbot.framework.codegen.model.constructor.tree.TestsGenerationReport
60
57
import org.utbot.framework.plugin.api.CodegenLanguage
61
58
import org.utbot.framework.plugin.api.UtMethod
62
59
import org.utbot.framework.plugin.api.UtTestCase
@@ -70,16 +67,17 @@ import org.utbot.intellij.plugin.models.GenerateTestsModel
70
67
import org.utbot.intellij.plugin.models.packageName
71
68
import org.utbot.intellij.plugin.sarif.SarifReportIdea
72
69
import org.utbot.intellij.plugin.sarif.SourceFindingStrategyIdea
70
+ import org.utbot.intellij.plugin.ui.DetailsTestsReportNotifier
73
71
import org.utbot.intellij.plugin.ui.SarifReportNotifier
74
72
import org.utbot.intellij.plugin.ui.TestReportUrlOpeningListener
75
73
import org.utbot.intellij.plugin.ui.TestsReportNotifier
74
+ import org.utbot.intellij.plugin.ui.WarningTestsReportNotifier
76
75
import org.utbot.intellij.plugin.ui.utils.getOrCreateSarifReportsPath
77
76
import org.utbot.intellij.plugin.ui.utils.getOrCreateTestResourcesPath
78
77
import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater
79
78
import org.utbot.intellij.plugin.util.signature
80
79
import org.utbot.sarif.SarifReport
81
80
import java.nio.file.Path
82
- import java.nio.file.Paths
83
81
import java.util.concurrent.CountDownLatch
84
82
import java.util.concurrent.TimeUnit
85
83
import kotlin.reflect.KClass
@@ -167,7 +165,6 @@ object CodeGenerationController {
167
165
SarifReportNotifier .notify(
168
166
info = """
169
167
SARIF report was saved to ${toHtmlLinkTag(mergedReportFile.path)}$HTML_LINE_SEPARATOR
170
- You can open it using the VS Code extension "Sarif Viewer"
171
168
""" .trimIndent()
172
169
)
173
170
}
@@ -394,32 +391,10 @@ object CodeGenerationController {
394
391
" Test resources directory $testResourcesDirPath does not exist"
395
392
}
396
393
397
- val testReportSubDir = " utbot-tests-report"
398
- val classFqn = with (testsCodeWithTestReport.testsGenerationReport.classUnderTest) {
399
- qualifiedName ? : error(" Could not save tests report for anonymous or local class $this " )
400
- }
401
- val fileReportPath = classFqnToPath(classFqn)
402
-
403
- val resultedReportedPath =
404
- Paths .get(
405
- testResourcesDirPath.toString(),
406
- testReportSubDir,
407
- fileReportPath + " TestReport" + TestsGenerationReport .EXTENSION
408
- )
409
-
410
- val parent = resultedReportedPath.parent
411
- requireNotNull(parent) {
412
- " Expected from parent of $resultedReportedPath to be not null but it is null"
413
- }
414
-
415
- VfsUtil .createDirectories(parent.toString())
416
- resultedReportedPath.toFile().writeText(testsCodeWithTestReport.testsGenerationReport.getFileContent())
417
-
418
394
processInitialWarnings(testsCodeWithTestReport, model)
419
395
420
396
val notifyMessage = buildString {
421
- appendHtmlLine(testsCodeWithTestReport.testsGenerationReport.toString())
422
- appendHtmlLine()
397
+ appendHtmlLine(testsCodeWithTestReport.testsGenerationReport.toString(isShort = true ))
423
398
val classUnderTestPackageName =
424
399
testsCodeWithTestReport.testsGenerationReport.classUnderTest.classId.packageFqName.toString()
425
400
if (classUnderTestPackageName != model.testPackageName) {
@@ -430,12 +405,19 @@ object CodeGenerationController {
430
405
appendHtmlLine(warningMessage)
431
406
appendHtmlLine()
432
407
}
433
- val savedFileMessage = """
434
- Tests report was saved to ${toHtmlLinkTag(resultedReportedPath.toString())} in TSV format
408
+ val eventLogMessage = """
409
+ <a href=" ${ TestReportUrlOpeningListener .prefix}${ TestReportUrlOpeningListener .eventLogSuffix} ">See details in Event Log</a>.
435
410
""" .trimIndent()
436
- appendHtmlLine(savedFileMessage)
411
+ appendHtmlLine(eventLogMessage)
412
+ }
413
+
414
+ if (testsCodeWithTestReport.testsGenerationReport.hasWarnings) {
415
+ WarningTestsReportNotifier .notify(notifyMessage)
416
+ } else {
417
+ TestsReportNotifier .notify(notifyMessage)
437
418
}
438
- TestsReportNotifier .notify(notifyMessage)
419
+
420
+ DetailsTestsReportNotifier .notify(testsCodeWithTestReport.testsGenerationReport.detailedStatistics)
439
421
}
440
422
441
423
private fun processInitialWarnings (testsCodeWithTestReport : TestsCodeWithTestReport , model : GenerateTestsModel ) {
@@ -445,8 +427,6 @@ object CodeGenerationController {
445
427
}
446
428
447
429
testsCodeWithTestReport.testsGenerationReport.apply {
448
- summaryMessage = { " Unit tests for $classUnderTest were generated with warnings.<br>" }
449
-
450
430
if (model.forceMockHappened) {
451
431
initialWarnings.add {
452
432
"""
0 commit comments