diff --git a/CONTRIBUTORS b/CONTRIBUTORS index d0e684eef..5cbe06118 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -8,6 +8,7 @@ Adam Sotona Adrian Nistor Adrien Grand Aleksandr Ishutin +Aleksei Zotov Alex Alex Rosen Alexander Grund diff --git a/WHATSNEW b/WHATSNEW index 293f4862e..49c78152c 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -8,6 +8,11 @@ Other changes: repackaged Jakarta Mail package rather than javax Mail. Github Pull Request #161 +* The "listener" element in the junitlauncher task now supports + an "extension" attribute to control the filename extension + of the generated output file from the listener. + Github Pull Request #168 + Changes from Ant 1.10.11 TO Ant 1.10.12 ======================================= diff --git a/contributors.xml b/contributors.xml index 74329cff6..574f45e4f 100644 --- a/contributors.xml +++ b/contributors.xml @@ -62,6 +62,10 @@ Aleksandr Ishutin + + Aleksei + Zotov + Alex diff --git a/manual/Tasks/junitlauncher.html b/manual/Tasks/junitlauncher.html index f8899bb72..0f20648e4 100644 --- a/manual/Tasks/junitlauncher.html +++ b/manual/Tasks/junitlauncher.html @@ -354,7 +354,7 @@ If no value is specified for this attribute and the listener implements the org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter then the file name will be defaulted to and will be of the - form TEST-testname.formatter-specific-extension + form TEST-testname.extension (ex: TEST-org.myapp.SomeTest.xml for the legacy-xml type formatter)

@@ -366,6 +366,13 @@ No + + extension + Extension to append to the output filename. +

Since Ant 1.10.13

+ + No; defaults to xml for the legacy-xml formatter and to txt for the rest + outputDir Directory into which to create the output of the listener. @@ -406,10 +413,10 @@ useLegacyReportingName Set to true, if the test identifiers reported by this listener should use legacy (JUnit4 - style) names. Else set to false. Defaults to true. + style) names. Else set to false.

Since Ant 1.10.10

- No + No; defaults to true diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java index 7bd65e3b0..00b76df8a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java @@ -282,13 +282,7 @@ public class LauncherSupport { final StringBuilder sb = new StringBuilder("TEST-"); sb.append(testRequest.getName() == null ? "unknown" : testRequest.getName()); sb.append("."); - final String suffix; - if ("org.apache.tools.ant.taskdefs.optional.junitlauncher.LegacyXmlResultFormatter".equals(listener.getClassName())) { - suffix = "xml"; - } else { - suffix = "txt"; - } - sb.append(suffix); + sb.append(listener.getExtension()); filename = sb.toString(); } if (listener.getOutputDir() != null) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java index ce9fdee1d..52479a9c9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java @@ -49,6 +49,7 @@ public class ListenerDefinition { private String unlessProperty; private String className; private String resultFile; + private String extension = "txt"; private boolean sendSysOut; private boolean sendSysErr; private String outputDir; @@ -94,6 +95,7 @@ public class ListenerDefinition { } case LEGACY_XML: { this.setClassName("org.apache.tools.ant.taskdefs.optional.junitlauncher.LegacyXmlResultFormatter"); + this.setExtension("xml"); break; } } @@ -107,6 +109,20 @@ public class ListenerDefinition { return this.resultFile; } + /** + * Sets the output file extension for this listener. + * + * @param extension file extension to use + * @since Ant 1.10.13 + */ + public void setExtension(String extension) { + this.extension = extension; + } + + public String getExtension() { + return extension; + } + public void setSendSysOut(final boolean sendSysOut) { this.sendSysOut = sendSysOut; }