diff --git a/WHATSNEW b/WHATSNEW index 15ab13410..c25a17b56 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -12,6 +12,16 @@ Other changes: * javaversion condition now has a new "atmost" attribute. See the javaversion manual for more details + * The "listener" nested element of the "junitlauncher" task now has a new + "useLegacyReportingName" attribute which can be used to control the test + identifiers names that get reported by the listener. See the junitlauncher + manual for more details. + Note that this change also introduces a new "setUseLegacyReportingName" method + on the org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter + interface. This will break backward compatibility with any of your custom + result formatters which implemented this interface and such implementations + are now expected to implement this new method. + Changes from Ant 1.10.8 TO Ant 1.10.9 ===================================== diff --git a/manual/Tasks/junitlauncher.html b/manual/Tasks/junitlauncher.html index ec14e0357..4a96e7149 100644 --- a/manual/Tasks/junitlauncher.html +++ b/manual/Tasks/junitlauncher.html @@ -402,6 +402,14 @@ is not set.
Since Ant 1.10.10
+junitlauncher
, regularly/multiple times,
* as and when any content is generated on the standard output stream during the test execution.
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/Constants.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/Constants.java
index ddd590256..711790737 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/Constants.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/Constants.java
@@ -48,6 +48,7 @@ public final class Constants {
public static final String LD_XML_ATTR_SEND_SYS_ERR = "sendSysErr";
public static final String LD_XML_ATTR_SEND_SYS_OUT = "sendSysOut";
public static final String LD_XML_ATTR_LISTENER_RESULT_FILE = "resultFile";
+ public static final String LD_XML_ATTR_LISTENER_USE_LEGACY_REPORTING_NAME = "useLegacyReportingName";
private Constants() {
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 c600e60d4..ce9fdee1d 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
@@ -28,6 +28,7 @@ import javax.xml.stream.XMLStreamWriter;
import static org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.Constants.LD_XML_ATTR_CLASS_NAME;
import static org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.Constants.LD_XML_ATTR_LISTENER_RESULT_FILE;
+import static org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.Constants.LD_XML_ATTR_LISTENER_USE_LEGACY_REPORTING_NAME;
import static org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.Constants.LD_XML_ATTR_OUTPUT_DIRECTORY;
import static org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.Constants.LD_XML_ATTR_SEND_SYS_ERR;
import static org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.Constants.LD_XML_ATTR_SEND_SYS_OUT;
@@ -51,6 +52,7 @@ public class ListenerDefinition {
private boolean sendSysOut;
private boolean sendSysErr;
private String outputDir;
+ private boolean useLegacyReportingName = true;
public ListenerDefinition() {
@@ -135,6 +137,26 @@ public class ListenerDefinition {
return this.outputDir;
}
+ /**
+ *
+ * @return Returns {@code true} if legacy reporting name (JUnit 4 style) is to be used.
+ * Else returns {@code false}.
+ * @since Ant 1.10.10
+ */
+ public boolean isUseLegacyReportingName() {
+ return useLegacyReportingName;
+ }
+
+ /**
+ * Set the test identifier reporting style
+ * @param useLegacyReportingName {@code true} if legacy reporting name (JUnit 4 style) is to
+ * be used. Else {@code false}.
+ * @since Ant 1.10.10
+ */
+ public void setUseLegacyReportingName(final boolean useLegacyReportingName) {
+ this.useLegacyReportingName = useLegacyReportingName;
+ }
+
public boolean shouldUse(final Project project) {
final PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(project);
return propertyHelper.testIfCondition(this.ifProperty) && propertyHelper.testUnlessCondition(this.unlessProperty);
@@ -157,6 +179,7 @@ public class ListenerDefinition {
writer.writeAttribute(LD_XML_ATTR_CLASS_NAME, this.className);
writer.writeAttribute(LD_XML_ATTR_SEND_SYS_ERR, Boolean.toString(this.sendSysErr));
writer.writeAttribute(LD_XML_ATTR_SEND_SYS_OUT, Boolean.toString(this.sendSysOut));
+ writer.writeAttribute(LD_XML_ATTR_LISTENER_USE_LEGACY_REPORTING_NAME, Boolean.toString(this.useLegacyReportingName));
if (this.outputDir != null) {
writer.writeAttribute(LD_XML_ATTR_OUTPUT_DIRECTORY, this.outputDir);
}
@@ -187,6 +210,11 @@ public class ListenerDefinition {
if (resultFile != null) {
listenerDef.setResultFile(resultFile);
}
+ final String useLegacyReportingName = reader.getAttributeValue(null,
+ LD_XML_ATTR_LISTENER_USE_LEGACY_REPORTING_NAME);
+ if (useLegacyReportingName != null) {
+ listenerDef.setUseLegacyReportingName(Boolean.parseBoolean(useLegacyReportingName));
+ }
reader.nextTag();
reader.require(XMLStreamConstants.END_ELEMENT, null, LD_XML_ELM_LISTENER);
return listenerDef;
diff --git a/src/tests/junit/org/example/junitlauncher/Tracker.java b/src/tests/junit/org/example/junitlauncher/Tracker.java
index ba31ec872..ec5f30a0c 100644
--- a/src/tests/junit/org/example/junitlauncher/Tracker.java
+++ b/src/tests/junit/org/example/junitlauncher/Tracker.java
@@ -73,6 +73,11 @@ public class Tracker implements TestResultFormatter {
this.context = context;
}
+ @Override
+ public void setUseLegacyReportingName(final boolean useLegacyReportingName) {
+ // do nothing
+ }
+
@Override
public void close() throws IOException {
this.writer.flush();