TestData
A bundle of information about the current test.
A TestData object is passed to the withFixture methods of traits Suite and FixtureSuite
(both NoArgTest and OneArgTest
extend TestData) and to the beforeEach and afterEach
methods of trait BeforeAndAfterEach. This enables fixtures and tests to make use
of the test name and configuration objects in the config map.
In ScalaTest's event model, a test may be surrounded by “scopes.” Each test and scope is associated with string of text. A test's name is a concatenation of the text of any surrounding scopes followed by the text provided with the test itself, after each text element has been trimmed and one space inserted between each component. Here's an example:
package org.scalatest.examples.freespec
import org.scalatest.FreeSpec
class SetSpec extends FreeSpec {
"A Set" - {
"when empty" - {
"should have size 0" in {
assert(Set.empty.size === 0)
}
"should produce NoSuchElementException when head is invoked" in {
assertThrows[NoSuchElementException] {
Set.empty.head
}
}
}
}
}
The above FreeSpec contains two tests, both nested inside the same two scopes. The outermost scope names
the subject, A Set. The nested scope qualifies the subject with when empty. Inside that
scope are the two tests. The text of the tests are:
-
should have size 0 -
should produce NoSuchElementException when head is invoked
Therefore, the names of these two tests are:
-
A Stack when empty should have size 0 -
A Stack when empty should produce NoSuchElementException when head is invoked
The TestData instance for the first test would contain:
-
name:"A Stack when empty should have size 0" -
scopes:collection.immutable.IndexedSeq("A Stack", "when empty") -
text:"should have size 0"
Value members
Abstract fields
A ConfigMap containing objects that can be used
to configure the fixture and test.
A ConfigMap containing objects that can be used
to configure the fixture and test.
The name of this test.
The name of this test.
See the main documentation for this trait for an explanation of the difference between name, text,
and scopes.
An immutable IndexedSeq containing the text for any "scopes" enclosing this test, in order
from outermost to innermost scope.
An immutable IndexedSeq containing the text for any "scopes" enclosing this test, in order
from outermost to innermost scope.
See the main documentation for this trait for an explanation of the difference between name, text,
and scopes. If a test has no surrounding scopes, this field will contain an empty IndexedSeq.