121
Apache Ant JUnit Task
This task is used to run tests from the JUnit testing framework. This task is depend on external libraries that are not included in Apache Ant distribution by default.
The junit.jar and ant.junit.jar both are required to run this task, so put these JAR’s in ANT_HOME/lib location.
The <junit> element is used in build.xml file to implement this task. It also supports a nested element <classpath> which presents path-like structure.
Apache Ant Junit Task Attributes
Attribute | Description | Required |
---|---|---|
printsummary | It prints summery of the test cases. | No |
fork | Run the tests in a separate JVM | No |
forkmode | It controls how many JVMs get created if we want to fork test cases. | No |
haltonerror | It stops the build process if any error occurs. | No |
errorproperty | This property is set in error event. | No |
haltonfailure | It stops the build process if a test fails. | No |
timeout | It cancels the individual tests if they don’t finish in the given time. | No |
maxmemory | Maximum amount of memory to allocate to the forked JVM. | No |
jvm | The command used to invoke JVM. | No |
dir | The directory in which to invoke JVM. | No |
tempdirA directory where Ant should place temporary files.No | reloadingWhether or not a new classloader should be instantiated for each test case.No | clonevmIt makes a clone of the process running in JVM.No |
Let’s see some examples to understand the functionalities of this testing task.
Apache Ant JUnit Task Example
The above example is running a test case defined into TestCase.
This example runs a separate JVM and run test on it. The fork attribute will run a new JVM.
Next TopicApache Ant Telnet Task