sltest.Assessment

Access assessment from set

Description

An sltest.Assessment object is an individual assessment result from an sltest.AssessmentSet object.

Creation

Create an sltest.Assessment object using result = get(as,index) where as is an sltest.AssessmentSet object.

Properties

expand all

Path to block containing the assessment. For a Test Sequence block, the sub path is a path to the test step containing the assessment. See Simulink.SimulationData.BlockPath.

Example: Simulink.SimulationData.BlockPath

Name of the assessment, specified as a character vector. For a verify() statement, results in the Test Manager are identified by the name.

Example: 'Simulink:verify_low'

Output of the assessment, specified as a timeseries.

Example: Values: [1×1 timeseries]

Result of the assessment.

Example: 'Fail'

Object Functions

dispDisplay results of sltest.AssessmentSet or sltest.Assessment
findFind assessments in sltest.AssessmentSet or sltest.Assessment object
plotPlot simulation output data in the Simulation Data Inspector

Examples

collapse all

This example shows how to simulate a model with verify statements and obtain assessment results via the programmatic interface.

Get the Assessment Set and One Assessment Result

1. Open the model.

open_system(fullfile(matlabroot,'examples','simulinktest',...
    'sltestRollRefTestExample.slx'))

% Turn the command line warning off for verify() statements
warning off Stateflow:Runtime:TestVerificationFailed

2. Run the model.

s = sim('sltestRollRefTestExample');

3. Get the assessment set.

as = sltest.getAssessments('sltestRollRefTestExample');

4. Get assessment 3 from the assessment set.

as3 = get(as,3);

Display Results of the Assessment Set and Assessment Result

1. Get summary of the assessment set.

asSummary = getSummary(as)
asSummary = 

  struct with fields:

       Total: 6
    Untested: 3
      Passed: 2
      Failed: 1
      Result: Fail

2. Display the result of assessment 3.

disp(as3)
  sltest.Assessment
  Package: sltest

  Properties:
         Name: 'Simulink:verify_high'
    BlockPath: [1x1 Simulink.SimulationData.BlockPath]
       Values: [1x1 timeseries]
       Result: Untested

3. Find untested or failed results in the assessment set.

asFailUntested = find(as,'Result',slTestResult.Fail,'-or',...
    'Result',slTestResult.Untested)
asFailUntested = 

  sltest.AssessmentSet
  Summary:
       Total: 4
    Untested: 3
      Passed: 0
      Failed: 1
      Result: Fail


  Untested Assessments (first 10):
    1 : Untested 'Simulink:verifyTKNormal'
    2 : Untested 'Simulink:verifyTKLow'
    3 : Untested 'Simulink:verify_high'

  Failed Assessments (first 10):
    4 : Fail 'Simulink:verify_high'

4. Find assessments under the Test Assessment block, using a regular expression.

assessBlock = find(as,'-regexp','BlockPath','.[Aa]ssess')
assessBlock = 

  sltest.AssessmentSet
  Summary:
       Total: 6
    Untested: 3
      Passed: 2
      Failed: 1
      Result: Fail


  Untested Assessments (first 10):
    1 : Untested 'Simulink:verifyTKNormal'
    2 : Untested 'Simulink:verifyTKLow'
    3 : Untested 'Simulink:verify_high'

  Passed Assessments (first 10):
    5 : Pass 'Simulink:verify_low'
    6 : Pass 'Simulink:verify_normal'

  Failed Assessments (first 10):
    4 : Fail 'Simulink:verify_high'

Re-enable warnings

warning on Stateflow:Runtime:TestVerificationFailed

Introduced in R2016b