jUnit Plugin (quokka.plugin.junit:0.3, namespace=junit)

The jUnit plugin runs unit and integration tests using the jUnit test framework.

Minor Targets

test Implements quokka.plugin.lifecycle:test
integration-test Implements quokka.plugin.lifecycle:integration-test-impl

Properties:

The following properties are common to be targets. All properties are optional unless stated otherwise.

printSummary Print one-line statistics for each testcase. Can take the values on, off, and withOutAndErr. withOutAndErr is the same as on but also includes the output of the test as written to System.out and System.err. Defaults to off.
fork Run the tests in a separate VM. Default is false if unspecified, but the quokka default is true
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. Default if unspecified is perTest, but the quokka default is once.
haltOnError Stop the build process if an error occurs during the test run. No; default is off
errorProperty The name of a property to set in the event of an error.
haltOnFailure Stop the build process if a test fails (errors are considered failures as well). Default is off
failureProperty The name of a property to set in the event of a failure (errors are considered failures as well).
filterTrace Filter out Junit and Ant stack frames from error and failure stack traces. Default is on.
timeout Cancel the individual tests if they don't finish in the given time (measured in milliseconds). Ignored if fork is disabled.
maxMemory Maximum amount of memory to allocate to the forked VM. Ignored if fork is disabled.
jvm The command used to invoke the Java Virtual Machine, default is 'java'. The command is resolved by java.lang.Runtime.exec(). Ignored if fork is disabled. Default is java.
dir The directory in which to invoke the VM. Ignored if fork is disabled.
newEnvironment Do not propagate the old environment when new environment variables are specified. Ignored if fork is disabled.Default is false.
showOutput Send any output generated by tests to Ant's logging system as well as to the formatters. By default only the formatters receive the output.
outputToFormatters Send any output generated by tests to the test formatters. This is "true" by default.
tempDir Where Ant should place temporary files.Default is the project's base directory.
reloading Whether or not a new classloader should be instantiated for each test case.
Ignore if fork is set to true. Default is true.
cloneVm If set to true true, then all system properties and the bootClassPath of the forked Java Virtual Machine will be the same as those of the Java VM running Ant. Default is "false" (ignored if fork is disabled).
jvmArgs Arguments passed to the JVM when the unit tests are forked.
sysproperty A map of system properties passed to the JVM when forked. e.g. sysproperty[key]=value sets a system property of key to value.

Nested Properties:

batchTest is the root of a map of batch tests. Each batchTest has the following properties. See the default properties above for an example.

rc A quokka resource collection (e.g. a file set).
fork Run the tests in a separate VM. Overrides value set in <junit>.
haltOnError Stop the build process if an error occurs during the test run. Overrides value set in <junit>.
errorProperty The name of a property to set in the event of an error. Overrides value set in <junit>.
haltOnFailure Stop the build process if a test fails (errors are considered failures as well). Overrides value set in <junit>.
failureProperty The name of a property to set in the event of a failure (errors are considered failures as well). Overrides value set in <junit>
filterTrace Filter out Junit and Ant stack frames from error and failure stack traces. Overrides value set in <junit>.
toDir Directory to write the reports to.Default is the current directory.
if Only run tests if the named property is set.
unless Only run tests if the named property is not set.

formatter

The results of the tests can be printed in different formats. Output will always be sent to a file, unless you set the useFile attribute to false. The name of the file is determined by the name of the test and can be set by the outfile attribute of <test>.

There are three predefined formatters - one prints the test results in XML format, the other emits plain text. The formatter named brief will only print detailed information for testcases that failed, while plain gives a little statistics line for all test cases. Custom formatters that need to implement org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter can be specified.

If you use the XML formatter, it may not include the same output that your tests have written as some characters are illegal in XML documents and will be dropped.

See the default properties above for an example.

type Use a predefined formatter (either xml, plain, or brief).
className Name of a custom formatter class.
extension Extension to append to the output filename. Mandatory if className has been used.
useFile Boolean that determines whether output should be sent to a file.Default is true.
if Only use formatter if the named property is set. Default is true.
unless Only use formatter if the named property is not set. Default is true.

test

  • prefix: q.junit.test
  • Implements: quokka.plugin.lifecycle:test

Default Properties

batchTest[0]rc.set.dir ${q.lifecycle.testCompileOutput}
batchTest[0]rc.set.excludes **/Abstract*,**/*ITest.class
batchTest[0]rc.set.includes **/*Test.class
batchTest[0]toDir ${q.project.targetDir}/test/junit
cloneVm true
fork true
forkMode once
formatter.type xml
tempDir ${q.project.targetDir}/test/junit

integration-test

  • prefix: q.junit.itest
  • Implements: quokka.plugin.lifecycle:integration-test-impl

Default Properties

batchTest[0]rc.set.dir ${q.lifecycle.testCompileOutput}
batchTest[0]rc.set.excludes **/Abstract*
batchTest[0]rc.set.includes **/*ITest.class
batchTest[0]toDir ${q.project.targetDir}/test/junit
cloneVm true
fork true
forkMode once
formatter.type xml
tempDir ${q.project.targetDir}/test/junit

Plugin Paths

runtime : Runtime class path

quokka.core.plugin-spi plugin-spi 0.3

quokka.plugin.lifecycle lifecycle 0.3

quokka.core.plugin-spi plugin-spi 0.3

apache.ant ant 1.7.1

quokka.core.bootstrap-util bootstrap-util 0.3

quokka.core.bootstrap-util bootstrap-util 0.3

apache.ant ant 1.7.1

apache.ant junit 1.7.1