apex-run-test Task

Description

Invoke Apex tests in an org.

It executes the apex run test command.

Note: This task depends on the same external libraries as the junitreport task. See Library Dependencies for more information.

Parameters

In addition to the attributes used by every ant-sf task, this task uses the following attributes:

Attribute Command line equivalent Description Required
synchronous --synchronous Indicates whether test methods from a single Apex class are run synchronously. No; defaults to false.
targetorg --target-org A username or alias for the target org. No
testlevel -test-level Specifies which tests to run. Acceptable values are:
  • RunAllTestsInOrg: all tests in your org and in installed managed packages are run.
  • RunLocalTests: all tests in your org are run, except the ones that originate from installed managed packages.
  • RunSpecifiedTests: only the tests that you specify are run.
No
todir -d The directory to store test run files. No
tofile The file to copy the JUnit results to. No
wait --wait The streaming client socket timeout, in minutes. No; defaults to 6.

Parameters specified as nested elements

class

Specifies an Apex test class name to run. This parameter cannot be used in conjonction with a suite parameter.

suite

Specifies an Apex test suite to run. This parameter cannot be used in conjonction with a class parameter.

test

Specifies an Apex test class name or ID and test method, if applicable, to run.

report

Generate a browsable report.

Parameters
Attribute Description Required
format The format of the generated report. Must be either noframes or frames. No; defaults to frames
styledir The directory where the stylesheets are defined. They must be conforming to the following conventions:
  • frames format: the stylesheet must be named junit-frames.xsl, or junit-frames-saxon.xsl if you are using Saxon 9+.
  • noframes format: the stylesheet must be named junit-noframes.xsl, or junit-noframes-saxon.xsl if you are using Saxon 9+.
No; defaults to embedded stylesheets
todir The directory where the files resulting from the transformation should be written to. No; defaults to current directory

This task assumes the following concerning the frames and noframes formats:

Custom versions of junit-frames.xsl or junit-noframes.xsl must adhere to the above conventions.

Nested element of the report tag
param

Since Ant 1.7, the report tag supports nested param tags. These tags can pass XSL parameters to the stylesheet.

Attribute Description Required
name Name of the XSL parameter Yes
expression Text value to be placed into the param.
Was originally intended to be an XSL expression.
Yes
if The param will only be passed if this property is set. No
unless The param will not be passed if this property is set. No

The built-in stylesheets support the following parameters:

XSL Parameter Description Required
TITLE Title used in <title> and <h1> tags No; defaults to Unit Test Results
classpath

Since Ant 1.9.5. Like for the XSLT task, a nested <classpath> will be used to load the processor.

factory

Since Ant 1.9.5. Like for the XSLT task, a nested <factory> can be used to specify factory settings.

Version: 0.0.0-master