Main Content

Categorize Models in a Hierarchy as Components or Units

When testing your model-based software architecture, there are different testing requirements for different levels of the architecture. The Model Testing Dashboard helps you to focus on the models that require unit testing so you can assess their testing quality. You can tag the models in your projects as units or components, then use the Model Testing Dashboard to see the hierarchy and analyze the testing requirements for the units. For more information, see Explore Status and Quality of Testing Activities Using the Model Testing Dashboard.

Units in the Model Testing Dashboard

A unit is a functional entity in your software architecture that you can execute and test independently or as part of larger system tests. Software development standards, such as ISO 26262-6, define objectives for unit testing. Unit tests typically must cover each of the requirements for the unit and must demonstrate traceability between the requirements, the test cases, and the unit. Unit tests must also meet certain coverage objectives for the unit, such as modified condition/decision coverage.

You can label models as units in the Model Testing Dashboard. The dashboard then provides metric results for each unit. If you do not specify the models that are considered units, then the dashboard considers a model to be a unit if it does not reference other models.

In the Model Testing Dashboard, in the Artifacts pane, the unit dashboard icon Unit dashboard icon. indicates a unit. If a unit is referenced by a component, it appears under the component. If a unit references one or more other models, those models are part of the unit. The referenced models appear in the Design folder under the unit and contribute to the metric results for the unit.

Artifacts panel showing the model Component1 expanded to show the models Unit1 and Unit2. The panel also shows the model Component2 expanded to show Component3.

To specify which models are units, label them in your project and configure the dashboard to recognize the label, as shown in Specify Models As Components and Units.

Components in the Model Testing Dashboard

A component is an entity that integrates multiple testable units together. For example, a model that references multiple unit models could be a component model. A component could also integrate other components. The Model Testing Dashboard organizes components and units under the components that reference them in the Artifacts pane. The dashboard does not provide metric results for components because components typically must meet different testing objectives than units.

If you do not specify the models that are considered components, then the dashboard considers a model to be a component if it references one or more other models.

In the Model Testing Dashboard, in the Artifacts pane, the component icon Component icon. indicates a component. To see the models under a component, expand the component node by clicking the arrow next to the component icon.

To specify the models that are considered components, label them in your project and configure the dashboard to recognize the label, as shown in Specify Models As Components and Units.

Specify Models As Components and Units

You can control which models appear as units and components by labeling them in your project and configuring the Model Testing Dashboard to recognize the labels.

  1. Open your project. For example, at the command line, type dashboardCCProjectStart. This example project is already has component and unit models configured.

  2. On the MATLAB® toolstrip Project window, right-click in the Labels pane and click Create New Category. Enter a name for the category that will contain your testing architecture labels, for example, Testing Interface.

  3. Create a label for the units. On the Labels pane, right-click the category that you created and click Create New Label. Name the label Software Unit.

  4. Create another label for component models and name the label Software Component.

    Project window showing the labels pane in the bottom left corner. The Testing Interface category is expanded and the labels Software Component and Software Unit under the category.

    The unit and component labels appear under the category in the Labels pane.

  5. Label the models in the project as components and units. In the project pane, right-click a model and click Add label. In the dialog box, select the label and click OK. For this example, apply these labels:

    • db_Controller — Software Component

    • db_ControlMode — Software Unit

    • db_DriverSwRequest — Software Unit

    • db_TargetSpeedThrottle — Software Unit

  6. In the Project tab, in the Tools section, click Model Testing Dashboard.

  7. In the Dashboard tab, click Options.

  8. In the Project Options dialog box, specify the category and labels that you created for the components and units. For the component interface, set Category to Testing Interface and Label to Software Component. For the unit interface, set Category to Testing Interface and Label to Software Unit.

    Project Options dialog box showing categories and labels specified for component and unit interfaces.

  9. Click Trace Artifacts. The dashboard updates the traceability information in the Artifacts pane and organizes the models under the component models that reference them. If a model is not referenced by a component, it appears at the top level of the components.

For each unit, the dashboard shows the artifacts that trace to the unit. To view the metric results for a unit, click the unit name in the Artifacts pane.

Related Topics