introduce ExcludeFromTestDiscovery annotation

allow excluding some test from test discovery capturing
for example, when they both are trying to manipulate with byte code
This commit is contained in:
Sergey Ignatov
2018-10-25 16:01:33 +03:00
parent 6452d8b2f7
commit 9cf9d65cf6
3 changed files with 21 additions and 1 deletions
@@ -3,6 +3,7 @@
package com.intellij;
import com.intellij.idea.Bombed;
import com.intellij.idea.ExcludeFromTestDiscovery;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testFramework.RunFirst;
@@ -36,6 +37,7 @@ public class TestCaseLoader {
private static final boolean INCLUDE_PERFORMANCE_TESTS = "true".equals(System.getProperty(INCLUDE_PERFORMANCE_TESTS_FLAG));
private static final boolean INCLUDE_UNCONVENTIONALLY_NAMED_TESTS = "true".equals(System.getProperty(INCLUDE_UNCONVENTIONALLY_NAMED_TESTS_FLAG));
private static final boolean RUN_ONLY_AFFECTED_TESTS = "true".equals(System.getProperty(RUN_ONLY_AFFECTED_TEST_FLAG));
private static final boolean RUN_WITH_TEST_DISCOVERY = System.getProperty("test.discovery.listener") != null;
/**
* An implicit group which includes all tests from all defined groups and tests which don't belong to any group.
@@ -173,7 +175,11 @@ public class TestCaseLoader {
if (!myForceLoadPerformanceTests && !shouldIncludePerformanceTestCase(testCaseClass)) return true;
String className = testCaseClass.getName();
return !myTestClassesFilter.matches(className, moduleName) || isBombed(testCaseClass);
return !myTestClassesFilter.matches(className, moduleName) || isBombed(testCaseClass) || isExcludeFromTestDiscovery(testCaseClass);
}
private static boolean isExcludeFromTestDiscovery(Class c) {
return RUN_WITH_TEST_DISCOVERY && getAnnotationInHierarchy(c, ExcludeFromTestDiscovery.class) != null;
}
public static boolean isBombed(final AnnotatedElement element) {
@@ -0,0 +1,12 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.idea;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface ExcludeFromTestDiscovery {
}
@@ -15,6 +15,7 @@
*/
package com.intellij.coverage;
import com.intellij.idea.ExcludeFromTestDiscovery;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.ex.ProjectManagerEx;
@@ -32,6 +33,7 @@ import java.util.Map;
/**
* @author yole
*/
@ExcludeFromTestDiscovery
public class CoverageIntegrationTest extends ModuleTestCase {
private static String getTestDataPath() {
return PluginPathManager.getPluginHomePath("coverage") + "/testData/simple";