diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.kt index 5b57184df3e5..d8d8110cab2e 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.kt @@ -508,11 +508,18 @@ class MavenParentCompletionAndResolutionTest : MavenDomWithIndicesTestCase() { """.trimIndent()) importProjectAsync() - checkHighlighting(projectPom, - Highlight(text="parent", description = "'groupId' child tag should be defined"), - Highlight(text="junit"), - Highlight(text="4.0"), + + val expectedHighlights = arrayOf( + Highlight(text = "parent", description = "'groupId' child tag should be defined"), + Highlight(text = "junit"), + Highlight(text = "4.0"), ) + + val highlights1 = doHighlighting(projectPom) + val highlights2 = doHighlighting(projectPom) + + assertHighlighting(highlights1, *expectedHighlights) + assertHighlighting(highlights2, *expectedHighlights) } @Test diff --git a/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenDomTestCase.kt b/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenDomTestCase.kt index b6177a7e3ec7..40f5f72a2339 100644 --- a/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenDomTestCase.kt +++ b/plugins/maven/testFramework/src/com/intellij/maven/testFramework/MavenDomTestCase.kt @@ -566,19 +566,23 @@ abstract class MavenDomTestCase : MavenMultiVersionImportingTestCase() { } protected suspend fun checkHighlighting(file: VirtualFile, vararg expectedHighlights: Highlight) { - withContext(Dispatchers.EDT) { + assertHighlighting(doHighlighting(file), *expectedHighlights) + } + + protected suspend fun doHighlighting(file: VirtualFile): Collection { + return withContext(Dispatchers.EDT) { refreshFiles(listOf(file)) val content = String(file.contentsToByteArray()) - MavenLog.LOG.debug("Checking highlighting in file $file:\n$content") + MavenLog.LOG.warn("Checking highlighting in file $file:\n$content") fixture.openFileInEditor(file) - MavenLog.LOG.debug("Text in editor: ${fixture.editor.document.text}") + MavenLog.LOG.warn("Text in editor: ${fixture.editor.document.text}") val highlightingInfos = fixture.doHighlighting() - MavenLog.LOG.debug("Highlighting results: ${highlightingInfos.joinToString { "\n${it.severity} ${it.description} (${it.startOffset}, ${it.endOffset})" }}") - assertHighlighting(highlightingInfos, *expectedHighlights) + MavenLog.LOG.warn("Highlighting results: ${highlightingInfos.joinToString { "\n${it.severity} ${it.description} (${it.startOffset}, ${it.endOffset})" }}") + highlightingInfos } } - private fun assertHighlighting(highlightingInfos: Collection, vararg expectedHighlights: Highlight) { + protected fun assertHighlighting(highlightingInfos: Collection, vararg expectedHighlights: Highlight) { expectedHighlights.forEach { assertHighlighting(highlightingInfos, it) } }