MATLAB Examples

Delete Test Harnesses Programmatically

This example shows how to delete test harnesses programmatically. Deleting with % the programmatic interface can be useful when your model has multiple test harnesses at different hierarchy levels. This example demonstrates creating four test harnesses, then deleting them.

1. Open the model

open_system('sltestCar');

2. Create two harnesses for the transmission subsystem, and two harnesses for the transmission ratio subsystem.

sltest.harness.create('sltestCar/transmission');
sltest.harness.create('sltestCar/transmission');
sltest.harness.create('sltestCar/transmission/transmission ratio');
sltest.harness.create('sltestCar/transmission/transmission ratio');

3. Find the harnesses in the model.

test_harness_list = sltest.harness.find('sltestCar')
test_harness_list = 

  1x5 struct array with fields:

    model
    name
    description
    type
    ownerHandle
    ownerFullPath
    ownerType
    isOpen
    canBeOpened
    lockMode
    verificationMode
    saveExternally
    rebuildOnOpen
    rebuildModelData
    postRebuildCallback
    graphical
    origSrc
    origSink
    synchronizationMode

4. Delete the harnesses.

for k = 1:length(test_harness_list)
     sltest.harness.delete(test_harness_list(k).ownerFullPath,...
     test_harness_list(k).name)
end
close_system('sltestCar',0);