提交 24293ec2 编写于 作者: C Christoph Kutzinski

Added CaseResult#isFailed to complement existing methods isPassed and isSkipped

上级 786e617b
......@@ -24,9 +24,11 @@
package hudson.tasks.junit;
import org.jvnet.localizer.Localizable;
import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.tasks.test.TestResult;
import org.dom4j.Element;
import org.kohsuke.stapler.export.Exported;
......@@ -36,6 +38,7 @@ import java.util.*;
import java.util.logging.Logger;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
/**
* One test result.
......@@ -299,7 +302,7 @@ public final class CaseResult extends TestResult implements Comparable<CaseResul
@Override
public int getFailCount() {
if (!isPassed() && !isSkipped()) return 1; else return 0;
if (isFailed()) return 1; else return 0;
}
@Override
......@@ -416,7 +419,7 @@ public final class CaseResult extends TestResult implements Comparable<CaseResul
*/
@Override
public Collection<? extends TestResult> getFailedTests() {
return singletonListOrEmpty(!isPassed());
return singletonListOfThisOrEmptyList(isFailed());
}
/**
......@@ -426,7 +429,7 @@ public final class CaseResult extends TestResult implements Comparable<CaseResul
*/
@Override
public Collection<? extends TestResult> getPassedTests() {
return singletonListOrEmpty(isPassed());
return singletonListOfThisOrEmptyList(isPassed());
}
/**
......@@ -436,12 +439,12 @@ public final class CaseResult extends TestResult implements Comparable<CaseResul
*/
@Override
public Collection<? extends TestResult> getSkippedTests() {
return singletonListOrEmpty(isSkipped());
return singletonListOfThisOrEmptyList(isSkipped());
}
private Collection<? extends hudson.tasks.test.TestResult> singletonListOrEmpty(boolean f) {
private Collection<? extends hudson.tasks.test.TestResult> singletonListOfThisOrEmptyList(boolean f) {
if (f)
return Collections.singletonList(this);
return singletonList(this);
else
return emptyList();
}
......@@ -479,6 +482,14 @@ public final class CaseResult extends TestResult implements Comparable<CaseResul
public boolean isSkipped() {
return skipped;
}
/**
* @return true if the test was not skipped and did not pass, false otherwise.
* @since 1.520
*/
public boolean isFailed() {
return !isPassed() && !isSkipped();
}
/**
* Provides the reason given for the test being being skipped.
......
......@@ -179,7 +179,7 @@ public final class PackageResult extends MetaTabulatedResult implements Comparab
List<CaseResult> r = new ArrayList<CaseResult>();
for (ClassResult clr : classes.values()) {
for (CaseResult cr : clr.getChildren()) {
if (!cr.isPassed() && !cr.isSkipped()) {
if (cr.isFailed()) {
r.add(cr);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册