Skip to content

Commit

Permalink
don't write 'dummy' results when no tests ran
Browse files Browse the repository at this point in the history
  • Loading branch information
kutzi authored and mpkorstanje committed Mar 9, 2018
1 parent 5d3e747 commit 23ce675
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
13 changes: 0 additions & 13 deletions core/src/main/java/cucumber/runtime/formatter/JUnitFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ private void finishReport() {
rootElement.setAttribute("failures", String.valueOf(rootElement.getElementsByTagName("failure").getLength()));
rootElement.setAttribute("skipped", String.valueOf(rootElement.getElementsByTagName("skipped").getLength()));
rootElement.setAttribute("time", sumTimes(rootElement.getElementsByTagName("testcase")));
if (rootElement.getElementsByTagName("testcase").getLength() == 0) {
addDummyTestCase(); // to avoid failed Jenkins jobs
}
TransformerFactory transfac = TransformerFactory.newInstance();
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.INDENT, "yes");
Expand All @@ -157,16 +154,6 @@ private void finishReport() {
}
}

private void addDummyTestCase() {
Element dummy = doc.createElement("testcase");
dummy.setAttribute("classname", "dummy");
dummy.setAttribute("name", "dummy");
rootElement.appendChild(dummy);
Element skipped = doc.createElement("skipped");
skipped.setAttribute("message", "No features found");
dummy.appendChild(skipped);
}

private String sumTimes(NodeList testCaseNodes) {
double totalDurationSecondsForAllTimes = 0.0d;
for( int i = 0; i < testCaseNodes.getLength(); i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,22 +499,6 @@ public void should_format_scenario_outlines_with_arguments_in_name() throws Thro
assertXmlEqual(expected, formatterOutput);
}

@Test
public void should_add_dummy_testcase_if_no_scenarios_are_run_to_aviod_failed_jenkins_jobs() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature",
"Feature: feature name\n");

String formatterOutput = runFeatureWithJUnitFormatter(feature);

String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
"<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" time=\"0\">\n" +
" <testcase classname=\"dummy\" name=\"dummy\">\n" +
" <skipped message=\"No features found\" />\n" +
" </testcase>\n" +
"</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}

private File runFeaturesWithJunitFormatter(final List<String> featurePaths) throws IOException {
return runFeaturesWithJunitFormatter(featurePaths, false);
}
Expand Down

0 comments on commit 23ce675

Please sign in to comment.