%% Programmatically Create a Test Harness from a Standalone Model
% This example shows how to use sltest.harness.import to create a test harness by importing a standalone verification model. You create a test harness for a basic cruise control subsystem.
% The standalone 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.

mainModel = 'sltestBasicCruiseControl';
harnessModel = 'sltestBasicCruiseControlHarnessModel';

%
% 1. Load the main model.

load_system(mainModel)

% 2. Create a test harness from the standalone model. Create the harness for subsystem Controller in the main model, with Controller the harness component under test.
%

sltest.harness.import([mainModel '/Controller'],'ImportFileName',harnessModel,...
    'ComponentName',[harnessModel '/Controller'],'Name',...
    'VerificationSubsystemHarness')

%
% 3. Return the properties of the new test harness.

testHarnessProperties = sltest.harness.find([mainModel '/Controller'])

%

close_system(mainModel,0)

% Copyright 2012 The MathWorks, Inc.