org.scalatest.AbstractSuite.scala Maven / Gradle / Ivy
Show all versions of scalatest_2.9.0 Show documentation
/*
* Copyright 2001-2012 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
/**
* AbstractSuite
has been deprecated and will be removed in a future version of ScalaTest. Please change occurances of
* AbstractSuite
where serving as a base class for stackable traits to SuiteMixin
. This
* is just a name change for stackable traits extending AbstractSuite
. If AbstractSuite
was
* being used in any other way, change AbstractSuite
to Suite
.
*
*
* The main change will be to change stackable traits defined like this:
*
*
*
* import org.scalatest._
* import concurrent.Eventually._
*
* trait RetriedTests extends AbstractSuite { Suite =>
* abstract override def withFixture(test: NoArgTest) {
* eventually { super.withFixture(test) }
* }
* }
*
*
*
* Instead of extending AbstractSuite
, extend SuiteMixin
instead:
*
*
*
* import org.scalatest._
* import concurrent.Eventually._
*
* trait RetriedTests extends SuiteMixin { Suite =>
* abstract override def withFixture(test: NoArgTest) {
* eventually { super.withFixture(test) }
* }
* }
*
*/
@deprecated("Please use SuiteMixin or Suite instead. For more info, see the Scaladoc for AbstractSuite.")
trait AbstractSuite { this: Suite =>
/**
* Runs the passed test function with a fixture established by this method.
*
*
* This method should set up the fixture needed by the tests of the
* current suite, invoke the test function, and if needed, perform any clean
* up needed after the test completes. Because the NoArgTest
function
* passed to this method takes no parameters, preparing the fixture will require
* side effects, such as initializing an external database.
*
*
* @param test the no-arg test function to run with a fixture
*/
protected def withFixture(test: NoArgTest)
/**
* Runs this suite of tests.
*
* @param testName an optional name of one test to execute. If None
, all relevant tests should be executed.
* I.e., None
acts like a wildcard that means execute all relevant tests in this Suite
.
* @param args the Args
for this run
*
* @throws NullPointerException if any passed parameter is null
.
*/
def run(testName: Option[String], args: Args): Status
/**
* Runs zero to many of this suite's nested suites.
*
* @param args the Args
for this run
*
* @throws NullPointerException if args
is null
.
*/
protected def runNestedSuites(args: Args): Status
/**
* Runs zero to many of this suite's tests.
*
* @param 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
.
* @param args the Args
for this run
*
* @throws NullPointerException if either testName
or args
is null
.
*/
protected def runTests(testName: Option[String], args: Args): Status
/**
* Runs a test.
*
* @param testName the name of one test to execute.
* @param args the Args
for this run
*
* @throws NullPointerException if any of testName
, reporter
, stopper
, configMap
,
* or tracker
is null
.
*/
protected def runTest(
testName: String,
args: Args
): Status
/**
* A Set
of test names. If this Suite
contains no tests, this method returns an empty Set
.
*
*
* Although subclass and subtrait implementations of this method may return a Set
whose iterator produces String
* test names in a well-defined order, the contract of this method does not required a defined order. Subclasses are free to
* implement this method and return test names in either a defined or undefined order.
*
*/
def testNames: Set[String]
/**
* An immutable IndexedSeq
of this Suite
object's nested Suite
s. If this Suite
contains no nested Suite
s,
* this method returns an empty IndexedSeq
.
*/
def nestedSuites: collection.immutable.IndexedSeq[Suite]
/**
* A Map
whose keys are String
tag names with which tests in this Suite
are marked, and
* whose values are the Set
of test names marked with each tag. If this Suite
contains no tags, this
* method returns an empty Map
.
*
*
* Subclasses may implement this method to define and/or discover tags in a custom manner, but overriding method implementations
* should never return an empty Set
as a value. If a tag has no tests, its name should not appear as a key in the
* returned Map
.
*
*/
def tags: Map[String, Set[String]]
/**
* The total number of tests that are expected to run when this Suite
's run
method is invoked.
*
* @param filter a Filter
with which to filter tests to count based on their tags
*/
def expectedTestCount(filter: Filter): Int
/**
* The fully qualified name of the class that can be used to rerun this suite.
*/
def rerunner: Option[String]
/**
* This suite's style name.
*
*
* This lifecycle method provides a string that is used to determine whether this suite object's
* style is one of the chosen styles for
* the project.
*
*/
val styleName: String
/**
* This overloaded form of run
has been deprecated and will be removed in a future
* version of ScalaTest. Please use the run
method that takes two parameters instead.
*
*
* This final implementation of this method constructs a Args
instance from the passed
* reporter
, stopper
, filter
, configMap
, distributor
,
* and tracker
, and invokes the overloaded run
method that takes two parameters,
* passing in the specified testName
and the newly constructed Args
. This method
* implementation enables existing code that called into the old run
method to continue to work
* during the deprecation cycle. Subclasses and subtraits that overrode this method, however, will need to
* be changed to use the new two-parameter form instead.
*
*
* @param testName an optional name of one test to execute. If None
, all relevant tests should be executed.
* I.e., None
acts like a wildcard that means execute all relevant tests in this Suite
.
* @param reporter the Reporter
to which results will be reported
* @param stopper the Stopper
that will be consulted to determine whether to stop execution early.
* @param filter a Filter
with which to filter tests based on their tags
* @param configMap a Map
of key-value pairs that can be used by the executing Suite
of tests.
* @param distributor an optional Distributor
, into which to put nested Suite
s to be executed
* by another entity, such as concurrently by a pool of threads. If None
, nested Suite
s will be executed sequentially.
* @param tracker a Tracker
tracking Ordinal
s being fired by the current thread.
*
* @throws NullPointerException if any passed parameter is null
.
*/
final def run(
testName: Option[String],
reporter: Reporter,
stopper: Stopper,
filter: Filter,
configMap: Map[String, Any],
distributor: Option[Distributor],
tracker: Tracker
): Status = { // TODO: test that this grabs chosenStyles out of config map
run(testName, Args(reporter, stopper, filter, configMap, distributor, tracker, Set.empty))
}
}