MATLAB Examples

Import a Standalone Model as a Simulink® Test™ Harness

This example shows how to import a standalone test model to create a test harness in Simulink Test.

Contents

The Main Model and the Harness Model

The main model sltestBasicCruiseControl is a simple cruise control system, with root import and output blocks.

The standalone test model contains a Signal Builder block driving a copy of the Controller subsystem, with a subsystem verifying that the throttle output goes to 0 if the brake is applied for three consecutive time steps.

Create a Test Harness from the Standalone Model

1. In the main model, right click the Controller subsystem and select Test Harness > Import for 'Controller'.

2. Set the following harness properties:

  • Name: VerificationSubsystemHarness
  • Clear Save test harness externally
  • Simulink model to import: Click Browse and select sltestCruiseControlHarnessModel.
  • Component under Test in imported model: Controller

Click OK.

A test harness is created from the standalone model, owned by the Controller subsystem in the main model Click the badge to preview the test harness.