Skip to content
Permalink
Browse files
[FIXED JENKINS-25021] If the background failed then the test may not …
…be correctly marked as failed in some cicumstances.

Don't reset the failed state flag for skipped tests.
  • Loading branch information
James Nord committed Oct 7, 2014
1 parent 9548a92 commit 64dfc376835f8bf0fe2ec0bfd7ebe6a9f2df95ac
@@ -132,16 +132,21 @@ void addStepResult(StepResult stepResult) {
@Override
public void tally() {
duration = 0.0f;

failed = false;
skipped = false;

for (StepResult sr : stepResults) {
sr.tally();
if (sr.getFailCount() != 0) {
failed = true;
skipped = false;
}
else if (sr.getSkipCount() != 0) {
failed = false;
skipped = true;
if (!failed) {
// only change the flags if we haven't had a failure
if (sr.getFailCount() != 0) {
failed = true;
skipped = false;
}
else if (sr.getSkipCount() != 0) {
failed = false;
skipped = true;
}
}
duration += sr.getDuration();
}
@@ -88,8 +88,8 @@ public void testBackgroundFailure() throws Exception {
assertThat("Correct # of passing tests", testresult.getPassCount(), is(7));
assertThat("Correct # of failing tests", testresult.getFailCount(), is(1));
assertThat("Correct # of skipped tests", testresult.getSkipCount(), is(0));
assertThat("Duration is correct", testresult.getDuration(), is(0.12737842F));
assertThat("Duration string is correct", testresult.getDurationString(), is("0.12 sec"));
assertThat("Duration is correct", testresult.getDuration(), is(0.33427134F));
assertThat("Duration string is correct", testresult.getDurationString(), is("0.33 sec"));
assertThat("Correct # of children", testresult.getChildren(), hasSize(3));
assertThat("Correct # of features", testresult.getFeatures(), hasSize(3));

@@ -149,7 +149,9 @@ public void testUndefinedStep() throws Exception {

// Get the individual Features and check their scenarios.
}




private static File getResourceAsFile(String resource) throws Exception {
URL url = CucumberJSONParserTest.class.getResource(resource);
Assert.assertNotNull("Resource " + resource + " could not be found", url);
@@ -21,15 +21,39 @@
{
"result": {
"duration": 103446466,
"status": "failed",
"error_message": "java.lang.reflect.InvocationTargetException"
"status": "passed"
},
"name": "a calculator I just turned on",
"keyword": "Given ",
"line": 5,
"match": {
"location": "RpnCalculatorStepdefs.a_calculator_I_just_turned_on()"
}
},
{
"result": {
"duration": 103446466,
"status": "failed",
"error_message": "java.lang.reflect.InvocationTargetException"
},
"name": "I want to fail this step",
"keyword": "Given ",
"line": 6,
"match": {
"location": "RpnCalculatorStepdefs.i_want_to_fail_this_step()"
}
},
{
"result": {
"duration": 103446466,
"status": "skipped"
},
"name": "some step that is skipped",
"keyword": "Given ",
"line": 5,
"match": {
"location": "RpnCalculatorStepdefs.a_method()"
}
}
],
"type": "background"

0 comments on commit 64dfc37

Please sign in to comment.