From c524f9ba2269aab3e0126cedba791854d797c592 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Thu, 5 Oct 2006 20:14:03 +0000 Subject: [PATCH] Bugzilla 40682: junit regression git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@453350 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 + .../taskdefs/optional/junit/JUnitTask.java | 60 +++++++++---------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 5d80c4621..0c91e8e45 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -37,6 +37,9 @@ Fixed bugs: * no check for refid when prefix attribute is set in zipfileset. Bugzilla report 30498. +* fix for junit4 issue introducted since beta2. + Bugzilla report 40682. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index dd1a9ab20..887db1206 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -154,6 +154,14 @@ public class JUnitTask extends Task { private boolean splitJunit = false; private JUnitTaskMirror delegate; + // Attributes for basetest + private boolean haltOnError = false; + private boolean haltOnFail = false; + private boolean filterTrace = true; + private boolean fork = false; + private String failureProperty; + private String errorProperty; + private static final int STRING_BUFFER_SIZE = 128; /** * @since Ant 1.7 @@ -185,11 +193,7 @@ public class JUnitTask extends Task { * @since Ant 1.5 */ public void setFiltertrace(boolean value) { - Enumeration e = allTests(); - while (e.hasMoreElements()) { - BaseTest test = (BaseTest) e.nextElement(); - test.setFiltertrace(value); - } + this.filterTrace = value; } /** @@ -203,11 +207,7 @@ public class JUnitTask extends Task { * @since Ant 1.2 */ public void setHaltonerror(boolean value) { - Enumeration e = allTests(); - while (e.hasMoreElements()) { - BaseTest test = (BaseTest) e.nextElement(); - test.setHaltonerror(value); - } + this.haltOnError = value; } /** @@ -222,11 +222,7 @@ public class JUnitTask extends Task { * @since Ant 1.4 */ public void setErrorProperty(String propertyName) { - Enumeration e = allTests(); - while (e.hasMoreElements()) { - BaseTest test = (BaseTest) e.nextElement(); - test.setErrorProperty(propertyName); - } + this.errorProperty = propertyName; } /** @@ -241,11 +237,7 @@ public class JUnitTask extends Task { * @since Ant 1.2 */ public void setHaltonfailure(boolean value) { - Enumeration e = allTests(); - while (e.hasMoreElements()) { - BaseTest test = (BaseTest) e.nextElement(); - test.setHaltonfailure(value); - } + this.haltOnFail = value; } /** @@ -260,11 +252,7 @@ public class JUnitTask extends Task { * @since Ant 1.4 */ public void setFailureProperty(String propertyName) { - Enumeration e = allTests(); - while (e.hasMoreElements()) { - BaseTest test = (BaseTest) e.nextElement(); - test.setFailureProperty(propertyName); - } + this.failureProperty = propertyName; } /** @@ -281,11 +269,7 @@ public class JUnitTask extends Task { * @since Ant 1.2 */ public void setFork(boolean value) { - Enumeration e = allTests(); - while (e.hasMoreElements()) { - BaseTest test = (BaseTest) e.nextElement(); - test.setFork(value); - } + this.fork = value; } /** @@ -722,6 +706,22 @@ public class JUnitTask extends Task { * @since Ant 1.2 */ public void execute() throws BuildException { + // Apply the basetest attributes + Enumeration e = allTests(); + while (e.hasMoreElements()) { + BaseTest test = (BaseTest) e.nextElement(); + test.setFiltertrace(filterTrace); + test.setHaltonerror(haltOnError); + if (errorProperty != null) { + test.setErrorProperty(errorProperty); + } + test.setHaltonfailure(haltOnFail); + if (failureProperty != null) { + test.setFailureProperty(failureProperty); + } + test.setFork(fork); + } + ClassLoader myLoader = JUnitTask.class.getClassLoader(); ClassLoader mirrorLoader; if (splitJunit) {