Skip to content

Commit

Permalink
[Ref JENKINS-10870] Report exceptions as failures/wrongs instead of s…
Browse files Browse the repository at this point in the history
…kipped/ignored
  • Loading branch information
swestcott committed Sep 4, 2011
1 parent bbc2a68 commit 403d44a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
19 changes: 15 additions & 4 deletions src/main/java/hudson/plugins/fitnesse/FitnesseResults.java
Expand Up @@ -3,6 +3,7 @@
import hudson.model.AbstractBuild;
import hudson.model.Hudson;
import hudson.model.ModelObject;
import hudson.model.Result;
import hudson.plugins.fitnesse.NativePageCounts.Counts;
import hudson.tasks.test.TestObject;
import hudson.tasks.test.TestResult;
Expand Down Expand Up @@ -94,20 +95,24 @@ public String getName() {
public String getDisplayName() {
return getName();
}

@Override
public int getFailCount() {
return pageCounts.wrong;
return pageCounts.wrong + getExceptionCount();
}

public int getFailOnlyCount() {
return pageCounts.wrong;
}

@Override
public int getPassCount() {
return pageCounts.right;
}

@Override
public int getSkipCount() {
return getIgnoredCount() + getExceptionCount();
return getIgnoredCount();
}

/**
Expand All @@ -125,7 +130,7 @@ public int getExceptionCount() {
}

public boolean isFailedOverall() {
return getFailCount() > 0;
return (getFailCount() > 0 || getExceptionCount() > 0);
}

public boolean isPassedOverall() {
Expand All @@ -143,6 +148,12 @@ public boolean isSkippedOverall() {
return getPassCount() == 0;
}

@Override
public Result getBuildResult() {
if (getFailCount() > 0) return Result.FAILURE;
return null;
}

@Override
public float getDuration() {
if (!durationCalculated) calculateDurationInMillis();
Expand Down
Expand Up @@ -70,7 +70,7 @@ public Object getTarget() {
* Referenced in summary.jelly and FitnesseProjectAction/jobMain.jelly
*/
public String getSummary() {
return String.format("(%s, %d pages: %d wrong, %d ignored or with exceptions)",
return String.format("(%s, %d pages: %d wrong or with exceptions, %d ignored)",
getResult().getName(), getTotalCount(), getFailCount(), getSkipCount());
}
}
Expand Up @@ -6,7 +6,7 @@
<tr class="result-failed"><td><strong>Wrong: ${it.failCount}</strong></td></tr>
<tr><th>Name</th><th>Right</th><th>Wrong</th><th>Ignored</th><th>Exceptions</th></tr>
<j:forEach var="r" items="${it.failedTests}">
<tr><td>${it.toHtml(r)}</td><td>${r.passCount}</td><td>${r.failCount}</td><td>${r.ignoredCount}</td><td>${r.exceptionCount}</td></tr>
<tr><td>${it.toHtml(r)}</td><td>${r.passCount}</td><td>${r.failOnlyCount}</td><td>${r.ignoredCount}</td><td>${r.exceptionCount}</td></tr>
</j:forEach>
</j:if>
<j:if test="${it.skipCount > 0}">
Expand Down
17 changes: 7 additions & 10 deletions src/test/java/hudson/plugins/fitnesse/FitnesseResultsTest.java
Expand Up @@ -58,10 +58,10 @@ public void wrongCountsShouldBeFailedOverall() {
}

@Test
public void exceptionCountsShouldBeSkipped() {
public void exceptionCountsShouldBeFailedOverall() {
for (FitnesseResults results : EXCEPTION) {
Assert.assertFalse(results.getHeadlineText(), results.isFailedOverall());
Assert.assertTrue(results.getHeadlineText(), results.isSkippedOverall());
Assert.assertTrue(results.getHeadlineText(), results.isFailedOverall());
Assert.assertFalse(results.getHeadlineText(), results.isSkippedOverall());
Assert.assertFalse(results.getHeadlineText(), results.isPassedOverall());
}
}
Expand All @@ -85,23 +85,20 @@ public void rightCountsShouldBePassed() {
}

@Test
public void failedTestsShouldIncludeCountsWrong() {
public void failedTestsShouldIncludeCountsWrongAndExceptions() {
FitnesseResults summary = setUpSummaryResults();
Collection<FitnesseResults> failedTests = summary.getFailedTests();
Assert.assertEquals(WRONG.length, failedTests.size());
Assert.assertEquals(WRONG.length + EXCEPTION.length, failedTests.size());
for (FitnesseResults results : WRONG) {
Assert.assertTrue(results.getHeadlineText(), failedTests.contains(results));
}
}

@Test
public void skippedTestsShouldIncludeCountsIgnoredOrExceptions() {
public void skippedTestsShouldIncludeCountsIgnored() {
FitnesseResults summary = setUpSummaryResults();
Collection<FitnesseResults> skippedTests = summary.getSkippedTests();
Assert.assertEquals(EXCEPTION.length + IGNORED.length, skippedTests.size());
for (FitnesseResults results : EXCEPTION) {
Assert.assertTrue(results.getHeadlineText(), skippedTests.contains(results));
}
Assert.assertEquals(IGNORED.length, skippedTests.size());
for (FitnesseResults results : IGNORED) {
Assert.assertTrue(results.getHeadlineText(), skippedTests.contains(results));
}
Expand Down

0 comments on commit 403d44a

Please sign in to comment.