ScalaTestAntTask

org.scalatest.tools.ScalaTestAntTask
class ScalaTestAntTask extends Task

An ant task to run ScalaTest. Instructions on how to specify various options are below. See the main documentation for object Runner class for a description of what each of the options does.

To use the ScalaTest ant task, you must first define it in your ant file using taskdef. Here's an example:

<path id="scalatest.classpath">
  <pathelement location="${lib}/scalatest.jar"/>
  <pathelement location="${lib}/scala-library.jar"/>
  <-- scala-actors.jar needed only for ScalaTest <= 1.9.1 on Scala >= 2.10.0 -->
  <pathelement location="${lib}/scala-actors.jar"/>
</path>

<target name="main" depends="dist">
  <taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask">
    <classpath refid="scalatest.classpath"/>
  </taskdef>

  <scalatest ...
</target>

Note that you only need the scala-actors.jar if you are using ScalaTest version 1.9.1 or earlier with Scala 2.10 or later. Once defined, you use the task by specifying information in a scalatest element:

 <scalatest ...>
   ...
 </scalatest>

You can place key value pairs into the config map using nested <config> elements, like this:

 <scalatest>
   <config name="dbname" value="testdb"/>
   <config name="server" value="192.168.1.188"/>

You can specify a runpath using either a runpath attribute and/or nested <runpath> elements, using standard ant path notation:

 <scalatest runpath="serviceuitest-1.1beta4.jar:myjini">

or

 <scalatest>
   <runpath>
     <pathelement location="serviceuitest-1.1beta4.jar"/>
     <pathelement location="myjini"/>
   </runpath>

