verifyEqualsBaseline
Syntax
Description
verifyEqualsBaseline(
verifies that testCase
,actual
,baseline
)actual
is strictly equal to the baseline data represented
by baseline
. The method compares values in the same way as the verifyEqual
method.
You can use the verifyEqualsBaseline
method within a test class that
specifies baseline parameters. If the qualification fails, the testing framework provides
you with options to either create new baseline data or update the existing baseline data
using the actual value. For more information about baseline testing, see Create Baseline Tests for MATLAB Code.
verifyEqualsBaseline(
associates the diagnostic information in testCase
,actual
,baseline
,diagnostic
)diagnostic
with the
qualification.
verifyEqualsBaseline(___,
specifies options using one or more name-value arguments in addition to other input argument
combinations in previous syntaxes. For example,
Name=Value
)verifyEqualsBaseline(testCase,actual,baseline,RelTol=0.01)
verifies
that the difference between the corresponding elements of the actual and baseline numeric
arrays is within 1%.
Input Arguments
Examples
Tips
verifyEqualsBaseline
is a convenience method. For example,verifyEqualsBaseline(testCase,actual,baseline)
is functionally equivalent to the following code.import matlabtest.constraints.EqualsBaseline testCase.verifyThat(actual,EqualsBaseline(baseline))
Similarly,
verifyEqualsBaseline(testCase,actual,baseline,AbsTol=abstol,RelTol=reltol)
is functionally equivalent to the following code.import matlabtest.constraints.EqualsBaseline import matlab.unittest.constraints.AbsoluteTolerance import matlab.unittest.constraints.RelativeTolerance testCase.verifyThat(actual,EqualsBaseline(baseline, ... Within=AbsoluteTolerance(abstol) | RelativeTolerance(reltol)))
More functionality is available when using the
EqualsBaseline
constraint directly withverifyThat
.Use verification qualifications to produce and record failures without throwing an exception. Because verifications do not throw exceptions, the test content runs to completion even when verification failures occur. Typically, verifications are the primary qualification for a 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 make the test environment meet 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 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 stop 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, and stopping testing and starting a fresh session is preferable. For more information, see
matlab.unittest.qualifications.FatalAssertable
.
Version History
Introduced in R2024b