org.scalatest.Distributor.scala Maven / Gradle / Ivy
Show all versions of scalatest_2.8.1 Show documentation
/*
* Copyright 2001-2008 Artima, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.scalatest
/**
* Trait whose instances facilitate parallel execution of Suites.
* An optional Distributor is passed to the run method of Suite. If a
* Distributor is indeed passed, trait Suite's implementation of run will
* populate that Distributor with its nested Suites (by passing them to the Distributor's
* apply method) rather than executing the nested Suites directly. It is then up to another thread or process
* to execute those Suites.
*
*
* If you have a set of nested Suites that must be executed sequentially, you can mix in trait
* SequentialNestedSuiteExecution, which overrides runNestedSuites and
* calls super's runNestedSuites implementation, passing in None for the
* Distributor.
*
*
*
* Implementations of this trait must be thread safe.
*
*
* @author Bill Venners
*/
trait Distributor /* extends ((Suite, Tracker) => Unit) */ {
/**
* Puts a Suite into the Distributor.
*
* @param suite the Suite to put into the Distributor.
* @param tracker a Tracker to pass to the Suite's run method.
*
* @throws NullPointerException if either suite or tracker is null.
*/
def apply(suite: Suite, tracker: Tracker)
}
/**
* Companion object to Distributor that holds a deprecated implicit conversion.
*/
object Distributor {
/**
* Converts a Distributor to a function type that prior to the ScalaTest 1.5 release the
* Distributor extended.
*
*
* Prior to ScalaTest 1.5, Distributor extended function type (Suite, Tracker) => Unit.
* This inheritance relationship was severed in 1.5 to make it possible to implement Distributors in Java, a request by an IDE
* vendor to isolate their ScalaTest integration from binary incompatibility between different Scala/ScalaTest releases.
* To make a trait easily implementable in Java, it needs to have no concrete methods. Distributor itself does not declare
* any concrete methods, but (Suite, Tracker) => Unit does.
*
*
*
* This implicit conversion was added in ScalaTest 1.5 to avoid breaking any source code that was actually using
* Distributor as an (Suite, Tracker) => Unit function. It is unlikely anyone was actually doing that, but if you were
* and now get the deprecation warning, please email [email protected] if you believe this implicit conversion should
* be retained. If no one steps forward with a compelling justification, it will be removed in a future version of ScalaTest.
*
*/
@deprecated("See the documentation for Distributor.convertDistributorToFunction for information")
implicit def convertDistributorToFunction(distributor: Distributor): (Suite, Tracker) => Unit =
(suite: Suite, tracker: Tracker) => distributor(suite, tracker)
}