aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java_tools/junitrunner
diff options
context:
space:
mode:
authorGravatar philwo <philwo@google.com>2018-03-09 01:17:49 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-09 01:20:06 -0800
commit2ee6dd262bcf5fd890e24d5f185616b8ab259608 (patch)
tree36b88077608a8ddc3539354353767dd456287604 /src/java_tools/junitrunner
parentb961b0ad6cc2578b98d0a307581e23e73392ad02 (diff)
Automated rollback of commit 3edf41b70de9bb1a8702d0342beeb2ad13898d71.
*** Reason for rollback *** Rollback was requested by original authors @hmemcpy and @ittaiz in #3201: "We found a problem with this patch... seems that tests that are added dynamically by the test runner (in our case, specs2 'examples' that are generated with Fragments.foreach) do not appear in the xml!" This should be part of 0.12.0-rc1, otherwise that release will have the above mentioned regression. *** Original change description *** Skipping writing FILTERED tests to test.xml This fixes #3201 by preventing tests that haven't actually run to be written to the test.xml. This is consistent with how e.g. surefire reports work, tests that were filtered out do not appear in the xml. This allows changing the Bazel plugin in such a way that does not depend on `time` being 0.0. Closes #4596. PiperOrigin-RevId: 188455315
Diffstat (limited to 'src/java_tools/junitrunner')
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/AntXmlResultWriter.java3
-rw-r--r--src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/model/AntXmlResultWriterTest.java91
2 files changed, 0 insertions, 94 deletions
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/AntXmlResultWriter.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/AntXmlResultWriter.java
index 4c0e794fb6..8ee4ba3a64 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/AntXmlResultWriter.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/AntXmlResultWriter.java
@@ -112,9 +112,6 @@ public final class AntXmlResultWriter implements XmlResultWriter {
private void writeTestCases(XmlWriter writer, TestResult result,
Iterable<Throwable> parentFailures) throws IOException {
for (TestResult child : result.getChildResults()) {
- if (child.getStatus() == TestResult.Status.FILTERED) {
- continue;
- }
if (child.getChildResults().isEmpty()) {
writeTestCase(writer, child, parentFailures);
}
diff --git a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/model/AntXmlResultWriterTest.java b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/model/AntXmlResultWriterTest.java
deleted file mode 100644
index 3b208388f1..0000000000
--- a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/model/AntXmlResultWriterTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2018 The Bazel Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.testing.junit.runner.model;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.Description;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class AntXmlResultWriterTest {
- private static final long NOW = 1;
- private static TestSuiteNode root;
- private static XmlWriter writer;
- private static AntXmlResultWriter resultWriter;
- private static StringWriter stringWriter;
-
- @Before
- public void before() {
- stringWriter = new StringWriter();
- writer = XmlWriter.createForTesting(stringWriter);
- resultWriter = new AntXmlResultWriter();
- root = new TestSuiteNode(Description.createSuiteDescription("root"));
- }
-
- @Test
- public void allPassingTestCasesWritten() throws IOException {
- TestSuiteNode parent = createTestSuite();
- TestCaseNode test1 = createTestCase(parent);
- TestCaseNode test2 = createTestCase(parent);
- runToCompletion(test1);
- runToCompletion(test2);
-
- resultWriter.writeTestSuites(writer, root.getResult());
- String resultXml = stringWriter.toString();
- assertThat(resultXml).contains("<testcase name='testCase1'");
- assertThat(resultXml).contains("<testcase name='testCase2'");
- }
-
- @Test
- public void testFilteredCasesNotWritten() throws IOException {
- TestSuiteNode parent = createTestSuite();
- TestCaseNode test1 = createTestCase(parent);
- runToCompletion(test1);
-
- createTestCase(parent); // creates a test case that is FILTERED by default
-
- resultWriter.writeTestSuites(writer, root.getResult());
-
- String resultXml = stringWriter.toString();
- assertThat(resultXml).contains("<testcase name='testCase1'");
- assertThat(resultXml).doesNotContain("<testcase name='testCase2'");
- }
-
- private void runToCompletion(TestCaseNode test) {
- test.started(NOW);
- test.finished(NOW + 1);
- }
-
- private TestCaseNode createTestCase(TestSuiteNode parent) {
- int idx = parent.getChildren().size() + 1;
- TestCaseNode testCase =
- new TestCaseNode(Description.createSuiteDescription("testCase" + idx), parent);
- parent.addTestCase(testCase);
- return testCase;
- }
-
- private TestSuiteNode createTestSuite() {
- Description suite = Description.createSuiteDescription(TestCaseNodeTest.TestSuite.class);
- TestSuiteNode parent = new TestSuiteNode(suite);
- root.addTestSuite(parent);
- return parent;
- }
-}