This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git


The following commit(s) were added to refs/heads/master by this push:
     new 5981e1b  bz-63680 Fix the LegacyXmlResultFormatter to recursively look 
for a parent testclass name, until it finds one
5981e1b is described below

commit 5981e1bff1e095bf85ee4d6565bc0c7ff93f2bb6
Author: Jaikiran Pai <jaiki...@apache.org>
AuthorDate: Fri Aug 23 10:13:47 2019 +0530

    bz-63680 Fix the LegacyXmlResultFormatter to recursively look for a parent 
testclass name, until it finds one
---
 WHATSNEW                                           |  5 +++++
 .../junitlauncher/LegacyXmlResultFormatter.java    | 23 +++++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/WHATSNEW b/WHATSNEW
index 3e4d94e..c70d0c7 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -21,6 +21,11 @@ Fixed bugs:
    has now been fixed.
    Bugzilla Report 63446
 
+ * The "legacy-xml" junitlauncher task's listener would not include
+   @ParameterizedTest testcases in its XML report file. This has now
+   been fixed.
+   Bugzilla Report 63680
+
 Other changes:
 --------------
 
diff --git 
a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LegacyXmlResultFormatter.java
 
b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LegacyXmlResultFormatter.java
index 3f30b31..91caca6 100644
--- 
a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LegacyXmlResultFormatter.java
+++ 
b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LegacyXmlResultFormatter.java
@@ -236,19 +236,14 @@ class LegacyXmlResultFormatter extends 
AbstractJUnitResultFormatter implements T
                     continue;
                 }
                 // find the parent class of this test method
-                final Optional<TestIdentifier> parent = 
testPlan.getParent(testId);
-                if (!parent.isPresent() || 
!parent.get().getSource().isPresent()) {
-                    // we need to know the parent test class, else we aren't 
interested
+                final Optional<ClassSource> parentClassSource = 
findFirstParentClassSource(testId);
+                if (!parentClassSource.isPresent()) {
                     continue;
                 }
-                final TestSource parentSource = parent.get().getSource().get();
-                if (!(parentSource instanceof ClassSource)) {
-                    continue;
-                }
-                final String classname = ((ClassSource) 
parentSource).getClassName();
+                final String classname = 
(parentClassSource.get()).getClassName();
                 writer.writeStartElement(ELEM_TESTCASE);
                 writer.writeAttribute(ATTR_CLASSNAME, classname);
-                writer.writeAttribute(ATTR_NAME, testId.getDisplayName());
+                writer.writeAttribute(ATTR_NAME, 
testId.getLegacyReportingName());
                 final Stats stats = entry.getValue();
                 writer.writeAttribute(ATTR_TIME, String.valueOf((stats.endedAt 
- stats.startedAt) / ONE_SECOND));
                 // skipped element if the test was skipped
@@ -375,6 +370,16 @@ class LegacyXmlResultFormatter extends 
AbstractJUnitResultFormatter implements T
             }
             return Optional.empty();
         }
+
+        private Optional<ClassSource> findFirstParentClassSource(final 
TestIdentifier testId) {
+            final Optional<TestIdentifier> parent = testPlan.getParent(testId);
+            if (!parent.isPresent() || !parent.get().getSource().isPresent()) {
+                return Optional.empty();
+            }
+            final TestSource parentSource = parent.get().getSource().get();
+            return parentSource instanceof ClassSource ? 
Optional.of((ClassSource) parentSource)
+                    : findFirstParentClassSource(parent.get());
+        }
     }
 
 }

Reply via email to