From 911c5901fc2f65f707c8dd1866455bec8e19261c Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Thu, 12 Oct 2006 21:41:08 +0000 Subject: [PATCH] opps: restore correct behavour for setting basetest attributes git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@463447 13f79535-47bb-0310-9956-ffa450edef68 --- .../taskdefs/optional/junit/JUnitTask.java | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) 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 d935ebfb4..dce1b3d07 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 @@ -492,6 +492,27 @@ public class JUnitTask extends Task { newEnvironment = newenv; } + /** + * Preset the attributes of the test + * before configuration in the build + * script. + * This allows attributes in the task + * be be defaults for the tests, but allows + * individual tests to override the defaults. + */ + private void preConfigure(BaseTest test) { + test.setFiltertrace(filterTrace); + test.setHaltonerror(haltOnError); + if (errorProperty != null) { + test.setErrorProperty(errorProperty); + } + test.setHaltonfailure(haltOnFail); + if (failureProperty != null) { + test.setFailureProperty(failureProperty); + } + test.setFork(fork); + } + /** * Add a new single testcase. * @param test a new single testcase @@ -501,6 +522,7 @@ public class JUnitTask extends Task { */ public void addTest(JUnitTest test) { tests.addElement(test); + preConfigure(test); } /** @@ -514,6 +536,7 @@ public class JUnitTask extends Task { public BatchTest createBatchTest() { BatchTest test = new BatchTest(getProject()); batchTests.addElement(test); + preConfigure(test); return test; } @@ -722,22 +745,6 @@ 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) {