From dcf6c814a7166dfd1caac4052d03fe2415d1a770 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Fri, 18 May 2018 12:11:48 +0300 Subject: [PATCH] don't run first/last suites if nothing to test --- .../core/src/com/intellij/TestCaseLoader.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/testFramework/core/src/com/intellij/TestCaseLoader.java b/platform/testFramework/core/src/com/intellij/TestCaseLoader.java index ad9cf46320e9..086c64905e21 100644 --- a/platform/testFramework/core/src/com/intellij/TestCaseLoader.java +++ b/platform/testFramework/core/src/com/intellij/TestCaseLoader.java @@ -235,9 +235,9 @@ public class TestCaseLoader { } // PlatformLiteFixture is the very special test case because it doesn't load all the XMLs with component/extension declarations - // (that is, uses a mock application). Instead, it allows to declare them manually using its registerComponent/registerExtension - // methods. The goal is to make tests which extend PlatformLiteFixture extremely fast. The problem appears when such tests are invoked - // together with other tests which rely on declarations in XML files (that is, use a real application). The nature of the IDEA + // (that is, uses a mock application). Instead, it allows to declare them manually using its registerComponent/registerExtension + // methods. The goal is to make tests which extend PlatformLiteFixture extremely fast. The problem appears when such tests are invoked + // together with other tests which rely on declarations in XML files (that is, use a real application). The nature of the IDEA // application is such that static final fields are often used to cache extensions. While having a positive effect on performance, // it creates problems during testing. Simply speaking, if the instance of PlatformLiteFixture is the first one in a suite, it pollutes // static final fields (and all other kinds of caches) with invalid values. To avoid it, such tests should always be the last. @@ -283,8 +283,10 @@ public class TestCaseLoader { return result; } - public void clearClasses() { + private void clearClasses() { myClassList.clear(); + myFirstTestClass = null; + myLastTestClass = null; } static boolean isPerformanceTestsRun() { @@ -315,7 +317,7 @@ public class TestCaseLoader { } } - if (getClasses().size() == 1) { + if (myClassList.isEmpty()) { // nothing valuable to test clearClasses(); } long after = System.currentTimeMillis();