diff --git a/platform/testFramework/core/src/com/intellij/testFramework/TestLoggerFactory.java b/platform/testFramework/core/src/com/intellij/testFramework/TestLoggerFactory.java index 8dd232275fe3..79603dec64c3 100644 --- a/platform/testFramework/core/src/com/intellij/testFramework/TestLoggerFactory.java +++ b/platform/testFramework/core/src/com/intellij/testFramework/TestLoggerFactory.java @@ -211,6 +211,12 @@ public final class TestLoggerFactory implements Logger.Factory { onTestFinished(success, description.getDisplayName()); } + public static void logTestFailure(@NotNull Throwable t) { + if (shouldSplitTestLogs()) { + log(Level.ERROR.toString(), "Test framework", "Test failed", t); + } + } + /** * Invoke this method instead of {@link #onTestFinished(boolean)} to support separate logs saving * @@ -256,6 +262,7 @@ public final class TestLoggerFactory implements Logger.Factory { @Override protected void failed(Throwable e, Description description) { + logTestFailure(e); onTestFinished(false, description); } diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index adc3c335ceec..227281501852 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -566,6 +566,10 @@ public abstract class UsefulTestCase extends TestCase { success = true; throw e; } + catch (Throwable t) { + TestLoggerFactory.logTestFailure(t); + throw t; + } finally { TestLoggerFactory.onTestFinished(success, testDescription); } diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt index 8e75a17c8759..557012771948 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt @@ -33,6 +33,7 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase() EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.add(ENTRY_POINT_ANNOTATION) runWriteAction { FileTypeManager.getInstance().associateExtension(GroovyFileType.GROOVY_FILE_TYPE, "gradle") } } catch (e: Throwable) { + TestLoggerFactory.logTestFailure(e) TestLoggerFactory.onTestFinished(false, Description.createTestDescription(javaClass, name)) throw e } diff --git a/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java b/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java index 5f529a171586..e55cabf06abe 100644 --- a/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java +++ b/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java @@ -360,16 +360,19 @@ public abstract class KtUsefulTestCase extends TestCase { super.runTest(); TestLoggerFactory.onTestFinished(true, testDescription); } catch (InvocationTargetException e) { + TestLoggerFactory.logTestFailure(e); TestLoggerFactory.onTestFinished(false, testDescription); e.fillInStackTrace(); throwables[0] = e.getTargetException(); } catch (IllegalAccessException e) { + TestLoggerFactory.logTestFailure(e); TestLoggerFactory.onTestFinished(false, testDescription); e.fillInStackTrace(); throwables[0] = e; } catch (Throwable e) { + TestLoggerFactory.logTestFailure(e); TestLoggerFactory.onTestFinished(false, testDescription); throwables[0] = e; }