summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Georgi2013-04-28 04:13:47 (EDT)
committerMarkus Keller2013-04-28 04:13:47 (EDT)
commitf884bb73f0186fc8e55c458c1d817fa2cc34b4f4 (patch)
tree21a103109e323181c817cc66e511717364cf37cb
parent8784c4cedca248ed848edd5edd1d7c2f3a7741e4 (diff)
downloadeclipse.jdt.ui-f884bb73f0186fc8e55c458c1d817fa2cc34b4f4.zip
eclipse.jdt.ui-f884bb73f0186fc8e55c458c1d817fa2cc34b4f4.tar.gz
eclipse.jdt.ui-f884bb73f0186fc8e55c458c1d817fa2cc34b4f4.tar.bz2
Bug 359944: [JUnit] Eclipse JUnit4 runner treats failed assumptions (org.junit.Assume.*) as passing tests instead of skipped tests.
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/IXMLTags.java4
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestElement.java10
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunHandler.java2
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSession.java34
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSessionSerializer.java4
-rw-r--r--org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/MessageIds.java5
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/CounterPanel.java17
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java2
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties2
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java7
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestSessionLabelProvider.java4
-rw-r--r--org.eclipse.jdt.junit4.runtime/src/org/eclipse/jdt/internal/junit4/runner/JUnit4TestListener.java41
12 files changed, 115 insertions, 17 deletions
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/IXMLTags.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/IXMLTags.java
index 49ae717..ddc90e5 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/IXMLTags.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/IXMLTags.java
@@ -59,6 +59,10 @@ public interface IXMLTags {
*/
public static final String ATTR_IGNORED= "ignored"; //$NON-NLS-1$
/**
+ * value: Boolean
+ */
+ public static final String ATTR_ASSUMPTION_FAILED= "assumptionFailed"; //$NON-NLS-1$
+ /**
* value: String
*/
public static final String ATTR_PACKAGE= "package"; //$NON-NLS-1$
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestElement.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestElement.java
index 522efbf..a395615 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestElement.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestElement.java
@@ -172,6 +172,8 @@ public abstract class TestElement implements ITestElement {
private String fExpected;
private String fActual;
+ private boolean fAssumptionFailed;
+
/**
* Running time in seconds. Contents depend on the current {@link #getProgressState()}:
* <ul>
@@ -348,6 +350,14 @@ public abstract class TestElement implements ITestElement {
return fTime;
}
+ public void setAssumptionFailed(boolean assumptionFailed) {
+ fAssumptionFailed= assumptionFailed;
+ }
+
+ public boolean isAssumptionFailure() {
+ return fAssumptionFailed;
+ }
+
public String toString() {
return getProgressState() + " - " + getTestResult(true); //$NON-NLS-1$
}
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunHandler.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunHandler.java
index 09dc671..7de5674 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunHandler.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunHandler.java
@@ -128,6 +128,7 @@ public class TestRunHandler extends DefaultHandler {
fTestSuite= (TestSuiteElement) fTestRunSession.createTestElement(fTestSuite, getNextId(), suiteName, true, 0);
readTime(fTestSuite, attributes);
fNotRun.push(Boolean.valueOf(attributes.getValue(IXMLTags.ATTR_INCOMPLETE)));
+ fTestSuite.setAssumptionFailed(Boolean.valueOf(attributes.getValue(IXMLTags.ATTR_ASSUMPTION_FAILED)).booleanValue());
} else if (qName.equals(IXMLTags.NODE_PROPERTIES) || qName.equals(IXMLTags.NODE_PROPERTY)) {
// not interested
@@ -138,6 +139,7 @@ public class TestRunHandler extends DefaultHandler {
fTestCase= (TestCaseElement) fTestRunSession.createTestElement(fTestSuite, getNextId(), name + '(' + classname + ')', false, 0);
fNotRun.push(Boolean.valueOf(attributes.getValue(IXMLTags.ATTR_INCOMPLETE)));
fTestCase.setIgnored(Boolean.valueOf(attributes.getValue(IXMLTags.ATTR_IGNORED)).booleanValue());
+ fTestCase.setAssumptionFailed(Boolean.valueOf(attributes.getValue(IXMLTags.ATTR_ASSUMPTION_FAILED)).booleanValue());
readTime(fTestCase, attributes);
} else if (qName.equals(IXMLTags.NODE_ERROR)) {
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSession.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSession.java
index fa6b5b2..ac82010 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSession.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSession.java
@@ -107,6 +107,10 @@ public class TestRunSession implements ITestRunSession {
*/
volatile int fIgnoredCount;
/**
+ * Number of tests whose assumption failed during this test run.
+ */
+ volatile int fAssumptionFailureCount;
+ /**
* Number of errors during this test run.
*/
volatile int fErrorCount;
@@ -209,6 +213,7 @@ public class TestRunSession implements ITestRunSession {
void reset() {
fStartedCount= 0;
fFailureCount= 0;
+ fAssumptionFailureCount = 0;
fErrorCount= 0;
fIgnoredCount= 0;
fTotalCount= 0;
@@ -307,6 +312,10 @@ public class TestRunSession implements ITestRunSession {
return fFailureCount;
}
+ public int getAssumptionFailureCount() {
+ return fAssumptionFailureCount;
+ }
+
public int getStartedCount() {
return fStartedCount;
}
@@ -575,6 +584,7 @@ public class TestRunSession implements ITestRunSession {
fStartedCount= 0;
fIgnoredCount= 0;
fFailureCount= 0;
+ fAssumptionFailureCount = 0;
fErrorCount= 0;
fTotalCount= testCount;
@@ -705,7 +715,15 @@ public class TestRunSession implements ITestRunSession {
testElement= createUnrootedTestElement(testId, testName);
}
- Status status= Status.convert(statusCode);
+ Status status;
+ if (testElement != null && testName.startsWith(MessageIds.ASSUMPTION_FAILED_TEST_PREFIX)) {
+ testElement.setAssumptionFailed(true);
+ fAssumptionFailureCount++;
+ status = Status.OK;
+ } else {
+ status= Status.convert(statusCode);
+ }
+
registerTestFailureStatus(testElement, status, trace, expected, actual);
Object[] listeners= fSessionListeners.getListeners();
@@ -754,10 +772,12 @@ public class TestRunSession implements ITestRunSession {
public void registerTestFailureStatus(TestElement testElement, Status status, String trace, String expected, String actual) {
testElement.setStatus(status, trace, expected, actual);
- if (status.isError()) {
- fErrorCount++;
- } else if (status.isFailure()) {
- fFailureCount++;
+ if (!testElement.isAssumptionFailure()) {
+ if (status.isError()) {
+ fErrorCount++;
+ } else if (status.isFailure()) {
+ fFailureCount++;
+ }
}
}
@@ -774,6 +794,10 @@ public class TestRunSession implements ITestRunSession {
if (! testElement.getStatus().isErrorOrFailure())
setStatus(testElement, Status.OK);
}
+
+ if (testElement.isAssumptionFailure()) {
+ fAssumptionFailureCount++;
+ }
}
private void setStatus(TestElement testElement, Status status) {
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSessionSerializer.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSessionSerializer.java
index 6952f14..95e9c33 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSessionSerializer.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestRunSessionSerializer.java
@@ -100,6 +100,8 @@ public class TestRunSessionSerializer implements XMLReader {
addCDATA(atts, IXMLTags.ATTR_TIME, timeFormat.format(testSuiteElement.getElapsedTimeInSeconds()));
if (testElement.getProgressState() != ProgressState.COMPLETED || testElement.getTestResult(false) != Result.UNDEFINED)
addCDATA(atts, IXMLTags.ATTR_INCOMPLETE, Boolean.TRUE.toString());
+ if (testSuiteElement.isAssumptionFailure())
+ addCDATA(atts, IXMLTags.ATTR_ASSUMPTION_FAILED, Boolean.TRUE.toString());
startElement(IXMLTags.NODE_TESTSUITE, atts);
addFailure(testElement);
@@ -122,6 +124,8 @@ public class TestRunSessionSerializer implements XMLReader {
addCDATA(atts, IXMLTags.ATTR_INCOMPLETE, Boolean.TRUE.toString());
if (testCaseElement.isIgnored())
addCDATA(atts, IXMLTags.ATTR_IGNORED, Boolean.TRUE.toString());
+ if (testCaseElement.isAssumptionFailure())
+ addCDATA(atts, IXMLTags.ATTR_ASSUMPTION_FAILED, Boolean.TRUE.toString());
startElement(IXMLTags.NODE_TESTCASE, atts);
addFailure(testElement);
diff --git a/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/MessageIds.java b/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/MessageIds.java
index fbe3ffc..4fdb52c 100644
--- a/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/MessageIds.java
+++ b/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/MessageIds.java
@@ -130,6 +130,11 @@ public class MessageIds {
* Test identifier prefix for ignored tests.
*/
public static final String IGNORED_TEST_PREFIX= "@Ignore: "; //$NON-NLS-1$
+
+ /**
+ * Test identifier prefix for tests with assumption failures.
+ */
+ public static final String ASSUMPTION_FAILED_TEST_PREFIX= "@AssumptionFailure: "; //$NON-NLS-1$
}
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/CounterPanel.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/CounterPanel.java
index 00a55b8..3ee7dc0 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/CounterPanel.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/CounterPanel.java
@@ -32,6 +32,7 @@ public class CounterPanel extends Composite {
protected Text fNumberOfRuns;
protected int fTotal;
protected int fIgnoredCount;
+ protected int fAssumptionFailedCount;
private final Image fErrorIcon= JUnitPlugin.createImage("ovr16/error_ovr.gif"); //$NON-NLS-1$
private final Image fFailureIcon= JUnitPlugin.createImage("ovr16/failed_ovr.gif"); //$NON-NLS-1$
@@ -84,7 +85,7 @@ public class CounterPanel extends Composite {
public void reset() {
setErrorValue(0);
setFailureValue(0);
- setRunValue(0, 0);
+ setRunValue(0, 0, 0);
fTotal= 0;
}
@@ -96,21 +97,29 @@ public class CounterPanel extends Composite {
return fTotal;
}
- public void setRunValue(int value, int ignoredCount) {
+ public void setRunValue(int value, int ignoredCount, int assumptionFailureCount) {
String runString;
- if (ignoredCount == 0)
+ if (ignoredCount == 0 && assumptionFailureCount == 0)
runString= Messages.format(JUnitMessages.CounterPanel_runcount, new String[] { Integer.toString(value), Integer.toString(fTotal) });
- else
+ else if (ignoredCount != 0 && assumptionFailureCount == 0)
runString= Messages.format(JUnitMessages.CounterPanel_runcount_ignored, new String[] { Integer.toString(value), Integer.toString(fTotal), Integer.toString(ignoredCount) });
+ else if (ignoredCount == 0 && assumptionFailureCount != 0)
+ runString= Messages.format(JUnitMessages.CounterPanel_runcount_assumptionsFailed, new String[] { Integer.toString(value), Integer.toString(fTotal), Integer.toBinaryString(assumptionFailureCount) });
+ else
+ runString= Messages.format(JUnitMessages.CounterPanel_runcount_ignored_assumptionsFailed, new String[] { Integer.toString(value), Integer.toString(fTotal), Integer.toString(ignoredCount), Integer.toString(assumptionFailureCount) });
fNumberOfRuns.setText(runString);
+ fNumberOfRuns.setToolTipText(runString);
if (fIgnoredCount == 0 && ignoredCount > 0 || fIgnoredCount != 0 && ignoredCount == 0) {
layout();
+ } else if (fAssumptionFailedCount == 0 && assumptionFailureCount > 0 || fAssumptionFailedCount != 0 && assumptionFailureCount == 0) {
+ layout();
} else {
fNumberOfRuns.redraw();
redraw();
}
fIgnoredCount= ignoredCount;
+ fAssumptionFailedCount= assumptionFailureCount;
}
public void setErrorValue(int value) {
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java
index 5a1dd9f..82d19d8 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java
@@ -39,7 +39,9 @@ public final class JUnitMessages extends NLS {
public static String CounterPanel_label_failures;
public static String CounterPanel_label_runs;
public static String CounterPanel_runcount;
+ public static String CounterPanel_runcount_assumptionsFailed;
public static String CounterPanel_runcount_ignored;
+ public static String CounterPanel_runcount_ignored_assumptionsFailed;
public static String EnableStackFilterAction_action_description;
public static String EnableStackFilterAction_action_label;
public static String EnableStackFilterAction_action_tooltip;
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties
index 6f4c32e..0c0dcab 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties
@@ -22,6 +22,8 @@ CounterPanel_label_errors=Errors:
CounterPanel_label_failures=Failures:
CounterPanel_runcount= {0}/{1}
CounterPanel_runcount_ignored= {0}/{1} ({2} ignored)
+CounterPanel_runcount_assumptionsFailed= {0}/{1} ({2} assumption failures)
+CounterPanel_runcount_ignored_assumptionsFailed= {0}/{1} ({2} ignored, {3} assumption failures)
EnableStackFilterAction_action_label=Filter
EnableStackFilterAction_action_description=Filter the stack trace
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java
index 67cd64b..4afc41b 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java
@@ -239,6 +239,7 @@ public class TestRunnerViewPart extends ViewPart {
final Image fTestOkIcon;
final Image fTestErrorIcon;
final Image fTestFailIcon;
+ final Image fTestAssumptionFailureIcon;
final Image fTestRunningIcon;
final Image fTestIgnoredIcon;
@@ -1081,6 +1082,7 @@ public class TestRunnerViewPart extends ViewPart {
fTestFailIcon= createManagedImage("obj16/testfail.gif"); //$NON-NLS-1$
fTestRunningIcon= createManagedImage("obj16/testrun.gif"); //$NON-NLS-1$
fTestIgnoredIcon= createManagedImage("obj16/testignored.gif"); //$NON-NLS-1$
+ fTestAssumptionFailureIcon = createManagedImage("obj16/testassumptionfailed.gif"); //$NON-NLS-1$
fSuiteIcon= createManagedImage(fSuiteIconDescriptor);
fSuiteOkIcon= createManagedImage(fSuiteOkIconDescriptor);
@@ -1594,6 +1596,7 @@ action enablement
int totalCount;
int errorCount;
int failureCount;
+ int assumptionFailureCount;
boolean hasErrorsOrFailures;
boolean stopped;
@@ -1603,6 +1606,7 @@ action enablement
totalCount= fTestRunSession.getTotalCount();
errorCount= fTestRunSession.getErrorCount();
failureCount= fTestRunSession.getFailureCount();
+ assumptionFailureCount = fTestRunSession.getAssumptionFailureCount();
hasErrorsOrFailures= errorCount + failureCount > 0;
stopped= fTestRunSession.isStopped();
} else {
@@ -1611,12 +1615,13 @@ action enablement
totalCount= 0;
errorCount= 0;
failureCount= 0;
+ assumptionFailureCount = 0;
hasErrorsOrFailures= false;
stopped= false;
}
fCounterPanel.setTotal(totalCount);
- fCounterPanel.setRunValue(startedCount, ignoredCount);
+ fCounterPanel.setRunValue(startedCount, ignoredCount, assumptionFailureCount);
fCounterPanel.setErrorValue(errorCount);
fCounterPanel.setFailureValue(failureCount);
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestSessionLabelProvider.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestSessionLabelProvider.java
index 93b2693..517e3b9 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestSessionLabelProvider.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestSessionLabelProvider.java
@@ -31,6 +31,7 @@ import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelP
import org.eclipse.jdt.internal.junit.BasicElementLabels;
import org.eclipse.jdt.internal.junit.Messages;
import org.eclipse.jdt.internal.junit.model.TestCaseElement;
+import org.eclipse.jdt.internal.junit.model.TestElement;
import org.eclipse.jdt.internal.junit.model.TestSuiteElement;
import org.eclipse.jdt.internal.junit.model.TestElement.Status;
@@ -129,6 +130,9 @@ public class TestSessionLabelProvider extends LabelProvider implements IStyledLa
@Override
public Image getImage(Object element) {
+ if (element instanceof TestElement && ((TestElement) element).isAssumptionFailure())
+ return fTestRunnerPart.fTestAssumptionFailureIcon;
+
if (element instanceof TestCaseElement) {
TestCaseElement testCaseElement= ((TestCaseElement) element);
if (testCaseElement.isIgnored())
diff --git a/org.eclipse.jdt.junit4.runtime/src/org/eclipse/jdt/internal/junit4/runner/JUnit4TestListener.java b/org.eclipse.jdt.junit4.runtime/src/org/eclipse/jdt/internal/junit4/runner/JUnit4TestListener.java
index dbb5677..7636d1c 100644
--- a/org.eclipse.jdt.junit4.runtime/src/org/eclipse/jdt/internal/junit4/runner/JUnit4TestListener.java
+++ b/org.eclipse.jdt.junit4.runtime/src/org/eclipse/jdt/internal/junit4/runner/JUnit4TestListener.java
@@ -39,6 +39,19 @@ public class JUnit4TestListener extends RunListener {
}
}
+ private static class AssumptionFailedTestIdentifier extends JUnit4Identifier {
+ public AssumptionFailedTestIdentifier(Description description) {
+ super(description);
+ }
+ @Override
+ public String getName() {
+ String name= super.getName();
+ if (name != null)
+ return MessageIds.ASSUMPTION_FAILED_TEST_PREFIX + name;
+ return null;
+ }
+ }
+
private final IListensToTestExecutions fNotified;
@@ -48,15 +61,25 @@ public class JUnit4TestListener extends RunListener {
@Override
public void testStarted(Description plan) throws Exception {
- fNotified.notifyTestStarted(getIdentifier(plan));
+ fNotified.notifyTestStarted(getIdentifier(plan, false, false));
}
@Override
public void testFailure(Failure failure) throws Exception {
+ testFailure(failure, false);
+ }
+
+ @Override
+ public void testAssumptionFailure(Failure failure) {
+ testFailure(failure, true);
+ }
+
+ private void testFailure(Failure failure, boolean assumptionFailed) {
+ ITestIdentifier identifier= getIdentifier(failure.getDescription(), false, assumptionFailed);
TestReferenceFailure testReferenceFailure;
try {
Throwable exception= failure.getException();
- String status= exception instanceof AssertionError ? MessageIds.TEST_FAILED : MessageIds.TEST_ERROR;
+ String status= (assumptionFailed || exception instanceof AssertionError) ? MessageIds.TEST_FAILED : MessageIds.TEST_ERROR;
FailedComparison comparison= null;
if (exception instanceof junit.framework.ComparisonFailure) {
junit.framework.ComparisonFailure comparisonFailure= (junit.framework.ComparisonFailure) exception;
@@ -65,11 +88,11 @@ public class JUnit4TestListener extends RunListener {
org.junit.ComparisonFailure comparisonFailure= (org.junit.ComparisonFailure) exception;
comparison= new FailedComparison(comparisonFailure.getExpected(), comparisonFailure.getActual());
}
- testReferenceFailure= new TestReferenceFailure(getIdentifier(failure.getDescription()), status, failure.getTrace(), comparison);
+ testReferenceFailure= new TestReferenceFailure(identifier, status, failure.getTrace(), comparison);
} catch (RuntimeException e) {
StringWriter stringWriter= new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
- testReferenceFailure= new TestReferenceFailure(getIdentifier(failure.getDescription()), MessageIds.TEST_FAILED, stringWriter.getBuffer().toString(), null);
+ testReferenceFailure= new TestReferenceFailure(identifier, MessageIds.TEST_FAILED, stringWriter.getBuffer().toString(), null);
}
fNotified.notifyTestFailed(testReferenceFailure);
}
@@ -77,17 +100,21 @@ public class JUnit4TestListener extends RunListener {
@Override
public void testIgnored(Description plan) throws Exception {
// Send message to listeners which would be stale otherwise
- ITestIdentifier identifier= new IgnoredTestIdentifier(plan);
+ ITestIdentifier identifier= getIdentifier(plan, true, false);
fNotified.notifyTestStarted(identifier);
fNotified.notifyTestEnded(identifier);
}
@Override
public void testFinished(Description plan) throws Exception {
- fNotified.notifyTestEnded(getIdentifier(plan));
+ fNotified.notifyTestEnded(getIdentifier(plan, false, false));
}
- private ITestIdentifier getIdentifier(Description plan) {
+ private ITestIdentifier getIdentifier(Description plan, boolean ignored, boolean assumptionFailed) {
+ if (ignored)
+ return new IgnoredTestIdentifier(plan);
+ if (assumptionFailed)
+ return new AssumptionFailedTestIdentifier(plan);
return new JUnit4Identifier(plan);
}
}