getSimulationPlots

Class: sltest.testmanager.TestCaseResult
Package: sltest.testmanager

Get plots from test case callbacks

Syntax

figs = getSimulationPlots(result)
figs = getSimulationPlots(result,index)

Description

figs = getSimulationPlots(result) returns figure handles of plots generated from the callbacks of the test case associated with the results. Figures returned using this method are not visible. To see the plots, set the figure handle Visible property to 'on'.

figs = getSimulationPlots(result,index) returns the figure handles from the simulation specified by index.

Input Arguments

expand all

Test case results to get simulation plot figure handles from, specified as an sltest.testmanager.TestCaseResult object.

Simulation index, specified as 1 or 2.

Output Arguments

expand all

Figures from test case callbacks, returned as an array of figure handles.

Examples

expand all

% Create the test file, suite, and case
tf = sltest.testmanager.TestFile('Simulation Plots Test Case');
ts = createTestSuite(tf,'Sim Plots Test Suite');
tc = createTestCase(ts,'baseline','Sim Plots Test Case');

% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);

% Create a plot in a test case callback
setProperty(tc,'PostloadCallback','a = [1,2,3]; f = figure; plot(a);');

% Set option to save figures
opt = getOptions(tf);
opt.SaveFigures = true;

% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_absbrake');

% Run the test and capture results
resultset = run(tf);
tfr = getTestFileResults(resultset);
tsr = getTestSuiteResults(tfr);
tcr = getTestCaseResults(tsr);

% Get the test case callback plots figure handles
figs = tcr.getSimulationPlots;

Introduced in R2017a