Executes the supplied code (a by-name parameter) and returns an Outcome.
Executes the supplied code (a by-name parameter) and returns an Outcome.
Because Errors are used to denote serious errors, ScalaTest does not always treat a test that completes abruptly with
an Error as a test failure, but sometimes as
an indication that serious problems have arisen that should cause the run to abort, and the outcomeOf method exhibits
the same behavior. For example, if a test completes abruptly
with an OutOfMemoryError, it will not be reported as a test failure, but will instead cause the run to abort.
Because not everyone uses Errors only to represent serious problems, however, ScalaTest only behaves this way
for the following exception types (and their subclasses):
java.lang.annotation.AnnotationFormatErrorjava.awt.AWTErrorjava.nio.charset.CoderMalfunctionErrorjavax.xml.parsers.FactoryConfigurationErrorjava.lang.LinkageErrorjava.lang.ThreadDeathjavax.xml.transform.TransformerFactoryConfigurationErrorjava.lang.VirtualMachineErrorThe previous list includes all Errors that exist as part of Java 1.5 API, excluding java.lang.AssertionError.
If the code supplied to outcomeOf completes abruptly in one of the errors in the previous list, outcomeOf
will not return an Outcome, but rather will complete abruptly with the same exception.
will wrap any other exception thrown by the supplied code in a Some and return it.
The outcomeOf method (and ScalaTest in general) does treat a thrown AssertionError as an indication of a test failure and therefore
returns a Failed wrapping the AssertionError. In addition, any other Error that is not an instance of a
type mentioned in the previous list will be caught by the outcomeOf and transformed as follows:
If the code block completes normally (i.e., it doesn't throw any exception), outcomeOf results in Succeeded.
a block of code to execute
an Outcome representing the outcome of executing the block of code
Trait that contains the
outcomeOfmethod, which executes a passed code block and transforms the outcome into anOutcome, using the same mechanism used by ScalaTest to produce anOutcomewhen executing a test.For an example of
outcomeOfin action, see the documentation for classTableFor2.