verifyError
Class: matlab.unittest.qualifications.Verifiable
Namespace: matlab.unittest.qualifications
Verify function throws specified exception
Syntax
Description
verifyError(
verifies that testCase
,actual
,identifier
)actual
is a function handle that throws the exception
specified by identifier
.
verifyError(
also associates the diagnostic information in testCase
,actual
,identifier
,diagnostic
)diagnostic
with the qualification.
also returns the output values produced by the function handle. Use this syntax to control
the number of outputs to request when the function handle is invoked. If the function handle
throws an exception, all outputs are displayed as [output1,...,outputN]
= verifyError(___)<missing>
. You can
use any of the input argument combinations in the previous syntaxes.
Input Arguments
Examples
Tips
verifyError
is a convenience method. For example,verifyError(testCase,actual,identifier)
is functionally equivalent to the following code.import matlab.unittest.constraints.Throws testCase.verifyThat(actual,Throws(identifier))
More functionality is available when using the
Throws
constraint directly viaverifyThat
.Use verification qualifications to produce and record failures without throwing an exception. Because verifications do not throw exceptions, all test content runs to completion even when verification failures occur. Typically, verifications are the primary qualification for a unit test because they typically do not require an early exit from the test. Use other qualification types to test for violation of preconditions or incorrect test setup:
Use assumption qualifications to ensure that the test environment meets preconditions that otherwise do not result in a test failure. Assumption failures result in filtered tests, and the testing framework marks the tests as
Incomplete
. For more information, seematlab.unittest.qualifications.Assumable
.Use assertion qualifications when the failure condition invalidates the remainder of the current test content but does not prevent proper execution of subsequent tests. A failure at the assertion point renders the current test as
Failed
andIncomplete
. For more information, seematlab.unittest.qualifications.Assertable
.Use fatal assertion qualifications to abort the test session upon failure. These qualifications are useful when the failure is so fundamental that continuing testing does not make sense. Fatal assertion qualifications are also useful when fixture teardown does not restore the environment state correctly, and aborting testing and starting a fresh session is preferable. For more information, see
matlab.unittest.qualifications.FatalAssertable
.
Version History
Introduced in R2013a