Returns the value bound to a key cast to a specified type, wrapped in a Some
,
returns None
if the key is not bound, or throws TestCanceledException if the key exists but is
bound to an incompatible type.
Returns the value bound to a key cast to a specified type, wrapped in a Some
,
returns None
if the key is not bound, or throws TestCanceledException if the key exists but is
bound to an incompatible type. Here's an example:
val tempFileName: Option[String] = configMap.getOptional[String]("tempFileName")
the key with which the desired value should be associated
an implicit ClassManifest
specifying the expected type for the desired value
Returns the value bound to a key cast to the specified type V
, or throws TestCanceledException
if either the key is not bound or is bound to an incompatible type.
Returns the value bound to a key cast to the specified type V
, or throws TestCanceledException
if either the key is not bound or is bound to an incompatible type. Here's an example:
val tempFileName: String = configMap.getRequired[String]("tempFileName")
the key with which the desired value should be associated
an implicit ClassManifest
specifying the expected type for the desired value
Returns the value bound to a key cast to the specified type V
,
returns a specified default value if the key is not bound, or throws TestCanceledException if the key exists but is
if either the key is not bound or is bound to an incompatible type.
Returns the value bound to a key cast to the specified type V
,
returns a specified default value if the key is not bound, or throws TestCanceledException if the key exists but is
if either the key is not bound or is bound to an incompatible type. Here's an example:
val tempFileName: String = configMap.getWithDefault[String]("tempFileName", "tmp.txt")
the key with which the desired value should be associated
a default value to return if the key is not found
an implicit ClassManifest
specifying the expected type for the desired value
(Changed in version 2.8.0) keys
returns Iterable[A]
rather than Iterator[A]
.
(Changed in version 2.9.0) The behavior of scanRight
has changed. The previous behavior can be reproduced with scanRight.reverse.
(Changed in version 2.9.0) transpose
throws an IllegalArgumentException
if collections are not uniformly sized.
(Changed in version 2.8.0) values
returns Iterable[B]
rather than Iterator[B]
.
A map of configuration data.
A
ConfigMap
can be populated from theRunner
command line via-D
arguments.Runner
passes it to many methods where you can use it to configure your test runs. For example,Runner
passed theConfigMap
to:apply
method ofReporter
s viaRunStarting
eventsrun
method ofSuite
runNestedSuites
method ofSuite
runTests
method ofSuite
runTest
method ofSuite
withFixture(NoArgTest)
method ofSuite
withFixture(OneArgTest)
method offixture.Suite
beforeEach(TestData)
method ofBeforeAndAfterEachTestData
afterEach(TestData)
method ofBeforeAndAfterEachTestData
In addition to accessing the
ConfigMap
in overriden implementations of the above methods, you can also transform and pass along a modifiedConfigMap
.A
ConfigMap
maps string keys to values of any type, i.e., it is aMap[String, Any]
. To get a configuration value in a variable of the actual type of that value, therefore, you'll need to perform an unsafe cast. If this cast fails, you'll get an exception, which so long as theConfigMap
is used only in tests, will result in either a failed or canceled test or aborted suite. To give such exceptions nice stack depths and error messages, and to eliminate the need for usingasInstanceOf
in your test code,ConfigMap
provides three methods for accessing values at expected types.The
getRequired
method returns the value bound to a key cast to a specified type, or throwsTestCanceledException
if either the key is not bound or is bound to an incompatible type. Here's an example:The
getOptional
method returns the value bound to a key cast to a specified type, wrapped in aSome
, returnsNone
if the key is not bound, or throws TestCanceledException if the key exists but is bound to an incompatible type. Here's an example:The
getWithDefault
method returns the value bound to a key cast to a specified type, returns a specified default value if the key is not bound, or throws TestCanceledException if the key exists but is either not bound or is bound to an incompatible type. Here's an example: