Skip to content

Commit

Permalink
[FIXED JENKINS-7970] JUnit result archiver should only fail builds if…
Browse files Browse the repository at this point in the history
… there are really no results - i.e. also no skipped tests.
  • Loading branch information
kutzi committed Apr 2, 2013
1 parent 809fa1f commit 9bc7e21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion changelog.html
Expand Up @@ -55,7 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
JUnit result archiver should only fail builds if there are really no results - i.e. also no skipped tests.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-7970">issue 7970</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
Expand Up @@ -57,7 +57,6 @@
import org.kohsuke.stapler.StaplerRequest;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -139,8 +138,10 @@ public boolean perform(AbstractBuild build, Launcher launcher,
throw new AbortException(Messages.JUnitResultArchiver_BadXML(testResults));
}
result.freeze(action);
if (result.getPassCount() == 0 && result.getFailCount() == 0)
if (result.isEmpty()) {
// most likely a configuration error in the job - e.g. false pattern to match the JUnit result files
throw new AbortException(Messages.JUnitResultArchiver_ResultIsEmpty());
}

// TODO: Move into JUnitParser [BUG 3123310]
List<Data> data = new ArrayList<Data>();
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/hudson/tasks/junit/TestResult.java
Expand Up @@ -377,6 +377,15 @@ public int getFailCount() {
public int getSkipCount() {
return skippedTests;
}

/**
* Returns <tt>true</tt> if this doesn't have any any test results.
* @since 1.511
*/
@Exported(visibility=999)
public boolean isEmpty() {
return getTotalCount() == 0;
}

@Override
public List<CaseResult> getFailedTests() {
Expand Down

0 comments on commit 9bc7e21

Please sign in to comment.