org.scalatest.AsyncTestSuiteMixin.scala Maven / Gradle / Ivy
/*
* Copyright 2001-2013 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 AsyncTestSuite
* and can be overridden in stackable modification traits.
*
*
* The main use case for this trait is to override withFixture
in a mixin trait.
* Here's an example:
*
*
*
* trait Builder extends AsyncTestSuiteMixin { this: AsyncTestSuite =>
*
* final val builder = new ThreadSafeStringBuilder
*
* abstract override def withFixture(test: NoArgAsyncTest) = {
* builder.append("ScalaTest is ")
* complete {
* super.withFixture(test) // To be stackable, must call super.withFixture
* } lastly {
* builder.clear()
* }
* }
* }
*
*/
trait AsyncTestSuiteMixin extends SuiteMixin { this: AsyncTestSuite =>
/**
* Run the passed test function in the context of 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, register a callback
* on the resulting FutureOutcome
to perform any clean
* up needed after the test completes. Because the NoArgAsyncTest
function
* passed to this method takes no parameters, preparing the fixture will require
* side effects, such as reassigning instance var
s in this Suite
or initializing
* a globally accessible external database. If you want to avoid reassigning instance var
s
* you can use FixtureAsyncTestSuite.
*
*
* @param test the no-arg async test function to run with a fixture
*/
protected def withFixture(test: NoArgAsyncTest): FutureOutcome
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy