diff --git a/platform/testFramework/junit5/src/impl/TestApplicationExtension.kt b/platform/testFramework/junit5/src/impl/TestApplicationExtension.kt index 742610d4d5f3..4f47015b603c 100644 --- a/platform/testFramework/junit5/src/impl/TestApplicationExtension.kt +++ b/platform/testFramework/junit5/src/impl/TestApplicationExtension.kt @@ -7,6 +7,7 @@ import com.intellij.ide.AppLifecycleListener import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.EDT import com.intellij.testFramework.common.* +import com.intellij.testFramework.common.BazelTestUtil import com.intellij.util.ui.EDT import kotlinx.coroutines.* import org.jetbrains.annotations.TestOnly @@ -45,6 +46,14 @@ private class TestApplicationResource(val initializationResult: Result) : return } + // In Bazel test environment, don't dispose the application. + // The JVM will terminate after all tests complete anyway, and + // disposing here would break JUnit 4 tests that run after JUnit 5 tests. + // See BAZEL-2843 for details. + if (BazelTestUtil.isUnderBazelTest) { + return + } + runBlocking { withTimeout(Duration.ofSeconds(20).toMillis()) { withContext(Dispatchers.EDT) {