diff --git a/WHATSNEW b/WHATSNEW
index c49d36b70..8e7510a84 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -161,6 +161,11 @@ Other changes:
* New "pattern" attribute for selector.
+* has a new forkmode attribute that controls the number of
+ Java VMs that get created when forking tests. This allows you to
+ run all tests in a single forked JVM reducing the overhead of VM
+ creation a lot. Bugzilla Report 24697.
+
Changes from Ant 1.6.0 to Ant 1.6.1
=============================================
diff --git a/build.xml b/build.xml
index f57584416..7e8e1c2ff 100644
--- a/build.xml
+++ b/build.xml
@@ -53,7 +53,7 @@
-
+
diff --git a/docs/manual/OptionalTasks/junit.html b/docs/manual/OptionalTasks/junit.html
index 0fcf47e74..9c78bfaee 100644
--- a/docs/manual/OptionalTasks/junit.html
+++ b/docs/manual/OptionalTasks/junit.html
@@ -67,6 +67,24 @@ elements).
Run the tests in a separate VM. |
No; default is off . |
+
+ forkmode |
+ Controls how many Java Virtual Machines get
+ created if you want to fork some tests. Possible values are
+ "perTest" (the default), "perBatch" and
+ "once". "once" creates only a single Java VM
+ for all tests while "perTest" creates a new VM for each
+ TestCase class. "perBatch" creates a VM for each nested
+ <batchtest> and one collecting all nested
+ <test> s. Note that only tests with the same
+ settings of filtertrace , haltonerror ,
+ haltonfailure , errorproperty and
+ failureproperty can share a VM, so even if you set
+ forkmode to "once", Ant may have to create
+ more than a single Java VM. This attribute is ignored for tests
+ that don't get forked into a new Java VM. |
+ No; default is perTest . |
+
haltonerror |
Stop the build process if an error occurs during the test
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 005b4acb3..5b44f149a 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
@@ -147,7 +147,7 @@ public class JUnitTask extends Task {
private File tmpDir;
private AntClassLoader classLoader = null;
private Permissions perm = null;
- private ForkStyle forkStyle = new ForkStyle("perTest");
+ private ForkMode forkMode = new ForkMode("perTest");
private static final int STRING_BUFFER_SIZE = 128;
@@ -295,8 +295,8 @@ public class JUnitTask extends Task {
*
* @since Ant 1.6.2
*/
- public void setForkStyle(ForkStyle style) {
- this.forkStyle = style;
+ public void setForkMode(ForkMode mode) {
+ this.forkMode = mode;
}
/**
@@ -641,11 +641,11 @@ public class JUnitTask extends Task {
public void execute() throws BuildException {
List testLists = new ArrayList();
- boolean forkPerTest = forkStyle.getValue().equals(ForkStyle.PER_TEST);
- if (forkPerTest || forkStyle.getValue().equals(ForkStyle.ONCE)) {
+ boolean forkPerTest = forkMode.getValue().equals(ForkMode.PER_TEST);
+ if (forkPerTest || forkMode.getValue().equals(ForkMode.ONCE)) {
testLists.addAll(executeOrQueue(getIndividualTests(),
forkPerTest));
- } else { /* forkStyle.getValue().equals(ForkStyle.PER_BATCH) */
+ } else { /* forkMode.getValue().equals(ForkMode.PER_BATCH) */
final int count = batchTests.size();
for (int i = 0; i < count; i++) {
BatchTest batchtest = (BatchTest) batchTests.elementAt(i);
@@ -1379,7 +1379,7 @@ public class JUnitTask extends Task {
* These are the different forking options
* @since 1.6.2
*/
- public static final class ForkStyle extends EnumeratedAttribute {
+ public static final class ForkMode extends EnumeratedAttribute {
/**
* fork once only
@@ -1394,11 +1394,11 @@ public class JUnitTask extends Task {
*/
public static final String PER_BATCH = "perBatch";
- public ForkStyle() {
+ public ForkMode() {
super();
}
- public ForkStyle(String value) {
+ public ForkMode(String value) {
super();
setValue(value);
}
|