To add a URL to your runpath, use a <runpathurl> element (since ant paths don't support URLs):

 <scalatest>
   <runpathurl url="http://foo.com/bar.jar"/>

You can specify reporters using nested <reporter> elements, where the type attribute must be one of the following:

  • graphic

  • file

  • memory

  • junitxml

  • html

  • stdout

  • stderr

  • reporterclass

Each may include a config attribute to specify the reporter configuration. Types file, memory, junitxml, html, and reporterclass require additional attributes (the css attribute is optional for the html reporter):

 <scalatest>
   <reporter type="stdout" config="FD"/>
   <reporter type="file" filename="test.out"/>
   <reporter type="memory" filename="target/memory.out"/>
   <reporter type="junitxml" directory="target"/>
   <reporter type="html" directory="target" css="src/main/html/mystylesheet.css"/>
   <reporter type="reporterclass" classname="my.ReporterClass"/>

Specify tags to include and/or exclude using <tagsToInclude> and <tagsToExclude> elements, like this:

 <scalatest>
   <tagsToInclude>
       CheckinTests
       FunctionalTests
   </tagsToInclude>

   <tagsToExclude>
       SlowTests
       NetworkTests
   </tagsToExclude>

Tags to include or exclude can also be specified using attributes tagsToInclude and tagsToExclude, with arguments specified as whitespace- delimited lists.

To specify suites to run, use either a suite attribute or nested <suite> elements:

 <scalatest suite="com.artima.serviceuitest.ServiceUITestkit">

or

 <scalatest>
   <suite classname="com.artima.serviceuitest.ServiceUITestkit"/>

To specify tests to run, use nested <test> elements with either a 'name' or 'substring' attribute:

 <scalatest>
   <test name="hello test"/>
   <test substring="hello"/>

To specify suites using members-only or wildcard package names, use either the membersonly or wildcard attributes, or nested <membersonly> or <wildcard> elements:

 <scalatest membersonly="com.artima.serviceuitest">

or

 <scalatest wildcard="com.artima.joker">

or

 <scalatest>
   <membersonly package="com.artima.serviceuitest"/>
   <wildcard package="com.artima.joker"/>

Use attribute suffixes="[pipe-delimited list of suffixes]" to specify that only classes whose names end in one of the specified suffixes should be included in discovery searches for Suites to test. This can be used to improve discovery time or to limit the scope of a test. E.g.:

 <scalatest suffixes="Spec|Suite">

Use attribute testsfile="[file name]" or nested elements to specify files containing a list of tests to be run. This is used to rerun failed/canceled tests listed in files written by the memory reporter. E.g.:

 <scalatest testsfile="target/memory.out">

or

 <scalatest>
   <testsfile filename="target/memory.out"/>

Use attribute parallel="true" to specify parallel execution of suites. (If the parallel attribute is left out or set to false, suites will be executed sequentially by one thread.) When parallel is true, you can include an optional sortSuites attribute to request that events be sorted on-the-fly so that events for the same suite are reported together, with a timeout, (e.g., sortSuites="true"), and an optional numthreads attribute to specify the number of threads to be created in thread pool (e.g., numthreads="10").

Use attribute haltonfailure="true" to cause ant to fail the build if there's a test failure.

Use attribute fork="true" to cause ant to run the tests in a separate process.

When fork is true, attribute maxmemory may be used to specify the maximum memory size that will be passed to the forked jvm.  For example, the following setting will cause "-Xmx1280M" to be passed to the java command used to run the tests.

 <scalatest maxmemory="1280M">

When fork is true, nested <jvmarg> elements may be used to pass additional arguments to the forked jvm. For example, if you are running into 'PermGen space' memory errors, you could add the following jvmarg to bump up the JVM's MaxPermSize value:

 <jvmarg value="-XX:MaxPermSize=128m"/>

Attributes

Graph
Supertypes
class Task
class ProjectComponent
trait Cloneable
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def addConfiguredConfig(config: NameValuePair): Unit

Sets values from nested element config.

Sets values from nested element config.

Attributes

def addConfiguredJvmArg(arg: JvmArg): Unit

Sets value from nested element jvmarg.

Sets value from nested element jvmarg.

Attributes

def addConfiguredMembersOnly(membersonly: PackageElement): Unit

Sets value from nested element membersonly.

Sets value from nested element membersonly.

Attributes

def addConfiguredReporter(reporter: ReporterElement): Unit

Sets value from nested element reporter.

Sets value from nested element reporter.

Attributes

def addConfiguredRunpath(runpath: Path): Unit

Sets value from nested element runpath.

Sets value from nested element runpath.

Attributes

def addConfiguredRunpathUrl(runpathurl: RunpathUrl): Unit

Sets value from nested element runpathurl.

Sets value from nested element runpathurl.

Attributes

def addConfiguredSuite(suite: SuiteElement): Unit

Sets value from nested element suite.

Sets value from nested element suite.

Attributes

def addConfiguredTagsToExclude(tagsToExclude: TextElement): Unit

Sets value from nested element tagsToExclude.

Sets value from nested element tagsToExclude.

Attributes

def addConfiguredTagsToInclude(tagsToInclude: TextElement): Unit

Sets value from nested element tagsToInclude.

Sets value from nested element tagsToInclude.

Attributes

def addConfiguredTest(test: TestElement): Unit

Sets value from nested element test.

Sets value from nested element test.

Attributes

def addConfiguredTestNGSuites(testNGSuitePath: Path): Unit

Sets value from nested element testngsuites.

Sets value from nested element testngsuites.

Attributes

def addConfiguredTestsfile(testsfile: TestsfileElement): Unit

Sets value from nested element testsfile.

Sets value from nested element testsfile.

Attributes

def addConfiguredWildcard(wildcard: PackageElement): Unit

Sets value from nested element wildcard.

Sets value from nested element wildcard.

Attributes

def buildArgsList: List[String]
override def execute: Unit

Executes the task.

Executes the task.

Attributes

Definition Classes
Task
def setFork(fork: Boolean): Unit

Sets value of the fork attribute.

Sets value of the fork attribute.

Attributes

def setHaltonfailure(haltonfailure: Boolean): Unit

Sets value of the haltonfailure attribute.

Sets value of the haltonfailure attribute.

Attributes

def setMaxmemory(max: String): Unit

Sets value of the maxmemory attribute.

Sets value of the maxmemory attribute.

Attributes

def setMembersonly(packageName: String): Unit

Sets value of membersonly attribute.

Sets value of membersonly attribute.

Attributes

def setNumthreads(numthreads: Int): Unit

Sets value of the numthreads attribute.

Sets value of the numthreads attribute.

Attributes

def setParallel(parallel: Boolean): Unit

Sets value of the parallel attribute.

Sets value of the parallel attribute.

Attributes

def setRunpath(runpath: Path): Unit

Sets value of the runpath attribute.

Sets value of the runpath attribute.

Attributes

def setSortSuites(sortSuites: Boolean): Unit

Sets value of the sortSuites attribute.

Sets value of the sortSuites attribute.

Attributes

def setSpanScaleFactor(spanScaleFactor: Double): Unit

Sets value of the spanScaleFactor attribute.

Sets value of the spanScaleFactor attribute.

Attributes

def setSuffixes(suffixes: String): Unit

Sets value of the suffixes attribute.

Sets value of the suffixes attribute.

Attributes

def setSuite(suite: SuiteElement): Unit

Sets value of suite attribute.

Sets value of suite attribute.

Attributes

def setTagsToExclude(tagsToExclude: String): Unit

Sets value of the tagsToExclude attribute.

Sets value of the tagsToExclude attribute.

Attributes

def setTagsToInclude(tagsToInclude: String): Unit

Sets value of the tagsToInclude attribute.

Sets value of the tagsToInclude attribute.

Attributes

def setTestNGSuites(testNGSuitePath: Path): Unit

Sets value of the testngsuites attribute.

Sets value of the testngsuites attribute.

Attributes

def setTestsfile(testsfile: String): Unit

Sets value of the testsfile attribute.

Sets value of the testsfile attribute.

Attributes

def setWildcard(packageName: String): Unit

Sets value of wildcard attribute.

Sets value of wildcard attribute.

Attributes

Inherited methods

final def bindToOwner(x$0: Task): Unit

Attributes

Inherited from:
Task
def clone(): <FromJavaObject>

Create a copy of the receiver object.

Create a copy of the receiver object.

The default implementation of the clone method is platform dependent.

Attributes

Returns

a copy of the receiver object.

Note

not specified by SLS as a member of AnyRef

Inherited from:
ProjectComponent
def getDescription(): String

Attributes

Inherited from:
ProjectComponent
def getLocation(): Location

Attributes

Inherited from:
ProjectComponent
def getOwningTarget(): Target

Attributes

Inherited from:
Task
def getProject(): Project

Attributes

Inherited from:
ProjectComponent
def getRuntimeConfigurableWrapper(): RuntimeConfigurable

Attributes

Inherited from:
Task
def getTaskName(): String

Attributes

Inherited from:
Task
def getTaskType(): String

Attributes

Inherited from:
Task
def init(): Unit

Attributes

Inherited from:
Task
def log(x$0: String, x$1: Throwable, x$2: Int): Unit

Attributes

Inherited from:
Task
def log(x$0: Throwable, x$1: Int): Unit

Attributes

Inherited from:
Task
def log(x$0: String, x$1: Int): Unit

Attributes

Inherited from:
Task
def log(x$0: String): Unit

Attributes

Inherited from:
Task
def maybeConfigure(): Unit

Attributes

Inherited from:
Task
final def perform(): Unit

Attributes

Inherited from:
Task
def reconfigure(): Unit

Attributes

Inherited from:
Task
def setDescription(x$0: String): Unit

Attributes

Inherited from:
ProjectComponent
def setLocation(x$0: Location): Unit

Attributes

Inherited from:
ProjectComponent
def setOwningTarget(x$0: Target): Unit

Attributes

Inherited from:
Task
def setProject(x$0: Project): Unit

Attributes

Inherited from:
ProjectComponent
def setRuntimeConfigurableWrapper(x$0: RuntimeConfigurable): Unit

Attributes

Inherited from:
Task
def setTaskName(x$0: String): Unit

Attributes

Inherited from:
Task
def setTaskType(x$0: String): Unit

Attributes

Inherited from:
Task