ScalaTest User Guide Getting started Selecting testing styles Defining base classes Writing your first test Using assertions Tagging your tests Running your tests Sharing fixtures Sharing tests Using matchers Testing with mock objects Property-based testing Asynchronous testing Using Scala-js Using Inside Using OptionValues Using EitherValues Using PartialFunctionValues Using PrivateMethodTester Using WrapWith Philosophy and design Migrating to 3.0 |
Using the ScalaTest ant task
ScalaTest provides an ant task to make it easier to run ScalaTest as part of an ant build. Instructions on how to specify various
options are below. See the documentation for the
To use the ScalaTest ant task, you must first define it in your ant file using <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 <scalatest ...> ... </scalatest>
You can place key value pairs into the config map using nested <scalatest> <config name="dbname" value="testdb"/> <config name="server" value="192.168.1.188"/>
You can specify a runpath using either a <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 <scalatest> <runpathurl url="http://foo.com/bar.jar"/>
You can specify reporters using nested
Each may include a <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 <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 <scalatest suite="com.artima.serviceuitest.ServiceUITestkit"> or <scalatest> <suite classname="com.artima.serviceuitest.ServiceUITestkit"/>
To specify suites using members-only or wildcard package names, use
either the <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 <scalatest suffixes="Spec|Suite">
Use attribute <scalatest testsfile="target/memory.out"> or <scalatest> <testsfile filename="target/memory.out"/>
Use attribute
Use attribute
Use attribute
When <scalatest maxmemory="1280M">
When <jvmarg value="-XX:MaxPermSize=128m"/> |
ScalaTest is brought to you by Bill Venners and Artima.
ScalaTest is free, open-source software
released under the Apache
2.0 license.
If your company loves ScalaTest, please consider sponsoring the project.
Copyright © 2009-2025 Artima, Inc. All Rights Reserved.