Skip to content
Permalink
Browse files
[Ref JENKINS-10870] Report exceptions as failures/wrongs instead of s…
…kipped/ignored
  • Loading branch information
swestcott committed Sep 4, 2011
1 parent bbc2a68 commit 403d44ac01395c4e9b88a7b692f6cfd5eabef205
@@ -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;
@@ -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();
}

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

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

public boolean isPassedOverall() {
@@ -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();
@@ -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());
}
}
@@ -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}">
@@ -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());
}
}
@@ -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));
}

0 comments on commit 403d44a

Please sign in to comment.