org.scalatest.AbstractSuite.scala Maven / Gradle / Ivy
Show all versions of scalatest_2.11.0-M3 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 that defines abstract methods that are implemented in
Suite, or groups of thisSuite
that can * be overriden in stackable modification traits. * ** The main purpose of
* *AbstractSuite
is to differentiate coreSuite
* traits, such asSuite
,FunSuite
, andFunSpec
from stackable * modification traits forSuite
s such asBeforeAndAfterEach
,OneInstancePerTest
, * andParallelNestedSuiteExecution
. Because these stackable traits extendAbstractSuite
* instead ofSuite
, you can't define a suite by simply extending one of the stackable traits: ** class MySuite extends BeforeAndAfterEach // Won't compile ** ** Instead, you need to extend a core
* *Suite
trait and mix the stackableBeforeAndAfterEach
trait * into that, like this: ** class MySuite extends FunSuite with BeforeAndAfterEach // Compiles fine ** * @author Bill Venners */ 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
* * @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. IfNoArgTest
function * passed to this method takes no parameters, preparing the fixture will require * side effects, such as reassigning instancevar
s in thisSuite
or initializing * a globally accessible external database. If you want to avoid reassigning instancevar
s * you can use fixture.Suite. *None
, all relevant tests should be executed. * I.e.,None
acts like a wildcard that means execute all relevant tests in thisSuite
. * @param reporter theReporter
to which results will be reported * @param stopper theStopper
that will be consulted to determine whether to stop execution early. * @param filter aFilter
with which to filter tests based on their tags * @param configMap aMap
of key-value pairs that can be used by the executingSuite
of tests. * @param distributor an optionalDistributor
, into which to put nestedSuite
s to be executed * by another entity, such as concurrently by a pool of threads. IfNone
, nestedSuite
s will be executed sequentially. * @param tracker aTracker
trackingOrdinal
s being fired by the current thread. * * @throws NullPointerException if any passed parameter isnull
. */ def run( testName: Option[String], reporter: Reporter, stopper: Stopper, filter: Filter, configMap: Map[String, Any], distributor: Option[Distributor], tracker: Tracker ) /** * * Runs zero to many of this suite's nested suites. * * @param reporter theReporter
to which results will be reported * @param stopper theStopper
that will be consulted to determine whether to stop execution early. * @param filter aFilter
with which to filter tests based on their tags * @param configMap aMap
of key-value pairs that can be used by the executingSuite
of tests. * @param distributor an optionalDistributor
, into which to put nestedSuite
s to be run * by another entity, such as concurrently by a pool of threads. IfNone
, nestedSuite
s will be run sequentially. * @param tracker aTracker
trackingOrdinal
s being fired by the current thread. * * @throws NullPointerException if any passed parameter isnull
. */ protected def runNestedSuites(reporter: Reporter, stopper: Stopper, filter: Filter, configMap: Map[String, Any], distributor: Option[Distributor], tracker: Tracker) /** * Runs zero to many of this suite's tests. * * @param testName an optional name of one test to run. IfNone
, all relevant tests should be run. * I.e.,None
acts like a wildcard that means run all relevant tests in thisSuite
. * @param reporter theReporter
to which results will be reported * @param stopper theStopper
that will be consulted to determine whether to stop execution early. * @param filter aFilter
with which to filter tests based on their tags * @param configMap aMap
of key-value pairs that can be used by the executingSuite
of tests. * @param distributor an optionalDistributor
, into which instances of thisSuite
class * that are responsible for executing individual tests contained in thisSuite
's * tests, may be placed so as to be run * by another entity, such as concurrently by a pool of threads. * @param tracker aTracker
trackingOrdinal
s being fired by the current thread. * @throws NullPointerException if any oftestName
,reporter
,stopper
,groupsToInclude
, *groupsToExclude
, orconfigMap
isnull
. */ protected def runTests(testName: Option[String], reporter: Reporter, stopper: Stopper, filter: Filter, configMap: Map[String, Any], distributor: Option[Distributor], tracker: Tracker) /** * Runs a test. * * @param testName the name of one test to execute. * @param reporter theReporter
to which results will be reported * @param stopper theStopper
that will be consulted to determine whether to stop execution early. * @param configMap aMap
of key-value pairs that can be used by the executingSuite
of tests. * @param tracker aTracker
trackingOrdinal
s being fired by the current thread. * * @throws NullPointerException if any oftestName
,reporter
,stopper
,configMap
, * ortracker
isnull
. */ protected def runTest( testName: String, reporter: Reporter, stopper: Stopper, configMap: Map[String, Any], tracker: Tracker ) /** * AnSet
of test names. If thisSuite
contains no tests, this method returns an emptySet
. * ** Although subclass and subtrait implementations of this method may return a
*/ def testNames: Set[String] /** * ASet
whose iterator producesString
* 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. *List
of thisSuite
object's nestedSuite
s. If thisSuite
contains no nestedSuite
s, * this method returns an emptyList
. */ def nestedSuites: List[Suite] /** * AMap
whose keys areString
tag names with which tests in thisSuite
are marked, and * whose values are theSet
of test names marked with each tag. If thisSuite
contains no tags, this * method returns an emptyMap
. * ** Subclasses may implement this method to define and/or discover tags in a custom manner, but overriding method implementations * should never return an empty
*/ def tags: Map[String, Set[String]] /** * The total number of tests that are expected to run when thisSet
as a value. If a tag has no tests, its name should not appear as a key in the * returnedMap
. *Suite
'srun
method is invoked. * * @param filter aFilter
with which to filter tests to count based on their tags */ def expectedTestCount(filter: Filter): Int /** * Suite style name. */ val styleName: String }