mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
test discovery: collect data for successful tests only
This commit is contained in:
@@ -29,13 +29,15 @@ public abstract class TestDiscoveryListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void testFinished(String className, String methodName) {
|
||||
try {
|
||||
final Object data = getData();
|
||||
Method testEnded = data.getClass().getMethod("testEnded", new Class[] {String.class});
|
||||
testEnded.invoke(data, new Object[] {getFrameworkId() + className + "-" + methodName});
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
public void testFinished(String className, String methodName, boolean succeed) {
|
||||
if (succeed) {
|
||||
try {
|
||||
final Object data = getData();
|
||||
Method testEnded = data.getClass().getMethod("testEnded", new Class[] {String.class});
|
||||
testEnded.invoke(data, new Object[] {getFrameworkId() + className + "-" + methodName});
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.junit.internal.requests.ClassRequest;
|
||||
import org.junit.internal.requests.FilterRequest;
|
||||
import org.junit.runner.*;
|
||||
import org.junit.runner.manipulation.Filter;
|
||||
import org.junit.runner.notification.Failure;
|
||||
import org.junit.runner.notification.RunListener;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -68,12 +69,32 @@ public class JUnit4IdeaTestRunner implements IdeaTestRunner {
|
||||
for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
|
||||
final IDEAJUnitListener junitListener = (IDEAJUnitListener)Class.forName((String)iterator.next()).newInstance();
|
||||
runner.addListener(new RunListener() {
|
||||
private boolean mySuccess;
|
||||
public void testStarted(Description description) throws Exception {
|
||||
mySuccess = true;
|
||||
junitListener.testStarted(JUnit4ReflectionUtil.getClassName(description), JUnit4ReflectionUtil.getMethodName(description));
|
||||
}
|
||||
|
||||
public void testFailure(Failure failure) throws Exception {
|
||||
mySuccess = false;
|
||||
}
|
||||
|
||||
public void testAssumptionFailure(Failure failure) {
|
||||
mySuccess = false;
|
||||
}
|
||||
|
||||
public void testIgnored(Description description) throws Exception {
|
||||
mySuccess = false;
|
||||
}
|
||||
|
||||
public void testFinished(Description description) throws Exception {
|
||||
junitListener.testFinished(JUnit4ReflectionUtil.getClassName(description), JUnit4ReflectionUtil.getMethodName(description));
|
||||
final String className = JUnit4ReflectionUtil.getClassName(description);
|
||||
final String methodName = JUnit4ReflectionUtil.getMethodName(description);
|
||||
if (junitListener instanceof IDEAJUnitListenerEx) {
|
||||
((IDEAJUnitListenerEx)junitListener).testFinished(className, methodName, mySuccess);
|
||||
} else {
|
||||
junitListener.testFinished(className, methodName);
|
||||
}
|
||||
}
|
||||
|
||||
public void testRunStarted(Description description) throws Exception {
|
||||
|
||||
@@ -22,4 +22,8 @@ public class JUnitTestDiscoveryListener extends TestDiscoveryListener implements
|
||||
public String getFrameworkId() {
|
||||
return "j";
|
||||
}
|
||||
|
||||
public void testFinished(String className, String methodName) {
|
||||
testFinished(className, methodName, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,5 @@ package com.intellij.rt.execution.junit;
|
||||
public interface IDEAJUnitListenerEx extends IDEAJUnitListener {
|
||||
void testRunStarted(String name);
|
||||
void testRunFinished(String name);
|
||||
void testFinished(String className, String methodName, boolean succeed);
|
||||
}
|
||||
|
||||
@@ -23,29 +23,17 @@ public class TestNGTestDiscoveryListener extends TestDiscoveryListener implement
|
||||
}
|
||||
|
||||
public void onTestSuccess(ITestResult result) {
|
||||
onTestEnded(result);
|
||||
testFinished(result.getTestClass().getName(), result.getName(), true);
|
||||
}
|
||||
|
||||
public void onTestFailure(ITestResult result) {
|
||||
onTestEnded(result);
|
||||
}
|
||||
|
||||
public void onTestSkipped(ITestResult result) {
|
||||
onTestEnded(result);
|
||||
}
|
||||
|
||||
public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
|
||||
onTestEnded(result);
|
||||
}
|
||||
public void onTestFailure(ITestResult result) {}
|
||||
public void onTestSkipped(ITestResult result) {}
|
||||
public void onTestFailedButWithinSuccessPercentage(ITestResult result) {}
|
||||
|
||||
public void onStart(ITestContext context) {}
|
||||
|
||||
public void onFinish(ITestContext context) {}
|
||||
|
||||
private void onTestEnded(ITestResult result) {
|
||||
testFinished(result.getTestClass().getName(), result.getName());
|
||||
}
|
||||
|
||||
public void onStart(ISuite suite) {
|
||||
testRunStarted(suite.getName());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user