Generate Test Harness at the Command Line

You can also create a SystemTest™ test based on a Simulink® model by using the command line. A test harness is created as described in the previous section, but via the command line instead of from Simulink.

The resulting test that is automatically generated is configured for you and the appropriate components of the test are created, including the Simulink element and a Test Case Data test vector. For detailed information about the resulting test, see Generate a Test Harness from Simulink.

The automatic test generation requires that the model contain root-level Inports. If it does not, you will get an error message and a test harness will not be created. There are also other conditions that apply to the root-level Inports and the model. For a list of conditions to use this feature, see Model Requirements for Test Harness Generation.

You use the systest.createHarness function to create the test. systest.createHarness(testFileName,modelName) creates a SystemTest test harness named <testFileName> for the model <modelName>. The test is set up with a Test Case Data test vector and a Simulink element using the information from the Simulink model. The model must be on the MATLAB path. The testFileName must be a writable file location.

The following example creates a test harness from a model:

>>modelName = 'C:\mymodel.slx';
>>testFileName = 'C:\my_new_harness.test';

Was this topic helpful?