mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
testng: do not include classes with method level configs in suite; include success/fail of configuration method
This commit is contained in:
@@ -94,7 +94,7 @@ public class TestClassFilter implements ClassFilter.ClassFilterWithScope
|
||||
return true;
|
||||
}
|
||||
|
||||
return includeConfig && TestNGUtil.hasConfig(psiClass);
|
||||
return includeConfig && TestNGUtil.hasConfig(psiClass, TestNGUtil.CONFIG_ANNOTATIONS_FQN_NO_TEST_LEVEL);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,6 +90,20 @@ public class TestNGUtil {
|
||||
AfterTest.class.getName()
|
||||
};
|
||||
|
||||
@SuppressWarnings("deprecation") public static final String[] CONFIG_ANNOTATIONS_FQN_NO_TEST_LEVEL = {
|
||||
Configuration.class.getName(),
|
||||
Factory.class.getName(),
|
||||
ObjectFactory.class.getName(),
|
||||
BeforeClass.class.getName(),
|
||||
BeforeGroups.class.getName(),
|
||||
BeforeSuite.class.getName(),
|
||||
BeforeTest.class.getName(),
|
||||
AfterClass.class.getName(),
|
||||
AfterGroups.class.getName(),
|
||||
AfterSuite.class.getName(),
|
||||
AfterTest.class.getName()
|
||||
};
|
||||
|
||||
@NonNls
|
||||
private static final String[] CONFIG_JAVADOC_TAGS = {
|
||||
"testng.configuration",
|
||||
@@ -112,19 +126,24 @@ public class TestNGUtil {
|
||||
private static final String SUITE_TAG_NAME = "suite";
|
||||
|
||||
public static boolean hasConfig(PsiModifierListOwner element) {
|
||||
return hasConfig(element, CONFIG_ANNOTATIONS_FQN);
|
||||
}
|
||||
|
||||
public static boolean hasConfig(PsiModifierListOwner element,
|
||||
String[] configAnnotationsFqn) {
|
||||
if (element instanceof PsiClass) {
|
||||
for (PsiMethod method : ((PsiClass)element).getAllMethods()) {
|
||||
if (isConfigMethod(method)) return true;
|
||||
if (isConfigMethod(method, configAnnotationsFqn)) return true;
|
||||
}
|
||||
} else {
|
||||
if (!(element instanceof PsiMethod)) return false;
|
||||
return isConfigMethod((PsiMethod)element);
|
||||
return isConfigMethod((PsiMethod)element, configAnnotationsFqn);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isConfigMethod(PsiMethod method) {
|
||||
for (String fqn : CONFIG_ANNOTATIONS_FQN) {
|
||||
private static boolean isConfigMethod(PsiMethod method, String[] configAnnotationsFqn) {
|
||||
for (String fqn : configAnnotationsFqn) {
|
||||
if (AnnotationUtil.isAnnotated(method, fqn, false)) return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,16 +21,25 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
|
||||
private String myMethodName;
|
||||
private int myInvocationCount = 0;
|
||||
|
||||
public void onConfigurationSuccess(ITestResult itr) {
|
||||
//won't be called
|
||||
public void onConfigurationSuccess(ITestResult result) {
|
||||
final String className = result.getTestClass().getName();
|
||||
System.out.println("##teamcity[testSuiteStarted name=\'" + className + "\']");
|
||||
final String methodName = result.getMethod().getMethodName();
|
||||
System.out.println("##teamcity[testStarted name=\'" + methodName + "\']");
|
||||
onTestSuccess(result);
|
||||
System.out.println("\n##teamcity[testSuiteFinished name=\'" + className + "\']");
|
||||
}
|
||||
|
||||
public void onConfigurationFailure(ITestResult itr) {
|
||||
//won't be called
|
||||
public void onConfigurationFailure(ITestResult result) {
|
||||
final String className = result.getTestClass().getName();
|
||||
System.out.println("##teamcity[testSuiteStarted name=\'" + className + "\']");
|
||||
final String methodName = result.getMethod().getMethodName();
|
||||
System.out.println("##teamcity[testStarted name=\'" + methodName + "\']");
|
||||
onTestFailure(result);
|
||||
System.out.println("\n##teamcity[testSuiteFinished name=\'" + className + "\']");
|
||||
}
|
||||
|
||||
public void onConfigurationSkip(ITestResult itr) {
|
||||
//won't be called
|
||||
}
|
||||
|
||||
public void onStart(ISuite suite) {
|
||||
|
||||
Reference in New Issue
Block a user