From 23ce6751b83522a53b96e9f89557c1659a192512 Mon Sep 17 00:00:00 2001 From: Christoph Kutzinski Date: Thu, 8 Mar 2018 12:52:20 +0100 Subject: [PATCH] don't write 'dummy' results when no tests ran https://github.com/cucumber/cucumber-jvm/issues/1326 --- .../runtime/formatter/JUnitFormatter.java | 13 ------------- .../runtime/formatter/JUnitFormatterTest.java | 16 ---------------- 2 files changed, 29 deletions(-) diff --git a/core/src/main/java/cucumber/runtime/formatter/JUnitFormatter.java b/core/src/main/java/cucumber/runtime/formatter/JUnitFormatter.java index 3a2b23f544..cce3d0a8d0 100644 --- a/core/src/main/java/cucumber/runtime/formatter/JUnitFormatter.java +++ b/core/src/main/java/cucumber/runtime/formatter/JUnitFormatter.java @@ -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"); @@ -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++ ) { diff --git a/core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java b/core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java index 7693c2034d..ec72bdcb85 100644 --- a/core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java +++ b/core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java @@ -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 = "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - "\n"; - assertXmlEqual(expected, formatterOutput); - } - private File runFeaturesWithJunitFormatter(final List featurePaths) throws IOException { return runFeaturesWithJunitFormatter(featurePaths, false); }