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
ConfigMapcan be populated from theRunnercommand line via-Darguments.Runnerpasses it to many methods where you can use it to configure your test runs. For example,Runnerpassed theConfigMapto:applymethod ofReporters viaRunStartingeventsrunmethod ofSuiterunNestedSuitesmethod ofSuiterunTestsmethod ofSuiterunTestmethod ofSuitewithFixture(NoArgTest)method ofSuitewithFixture(OneArgTest)method offixture.SuitebeforeEach(TestData)method ofBeforeAndAfterEachTestDataafterEach(TestData)method ofBeforeAndAfterEachTestDataIn addition to accessing the
ConfigMapin overriden implementations of the above methods, you can also transform and pass along a modifiedConfigMap.A
ConfigMapmaps 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 theConfigMapis 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 usingasInstanceOfin your test code,ConfigMapprovides three methods for accessing values at expected types.The
getRequiredmethod returns the value bound to a key cast to a specified type, or throwsTestCanceledExceptionif either the key is not bound or is bound to an incompatible type. Here's an example:The
getOptionalmethod returns the value bound to a key cast to a specified type, wrapped in aSome, returnsNoneif the key is not bound, or throws TestCanceledException if the key exists but is bound to an incompatible type. Here's an example:The
getWithDefaultmethod 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: