Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Remove 'dummy' results from junit formatter #1331

Merged
merged 1 commit into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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