getCustomCriteriaPlots

Class: sltest.testmanager.TestIterationResult
Package: sltest.testmanager

Get plots from custom criteria

Syntax

figs = getCustomCriteriaPlots(result)

Description

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

Input Arguments

expand all

Test iteration result to get custom criteria plots from, specified as an sltest.testmanager.TestIterationResult object.

Output Arguments

expand all

Figures from test case custom criteria for the specified iteration, returned as an array of figure handles.

Examples

expand all

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

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

% Create a plot in custom criteria and enable custom criteria
tcCriteria = getCustomCriteria(tc);
tcCriteria.Callback = 'a = [1,2,3]; f= figure; plot(a);';
tcCriteria.Enabled = true;

% 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');

% Specify iterations
vars = 32 : 0.5 : 34;

for k = 1 : length(vars)

    % Create test iteration object
    testItr = sltest.testmanager.TestIteration;

    % Set the parameter value for this iteration
    setVariable(testItr,'Name','g','Source','base workspace','Value',vars(k));

    str = sprintf('Iteration %d',k);

    % Add the iteration object to the test case
    addIteration(tc,testItr,str);
end

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

% Get the custom criteria plot figure handles from first iteration
figs = tir(1).getCustomCriteriaPlots;

Introduced in R2017a