Browse Source

junitlauncher - Support extension attribute for listeners

This closes #168 pull request at github.com/apache/ant
master
Aleksei Zotov Jaikiran Pai 3 years ago
parent
commit
c8bc470774
6 changed files with 37 additions and 10 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +5
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +10
    -3
      manual/Tasks/junitlauncher.html
  5. +1
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java
  6. +16
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java

+ 1
- 0
CONTRIBUTORS View File

@@ -8,6 +8,7 @@ Adam Sotona
Adrian Nistor Adrian Nistor
Adrien Grand Adrien Grand
Aleksandr Ishutin Aleksandr Ishutin
Aleksei Zotov
Alex Alex
Alex Rosen Alex Rosen
Alexander Grund Alexander Grund


+ 5
- 0
WHATSNEW View File

@@ -8,6 +8,11 @@ Other changes:
repackaged Jakarta Mail package rather than javax Mail. repackaged Jakarta Mail package rather than javax Mail.
Github Pull Request #161 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 Changes from Ant 1.10.11 TO Ant 1.10.12
======================================= =======================================




+ 4
- 0
contributors.xml View File

@@ -62,6 +62,10 @@
<first>Aleksandr</first> <first>Aleksandr</first>
<last>Ishutin</last> <last>Ishutin</last>
</name> </name>
<name>
<first>Aleksei</first>
<last>Zotov</last>
</name>
<name> <name>
<first>Alex</first> <first>Alex</first>
<last></last> <last></last>


+ 10
- 3
manual/Tasks/junitlauncher.html View File

@@ -354,7 +354,7 @@
If no value is specified for this attribute and the listener implements If no value is specified for this attribute and the listener implements
the <code>org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter</code> the <code>org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter</code>
then the file name will be defaulted to and will be of the then the file name will be defaulted to and will be of the
form <code>TEST-<i>testname</i>.<i>formatter-specific-extension</i></code>
form <code>TEST-<i>testname</i>.<i>extension</i></code>
(ex: <samp>TEST-org.myapp.SomeTest.xml</samp> for the <q>legacy-xml</q> type (ex: <samp>TEST-org.myapp.SomeTest.xml</samp> for the <q>legacy-xml</q> type
formatter) formatter)
</p> </p>
@@ -366,6 +366,13 @@
</td> </td>
<td>No</td> <td>No</td>
</tr> </tr>
<tr>
<td>extension</td>
<td>Extension to append to the output filename.
<p><em>Since Ant 1.10.13</em></p>
</td>
<td>No; defaults to <q>xml</q> for the <q>legacy-xml</q> formatter and to <q>txt</q> for the rest</td>
</tr>
<tr> <tr>
<td>outputDir</td> <td>outputDir</td>
<td>Directory into which to create the output of the listener. <td>Directory into which to create the output of the listener.
@@ -406,10 +413,10 @@
<tr> <tr>
<td>useLegacyReportingName</td> <td>useLegacyReportingName</td>
<td>Set to true, if the test identifiers reported by this listener should use legacy (JUnit4 <td>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.
<p><em>Since Ant 1.10.10</em></p> <p><em>Since Ant 1.10.10</em></p>
</td> </td>
<td>No</td>
<td>No; defaults to <q>true</q></td>
</tr> </tr>
</table> </table>




+ 1
- 7
src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java View File

@@ -282,13 +282,7 @@ public class LauncherSupport {
final StringBuilder sb = new StringBuilder("TEST-"); final StringBuilder sb = new StringBuilder("TEST-");
sb.append(testRequest.getName() == null ? "unknown" : testRequest.getName()); sb.append(testRequest.getName() == null ? "unknown" : testRequest.getName());
sb.append("."); 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(); filename = sb.toString();
} }
if (listener.getOutputDir() != null) { if (listener.getOutputDir() != null) {


+ 16
- 0
src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/ListenerDefinition.java View File

@@ -49,6 +49,7 @@ public class ListenerDefinition {
private String unlessProperty; private String unlessProperty;
private String className; private String className;
private String resultFile; private String resultFile;
private String extension = "txt";
private boolean sendSysOut; private boolean sendSysOut;
private boolean sendSysErr; private boolean sendSysErr;
private String outputDir; private String outputDir;
@@ -94,6 +95,7 @@ public class ListenerDefinition {
} }
case LEGACY_XML: { case LEGACY_XML: {
this.setClassName("org.apache.tools.ant.taskdefs.optional.junitlauncher.LegacyXmlResultFormatter"); this.setClassName("org.apache.tools.ant.taskdefs.optional.junitlauncher.LegacyXmlResultFormatter");
this.setExtension("xml");
break; break;
} }
} }
@@ -107,6 +109,20 @@ public class ListenerDefinition {
return this.resultFile; 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) { public void setSendSysOut(final boolean sendSysOut) {
this.sendSysOut = sendSysOut; this.sendSysOut = sendSysOut;
} }


Loading…
Cancel
Save