Main Content

updateArtifacts

R2026b

Update trace information for pending artifact changes in the project

    Description

    updateArtifacts(metricEngine) updates the trace information for pending artifact changes in the metric results specified by metricEngine to ensure that artifacts are captured by the metrics. If an artifact was created, deleted, or modified since the last time you used updateArtifacts, running updateArtifacts performs traceability analysis and updates the trace information.

    Note

    When you collect metrics programmatically, call updateArtifacts before running tests to ensure that the dashboard tracks the test results.

    If the dashboard user interface is not used for a project, the dashboard does not track test results produced in Simulink Test Manager that have not been exported to a results file or been saved to a report.

    There is also a function updateArtifacts (Fixed-Point Designer) in the Fixed-Point Designer™ documentation.

    example

    Examples

    collapse all

    Collect metric results on the requirements-based testing artifacts in a project.

    Open a project that contains models and testing artifacts. For this example, in the MATLAB® Command Window, enter:

    openExample("slcheck/ExploreTestingMetricDataInModelTestingDashboardExample");
    openProject("cc_CruiseControl");

    Create a metric.Engine object. You can use the metric.Engine object to collect metric results for the current project.

    metricEngine = metric.Engine();

    Collect results for model testing metrics by executing the metric engine. The execute function returns the collected results.

    results = execute(metricEngine,"modeltesting.TestAnalysis[]")
    results =
    
      1x44 Result array with properties:
    
        UserData
        Value
        MetricID
        Artifacts
        ScopeId
        ScopeAlias
        ThresholdOutcomes
        Diagnostics

    Use getMetrics to access a subset of the collected results. For example, get only the results for the ratio of requirements per test.

    reqsPerTest = getMetrics(metricEngine,"modeltesting.TestAnalysis[slcomp.RequirementsPerTestRatio]")
    reqsPerTest =
    
      1x4 Result array with properties:
    
        UserData
        Value
        MetricID
        Artifacts
        ScopeId
        ScopeAlias
        ThresholdOutcomes
        Diagnostics

    Access the metric results data by using the properties of the metric.Result objects in the array. For this metric, the Value property is a structure containing the total, linked, and unlinked requirement counts.

    reqsPerTest(1).Value
    ans =
    
      struct with fields:
    
           Total: 37
          Linked: 37
        Unlinked: 0
    reqsPerTest(1).ScopeAlias
    ans =
    
        "cc_ControlMode"

    Display the ratio of requirements per test for each unit model in the project.

    models = [reqsPerTest.ScopeAlias].';
    values = [reqsPerTest.Value].';
    total = [values.Total].';
    linked = [values.Linked].';
    unlinked = [values.Unlinked].';
    T = table(models,total,linked,unlinked,VariableNames=["Model","Total","Linked","Unlinked"])
    T =
    
      4x4 table
    
               Model              Total    Linked    Unlinked
        ____________________      _____    ______    ________
    
        "cc_ControlMode"           37        37         0
        "cc_LightControl"           5         5         0
        "cc_DriverSwRequest"       10        10         0
        "cc_ThrottleController"     0         0         0

    For more information on how to collect metrics for testing artifacts, see Collect Metrics on Model Testing Artifacts Programmatically.

    Input Arguments

    collapse all

    Metric engine object for which you want to collect metric results, specified as a metric.Engine object.

    Version History

    Introduced in R2021b