|
ScalaTest 0.9.2
|
|
org/scalatest/fun/FunSuite1.scala]
trait
FunSuite1[F]
extends SuiteFunSuite1 with the type of the
fixture object. Most often this will be done explicitly by subclasses that have tests that need the fixture object. Here's an example:
class MySuite extends FunSuite1[Float] {
testWithFixture("example test") {
(f) => {
// test code that uses the passed fixture object...
}
}
def withFixture(f: (Float) => Unit) {
// Create the fixture objects (as in JUnit 3's setUp method)
val f = 1.1f
// Pass the fixture objects to the test function
f(f)
// If need be, perform any cleanup (as in JUnit 3's tearDown method)
}
}
This is a contrived example, because normally you would only pass fixture objects in this manner if
they are mutable. (The reason we used immutable objects in this example was just to make the type names fit
more easily on the page.) If they aren't mutable, then the fixture objects can simply be referenced from instance
variables and shared by all test methods that need them. Since they aren't mutable, they can't be "corrupted"
by one test and rendered unusable by the next. For mutable fixture objects, though, this trait allows you
to reinitialize and pass in a fresh set of fixture objects to each test function that needs them.| Method Summary | |
override def
|
groups
: scala.collection.immutable.Map[java.lang.String, scala.collection.immutable.Set[java.lang.String]]
A
Map whose keys are String group names to which tests in this FunSuite1 belong, and values
the Set of test names that belong to each group. If this FunSuite1 contains no groups, this method returns an empty Map. |
protected def
|
ignore
(testName : java.lang.String, testGroups : Group*)(f : => Unit) : Unit
Register a test to ignore, which has the specified name, optional groups, and function value that takes no arguments.
This method will register the test for later ignoring via an invocation of one of the
execute
methods. This method exists to make it easy to ignore an existing test method by changing the call to test
to ignore without deleting or commenting out the actual test code. The test will not be executed, but a
report will be sent that indicates the test was ignored. The passed test name must not have been registered previously on
this FunSuite1 instance. |
protected def
|
ignoreWithFixture
(testName : java.lang.String, testGroups : Group*)(f : (F) => Unit) : Unit
Register a test to ignore, which has the specified name, optional groups, and function value that takes 1 argument.
This method will register the test for later ignoring via an invocation of one of the
execute
methods. This method exists to make it easy to ignore an existing test method by changing the call to testWithFixture
to ignoreWithFixture without deleting or commenting out the actual test code. The test will not be executed, but a
report will be sent that indicates the test was ignored. The passed test name must not have been registered previously on
this FunSuite1 instance. |
protected def
|
ignoreWithFixtureAndReporter
(testName : java.lang.String, testGroups : Group*)(f : (F, Reporter) => Unit) : Unit
Register a test to ignore, which has the specified name, optional groups, and function value that takes 1 argument and a
Reporter.
This method will register the test for later ignoring via an invocation of one of the execute
methods. This method exists to make it easy to ignore an existing test method by changing the call to testWithFixtureAndReporter
to ignoreWithFixtureAndReporter without deleting or commenting out the actual test code. The test will not be executed, but a
report will be sent that indicates the test was ignored. The passed test name must not have been registered previously on
this FunSuite1 instance. |
protected def
|
ignoreWithReporter
(testName : java.lang.String, testGroups : Group*)(f : (Reporter) => Unit) : Unit
Register a test to ignore, which has the specified name, optional groups, and function value that takes a
Reporter.
This method will register the test for later ignoring via an invocation of one of the execute
methods. This method exists to make it easy to ignore an existing test method by changing the call to testWithReporter
to ignoreWithReporter without deleting or commenting out the actual test code. The test will not be executed, but a
report will be sent that indicates the test was ignored. The passed test name must not have been registered previously on
this FunSuite1 instance. |
protected override def
|
runTest
(testName : java.lang.String, reporter : Reporter, stopper : Stopper, properties : scala.collection.immutable.Map[java.lang.String, Any]) : Unit
Run a test. This trait's implementation runs the test registered with the name specified by
testName. |
protected def
|
test
(testName : java.lang.String, testGroups : Group*)(f : => Unit) : Unit
Register a test with the specified name, optional groups, and function value that takes no arguments.
This method will register the test for later execution via an invocation of one of the
execute
methods. The passed test name must not have been registered previously on
this FunSuite1 instance. |
override def
|
testNames
: scala.collection.immutable.Set[java.lang.String]
An immutable
Set of test names. If this FunSuite1 contains no tests, this method returns an empty Set. |
protected def
|
testWithFixture
(testName : java.lang.String, testGroups : Group*)(f : (F) => Unit) : Unit
Register a test with the specified name, optional groups, and function value that takes 1 argument.
This method will register the test for later execution via an invocation of one of the
execute
methods. The passed test name must not have been registered previously on
this FunSuite1 instance. This trait will not invoke any test functions registered via this method directly, but
will instead pass each test function registered with this method to withFixture. It is the responsibility of
subclass implementations of withFixture to invoke the test method, passing in the required fixture object. |
protected def
|
testWithFixtureAndReporter
(testName : java.lang.String, testGroups : Group*)(f : (F, Reporter) => Unit) : Unit
Register a test with the specified name, optional groups, and function value that takes 1 argument and a
Reporter.
This method will register the test for later execution via an invocation of one of the execute
methods. The Reporter passed to execute, or a Reporter that wraps it, will be partially applied to the function value, and
the resulting function will be passed to withFixture. Thus, this trait will not invoke any test functions registered via this method directly, but
will instead pass each test function registered with this method to withFixture. It is the responsibility of
subclass implementations of withFixture to invoke the test method, passing in the required fixture object.
The passed test name must not have been registered previously on this FunSuite1 instance. |
protected def
|
testWithReporter
(testName : java.lang.String, testGroups : Group*)(f : (Reporter) => Unit) : Unit
Register a test with the specified name, optional groups, and function value that takes a
Reporter.
This method will register the test for later execution via an invocation of one of the execute
methods. The Reporter passed to execute, or a Reporter that wraps it, will be passed to the function value.
The passed test name must not have been registered previously on
this FunSuite1 instance. |
protected abstract def
|
withFixture
(f : (F) => Unit) : Unit
Create a fixture object and pass it to the specified
test function value,
f, performing any necessary cleanup afterwards. This method serves the same purpose as the setUp
and tearDown methods of JUnit 3, the @Before and @After method annotations of JUnit 4, or the
@Configuration(beforeTestMethod = true) and @Configuration(afterTestMethod = true) method annotations of TestNG. Override this method
if you have a fixture object that are either themselves mutable, or provide access to
some other resource that tests may mutate in some way that needs to be reset for other tests. |
| Methods inherited from Suite | |
| nestedSuites, execute, execute, runTests, execute, runNestedSuites, suiteName, expectedTestCount, fail, fail, fail, fail, assert, assert, assert, assert, convertToEqualizer, intercept, intercept, expect, expect |
| Methods inherited from AnyRef | |
| getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
| Methods inherited from Any | |
| ==, !=, isInstanceOf, asInstanceOf |
| Method Details |
f, performing any necessary cleanup afterwards. This method serves the same purpose as the setUp
and tearDown methods of JUnit 3, the @Before and @After method annotations of JUnit 4, or the
@Configuration(beforeTestMethod = true) and @Configuration(afterTestMethod = true) method annotations of TestNG. Override this method
if you have a fixture object that are either themselves mutable, or provide access to
some other resource that tests may mutate in some way that needs to be reset for other tests.protected
def
test(testName : java.lang.String, testGroups : Group*)(f : => Unit) : Unit
execute
methods. The passed test name must not have been registered previously on
this FunSuite1 instance.IllegalArgumentException - if testName had been registered previouslyprotected
def
testWithReporter(testName : java.lang.String, testGroups : Group*)(f : (Reporter) => Unit) : Unit
Reporter.
This method will register the test for later execution via an invocation of one of the execute
methods. The Reporter passed to execute, or a Reporter that wraps it, will be passed to the function value.
The passed test name must not have been registered previously on
this FunSuite1 instance.IllegalArgumentException - if testName had been registered previouslyprotected
def
ignore(testName : java.lang.String, testGroups : Group*)(f : => Unit) : Unit
execute
methods. This method exists to make it easy to ignore an existing test method by changing the call to test
to ignore without deleting or commenting out the actual test code. The test will not be executed, but a
report will be sent that indicates the test was ignored. The passed test name must not have been registered previously on
this FunSuite1 instance.IllegalArgumentException - if testName had been registered previouslyprotected
def
ignoreWithReporter(testName : java.lang.String, testGroups : Group*)(f : (Reporter) => Unit) : Unit
Reporter.
This method will register the test for later ignoring via an invocation of one of the execute
methods. This method exists to make it easy to ignore an existing test method by changing the call to testWithReporter
to ignoreWithReporter without deleting or commenting out the actual test code. The test will not be executed, but a
report will be sent that indicates the test was ignored. The passed test name must not have been registered previously on
this FunSuite1 instance.IllegalArgumentException - if testName had been registered previouslyprotected
def
testWithFixture(testName : java.lang.String, testGroups : Group*)(f : (F) => Unit) : Unit
execute
methods. The passed test name must not have been registered previously on
this FunSuite1 instance. This trait will not invoke any test functions registered via this method directly, but
will instead pass each test function registered with this method to withFixture. It is the responsibility of
subclass implementations of withFixture to invoke the test method, passing in the required fixture object.IllegalArgumentException - if testName had been registered previouslyprotected
def
testWithFixtureAndReporter(testName : java.lang.String, testGroups : Group*)(f : (F, Reporter) => Unit) : Unit
Reporter.
This method will register the test for later execution via an invocation of one of the execute
methods. The Reporter passed to execute, or a Reporter that wraps it, will be partially applied to the function value, and
the resulting function will be passed to withFixture. Thus, this trait will not invoke any test functions registered via this method directly, but
will instead pass each test function registered with this method to withFixture. It is the responsibility of
subclass implementations of withFixture to invoke the test method, passing in the required fixture object.
The passed test name must not have been registered previously on this FunSuite1 instance.IllegalArgumentException - if testName had been registered previouslyprotected
def
ignoreWithFixture(testName : java.lang.String, testGroups : Group*)(f : (F) => Unit) : Unit
execute
methods. This method exists to make it easy to ignore an existing test method by changing the call to testWithFixture
to ignoreWithFixture without deleting or commenting out the actual test code. The test will not be executed, but a
report will be sent that indicates the test was ignored. The passed test name must not have been registered previously on
this FunSuite1 instance.IllegalArgumentException - if testName had been registered previouslyprotected
def
ignoreWithFixtureAndReporter(testName : java.lang.String, testGroups : Group*)(f : (F, Reporter) => Unit) : Unit
Reporter.
This method will register the test for later ignoring via an invocation of one of the execute
methods. This method exists to make it easy to ignore an existing test method by changing the call to testWithFixtureAndReporter
to ignoreWithFixtureAndReporter without deleting or commenting out the actual test code. The test will not be executed, but a
report will be sent that indicates the test was ignored. The passed test name must not have been registered previously on
this FunSuite1 instance.IllegalArgumentException - if testName had been registered previouslyoverride
def
testNames : scala.collection.immutable.Set[java.lang.String]
Set of test names. If this FunSuite1 contains no tests, this method returns an empty Set.
This trait's implementation of this method will return a set that contains the names of all registered tests. The set's iterator will return those names in the order in which the tests were registered.
protected override
def
runTest(testName : java.lang.String, reporter : Reporter, stopper : Stopper, properties : scala.collection.immutable.Map[java.lang.String, Any]) : Unit
testName.testName - the name of one test to execute.reporter - the Reporter to which results will be reportedstopper - the Stopper that will be consulted to determine whether to stop execution early.properties - a Map of properties that can be used by the executing Suite of tests.NullPointerException - if any of testName, reporter, stopper, or properties is null.override
def
groups : scala.collection.immutable.Map[java.lang.String, scala.collection.immutable.Set[java.lang.String]]
Map whose keys are String group names to which tests in this FunSuite1 belong, and values
the Set of test names that belong to each group. If this FunSuite1 contains no groups, this method returns an empty Map.
This trait's implementation returns groups that were passed as strings contained in Group objects passed to
methods test, testWithReporter, ignore, and ignoreWithReporter.
|
ScalaTest 0.9.2
|
|