diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/EdtTestUtil.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/EdtTestUtil.kt index e42071d1ed6..945e443afa2 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/EdtTestUtil.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/EdtTestUtil.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.test.testFramework +import com.intellij.mock.MockApplication import com.intellij.openapi.application.ApplicationManager import org.jetbrains.annotations.TestOnly import java.lang.reflect.InvocationTargetException @@ -41,6 +42,7 @@ fun runInEdtAndWait(runnable: () -> Unit) { else { try { val application = ApplicationManager.getApplication() + .takeIf { it !is MockApplication } // because MockApplication do nothing instead of `invokeAndWait` if (application != null) application.invokeAndWait(runnable) else diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java index e46292cc55f..67fff80e75e 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java @@ -52,6 +52,7 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; @SuppressWarnings("UseOfSystemOutOrSystemErr") public abstract class KtUsefulTestCase extends TestCase { @@ -217,9 +218,11 @@ public abstract class KtUsefulTestCase extends TestCase { protected void runTest() throws Throwable { Throwable[] throwables = new Throwable[1]; + AtomicBoolean completed = new AtomicBoolean(false); Runnable runnable = () -> { try { super.runTest(); + completed.set(true); } catch (InvocationTargetException e) { e.fillInStackTrace(); @@ -239,6 +242,9 @@ public abstract class KtUsefulTestCase extends TestCase { if (throwables[0] != null) { throw throwables[0]; } + if (!completed.get()) { + throw new IllegalStateException("test didn't start"); + } } private static void invokeTestRunnable(@NotNull Runnable runnable) throws Exception {