Performs an action and returns an array containing the assertion failures
that were observed within the block.
Namespace:
Gallio.Framework.AssertionsAssembly: Gallio (in Gallio.dll) Version: 3.3.0.0 (3.3.610.0)
Syntax
| C# |
|---|
public AssertionFailure[] CaptureFailures( Action action, AssertionFailureBehavior assertionFailureBehavior, bool captureExceptionAsAssertionFailure ) |
| Visual Basic (Declaration) |
|---|
Public Function CaptureFailures ( _ action As Action, _ assertionFailureBehavior As AssertionFailureBehavior, _ captureExceptionAsAssertionFailure As Boolean _ ) As AssertionFailure() |
Parameters
- action
- Type: Gallio.Common..::.Action
The action to invoke.
- assertionFailureBehavior
- Type: Gallio.Framework.Assertions..::.AssertionFailureBehavior
The assertion failure behavior to use while executing the block.
- captureExceptionAsAssertionFailure
- Type: System..::.Boolean
Specifies whether to represent an exception as an assertion failure, otherwise it is rethrown.
Return Value
The array of failures, may be empty if none.
Remarks
If the action throws an exception it is reported as an assertion failure unless the exception is a TestException (except AssertionFailureException) in which case the exception is rethrown by this method. This behavior enables special test exceptions such as TestTerminatedException to be used to terminate the test at any point instead of being reported as assertion failures.
The set of failures captured will depend on the setting of assertionFailureBehavior.
- If set to LogAndThrow or Throw, then only the first failure will be captured since execution will be immediately aborted when it happens.
- If set to Log or CaptureAndContinue, then all failures will be captured until the block terminates or throws an exception for some other reason.
- If set to Discard, then no failures will be captured since they will all be ignored!
Exceptions
| Exception | Condition |
|---|---|
| System..::.ArgumentNullException | Thrown if action is null. |
