All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.scalatest.SuiteMixin.scala Maven / Gradle / Ivy

Go to download

ScalaTest is a free, open-source testing toolkit for Scala and Java programmers.

There is a newer version: 2.0.M6-SNAP4
Show newest version
/*
 * 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

/**
 * Trait defining abstract "lifecycle" methods that are implemented in Suite and can
 * be overridden in stackable modification traits.
 *
 * 

* The main purpose of SuiteMixin is to differentiate core Suite * traits, such as Suite, FunSuite, and FunSpec from stackable * modification traits for Suites such as BeforeAndAfterEach, OneInstancePerTest, * and SequentialNestedSuiteExecution. Because these stackable traits extend SuiteMixin * instead of Suite, 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 stackable BeforeAndAfterEach trait * into that, like this: *

* *
 * class MySuite extends FunSuite with BeforeAndAfterEach // Compiles fine
 * 
* * @author Bill Venners */ trait SuiteMixin { 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 * @return a Status object that indicates when all tests and nested suites started by this method have completed, and whether or not a failure occurred. * * @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 * @return a Status object that indicates when all nested suites started by this method have completed, and whether or not a failure occurred. * * @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 * @return a Status object that indicates when all tests started by this method have completed, and whether or not a failure occurred. * * @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 * @return a Status object that indicates when the test started by this method has completed, and whether or not it failed . * * @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 SuiteMixin object's nested Suites. If this SuiteMixin contains no nested Suites, * 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 }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy