An array of Fingerprints that specify how to identify ScalaTest's test classes during
discovery.
An array of Fingerprints that specify how to identify ScalaTest's test classes during
discovery.
SubclassFingerprint for org.scalatest.Suite and AnnotatedFingerprint for org.scalatest.WrapWith
Test framework name.
Initiates a ScalaTest run.
Initiates a ScalaTest run.
the ScalaTest arguments for the new run
the ScalaTest remote arguments for the run in a forked JVM
a class loader to use when loading test classes during the run
a Runner implementation representing the newly started run to run ScalaTest's tests.
IllegalArgumentException when invalid or unsupported argument is passed
This class is ScalaTest's implementation of the new Framework API that is supported in sbt 0.13.
To use ScalaTest in sbt, you should add ScalaTest as dependency in your sbt build file, the following shows an example for using ScalaTest 2.0 with Scala 2.10.x project:
To pass argument to ScalaTest from sbt, you can use
testOptions:If you are using multiple testing frameworks, you can pass arguments specific to ScalaTest only:
Supported arguments
Integration in sbt 0.13 supports same argument format as
Runner, except the following arguments:-R-- runpath is not supported because test path and discovery is handled by sbt-s-- suite is not supported because sbt'stest-onlyserves the similar purpose-A-- again is not supported because sbt'stest-quickserves the similar purpose-j-- junit is not supported because in sbt different test framework should be supported by its correspondingFrameworkimplementation-b-- testng is not supported because in sbt different test framework should be supported by its correspondingFrameworkimplementation-P-- concurrent/parallel is not supported because parallel execution is controlled by sbt.-qis not supported because test discovery should be handled by sbt, and sbt's test-only or test filter serves the similar purpose-Tis not supported because correct ordering of text output is handled by sbt-gis not supported because current Graphic Reporter implementation works differently than standard reporterNew Features of New Framework API
New Framework API supports a number of new features that ScalaTest has utilized to support a better testing experience in sbt. The followings are summary of new features supported by the new Framework API:
Runnerper project run (non-fork), and a newdonemethodforkmodeIgnored,CanceledandPendingstatusSpecified behavior of single instance of
Runnerper project run (non-fork), and a newdonemethodIn new Framework API, it is now a specified behavior that
Framework'srunnermethod will be called to get aRunnerinstance once per project run. Arguments will be passed when callingFramework'srunnerand this gives ScalaTest a good place to perform setup tasks, such as initializingReporters.There's also a new
doneonRunnerinterface, which in turns provide a good spot for ScalaTest to perform cleanup tasks, such as disposing theReporters.HtmlReporterdepends on this behavior to generate itsindex.html. In addition,donecan return framework-specific summary text for sbt to render at the end of the project run, which allows ScalaTest to return its own summary text.API to return nested
Suites as sbtTasksIn new Framework API, a new concept of
Taskwas introduced. ATaskhas anexecutemethod that can return moreTasks for execution. ScalaTest does not utilize this feature, it always return empty array for sub-tasks.API to support test execution in
forkmodeForking was added to sbt since version 0.12, you can find documentation for forking support in sbt at Forking in sbt.
Although forking is already available in sbt since 0.12, there's no support in old Framework API, until it is added in new Framework API that is supported in sbt 0.13. With API provided with new Framework API, ScalaTest creates real
Reporters in the main process, and usesSocketReporterin forked process to send events back to the main process, and get processed by realReporters at the main process. All of this is transparent to any customReporterimplementation, as only one instance of the customReporterwill be created to process the events, regardless of whether the tests run in same or forked process.Selector API to selectively run tests
New Framework API includes a set of comprehensive API to select tests for execution. Though new Framework API supports fine-grained test selection, current sbt's
test-onlyandtest-quicksupports up to suite level selection only, orSuiteSelectoras defined in new Framework API. ThisFrameworkimplementation already supportsSuiteSelector,NestedSuiteSelector,TestSelectorandNestedTestSelector, which should work once future sbt version supports them.Added new
Ignored,CanceledandPendingstatusStatus
Ignored,CanceledandPendingare added to new Framework API, and they match perfectly with ScalaTest's ignored tests (now reported asIgnoredinstead ofSkipped), as well as canceled and pending tests newly added in ScalaTest 2.0.Added sbt Tagging support
Sbt supports task tagging, but has no support in old Framework API for test frameworks to integrate it. New Framework API supports it, and you can now use the following annotations to annotate your suite for sbt built-in resource tags:
CPUDiskNetworkThey will be mapped to corresponding resource tag
CPU,DiskandNetworkin sbt.You can also define custom tag, which you'll need to write it as Java annotation:
which will be translated to
Tags.Tag("custom")in sbt.