Main Content

fatalAssertSignalsMatch

Class: sltest.TestCase
Namespace: sltest

Fatally assert two data sets are equivalent

Since R2020b

Description

example

fatalAssertSignalsMatch(testCase,actual,expected) fatally asserts that the actual and expected signal data values are equivalent. When a fatal assertion fails, the whole test session is stopped. This is useful when the test contains so many errors that it does not make sense to continue the test session.

example

fatalAssertSignalsMatch(___,diagnostic) returns diagnostic information when the actual and expected data values are not equivalent..

example

fatalAssertSignalsMatch(___,Name,Value) fatally asserts with additional options specified by one or more Name,Value pair arguments.

Input Arguments

expand all

Instance of the test case, specified as an sltest.TestCase object.

Actual values to compare to expected values, specified as time series data, a string, or character array. The data for each actual value must pair data value with time value. The data must be in a format supported by the Simulation Data Inspector. The Simulation Data Inspector requires data in a format that associates sample values with time. Supported formats include timeseries, Structure with time, and Dataset.

Example: 'C:/matlab/data/actualData.mat'

Expected values to use as the baseline for the comparison. The data for each expected value must pair data value with time value. The data must be in a format supported by the Simulation Data Inspector. The Simulation Data Inspector requires data in a format that associates sample values with time. Supported formats include timeseries, Structure with time, and Dataset.

Example: 'C:/matlab/data/expectedData.mat'

Diagnostic information to display when the fatal assertion that the actual and expected values are equivalent fails, specified as a string, character array, a function handle, or an instance of a matlab.automation.diagnostics.Diagnostic class.

Example: 'Simulation output does not match.'

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'AbsTol',.02

In addition to the listed Name-Value pairs, you can use the Simulink.sdi.constraints.MatchesSignal Name-Value pairs.

Absolute tolerance, specified as the comma-separated pair consisting of 'AbsTol' and the scalar value of the tolerance. The tolerance specifies the magnitude of the difference between the actual and expected values.

Example: 'AbsTol',1e-9

Relative tolerance, specified as the comma-separated pair consisting of 'RelTol' and the scalar value of the tolerance. The relative tolerance specifies the magnitude of the difference between the actual and expected values, relative to the expected value.

Example: 'RelTol',.002

Time tolerance, specified as the comma-separated pair consisting of 'TimeTol' and the scalar value of the tolerance.

Example: 'TimeTol',.2

Attributes

Accesspublic
Sealedtrue

To learn about attributes of methods, see Method Attributes.

Examples

expand all

Create a test case for interactive use. Then, simulate the model in normal mode to obtain the expected values, and simulate in rapid accelerator mode to obtain the actual values. Use fatalAssertSignalsMatch to compare the values.

testCase =...
   sltest.TestCase.forInteractiveUse;
 
expected = testCase.simulate('myModel',...
   'SimulationMode','Normal');
actual = testCase.simulate('myModel',...
   'SimulationMode','Rapid-Accelerator');
 
testCase.fatalAssertSignalsMatch(actual,expected)

Create a test case for interactive use. Simulate the model in rapid accelerator mode to obtain the actual values. Use fatalAssertSignalsMatch to compare the actual values to the baseline values saved in a MAT-file. Set a relative tolerance.

testCase =...
   sltest.TestCase.forInteractiveUse;
 
actual = testCase.simulate('myModel',...
   'SimulationMode','Rapid-Accelerator');

testCase.fatalAssertSignalsMatch(actual,'baseline.mat',...
   'RelTol',0.001)
 

Create a test case for interactive use. Then, simulate the model in rapid accelerator mode to obtain the actual values. Use fatalAssertSignalsMatch to compare the actual values to the baseline values saved in a MAT-file. Specify the diagnostic message to display if the assertion fails.

testCase =...
   sltest.TestCase.forInteractiveUse;
 
actual = testCase.simulate('myModel',...
   'SimulationMode','Rapid-Accelerator');
 
testCase.fatalAssertSignalsMatch(actual,'baseline.mat',...
   'Rapid-Accel output did not match.')
 

Version History

Introduced in R2020b