Main Content

find

Find assessments in sltest.AssessmentSet or sltest.Assessment object

Description

asout = find(as,'PropertyName','PropertyValue') returns the results asout specified by the properties matching 'PropertyName', and 'PropertyValue'.

asout = find(as,'PropertyName1','PropertyValue1','–logical','PropertyName2','PropertyValue2'...) returns the results asout specified by multiple 'PropertyName', 'PropertyValue' pairs, and the '–logical' operator specifying the connective between the pairs. '–logical' can be '–and' or '–or'.

asout = find(as,'–regexp','PropertyName','PropertyValue') returns assessment results whose 'PropertyName' matches the regular expression 'PropertyValue'. When using regular expression search, 'PropertyName' can be the assessment object 'Name' or 'BlockPath'.

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('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: Fail

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):
    2 : Untested 'Simulink:verify_high'
    3 : Untested 'Simulink:verifyTKLow'
    4 : Untested 'Simulink:verifyTKNormal'

  Failed Assessments (first 10):
    1 : 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):
    4 : Untested 'Simulink:verify_high'
    5 : Untested 'Simulink:verifyTKLow'
    6 : Untested 'Simulink:verifyTKNormal'

  Passed Assessments (first 10):
    1 : Pass 'Simulink:verify_normal'
    2 : Pass 'Simulink:verify_low'

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

Re-enable warnings

warning on Stateflow:Runtime:TestVerificationFailed

Input Arguments

collapse all

Assessment object to search.

Example: as

Logical operator connecting multiple property names or property values.

Example: '–and'

Type of property to search.

Example: 'BlockPath'

Property value to search, specified as a character vector. Can be a regular expression when using the '–regexp' argument.

When using the 'Result' property name, 'PropertyValue' is an enumeration of the assessment result:

  • slTestResult.Fail for failed assessments

  • slTestResult.Pass for passed assessments

  • slTestResult.Untested for untested assessments

Example: slTestResult.Fail

Example: '[Aa]sess'

Regular expression for BlockPath properties search, specified as a character vector.

Example: '–regexp'

Output Arguments

collapse all

Assessment results output from the find operation, specified as an sltest.assessmentSet object.

Example: sltest.AssessmentSet

Version History

Introduced in R2016b