org.scalatest

trait ParallelTestExecution

[source: org/scalatest/ParallelTestExecution.scala]

trait ParallelTestExecution
extends OneInstancePerTest
Trait that causes that the tests of any suite it is mixed into to be run in parallel if a Distributor is passed to runTests.

ScalaTest's normal approach for running suites of tests in parallel is to run different suites in parallel, but the tests of any one suite sequentially. This approach should provide sufficient distribution of the work load in most cases, but some suites may encapsulate multiple long-running tests. Such suites may dominate the execution time of the run. If so, mixing in this trait into just those suites will allow their long-running tests to run in parallel with each other, thereby helping to reduce the total time required to run an entire run.

Because this trait extends OneInstancePerTest, each test will be run its own instance of the suite's class. This trait overrides the runTests method. If no Distributor is passed to runTests, this trait's implementation simply invokes its supertrait OneInstancePerTest's implementation of runTests, which will run each test in its own instance sequentially. If a Distributor is passed, however, this traits' implementation of runTests will, for each test, wrap a new instance of the suite in a special wrapper suite that will invoke just that one test, and passes the wrapper suites to the Distributor. The thread or entity that takes a wrapper suite from the Distributor will invoke run on the wrapper suite, which will run just one test. In this way, different tests of a suite that mixes in ParallelTestExecution will run in parallel.

Author
Bill Venners
Method Summary
protected def runTests (testName : scala.Option[java.lang.String], reporter : Reporter, stopper : Stopper, filter : Filter, configMap : scala.collection.immutable.Map[java.lang.String, Any], distributor : scala.Option[Distributor], tracker : Tracker) : Unit
Run the tests of this suite in parallel.
Methods inherited from OneInstancePerTest
newInstance
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Methods inherited from AbstractSuite
withFixture (abstract), run (abstract), runNestedSuites (abstract), runTest (abstract), testNames (abstract), nestedSuites (abstract), tags (abstract), expectedTestCount (abstract)
Method Details
protected def runTests(testName : scala.Option[java.lang.String], reporter : Reporter, stopper : Stopper, filter : Filter, configMap : scala.collection.immutable.Map[java.lang.String, Any], distributor : scala.Option[Distributor], tracker : Tracker) : Unit
Run the tests of this suite in parallel.
Parameters
testName - an optional name of one test to run. If None, all relevant tests should be run. I.e., None acts like a wildcard that means run all relevant tests in this Suite.
reporter - the Reporter to which results will be reported
stopper - the Stopper that will be consulted to determine whether to stop execution early.
filter - a Filter with which to filter tests based on their tags
configMap - a Map of key-value pairs that can be used by the executing Suite of tests.
distributor - an optional Distributor, into which to put nested Suites to be run by another entity, such as concurrently by a pool of threads. If None, nested Suites will be run sequentially.
tracker - a Tracker tracking Ordinals being fired by the current thread.
Throws
NullPointerException - if any of the passed parameters is null.
IllegalArgumentException - if testName is defined, but no test with the specified test name exists in this Suite
Overrides
OneInstancePerTest.runTests


Copyright (C) 2001-2010 Artima, Inc. All rights reserved.