Test Harnesses

Unit testing, integrated code testing, closed-loop scenarios, library testing

Create a test-specific simulation environment for your model by using a test harness. You can isolate individual blocks for unit testing and add inputs, verification logic, and dashboard blocks. Perform closed-loop testing by adding physical plant models to the test harness. Test potential design changes in the test harness before you change the production model.

Compared to using separate models for unit testing, test harnesses offer management and synchronization capabilities in the model canvas. If your model is under change management, you can save test harnesses in external files, without changing the main model.

You can test generated code by simulating test harnesses in SIL or PIL mode. You can also test external handwritten code by creating test harnesses for C Caller or S-Function blocks.

Topics

Create Test Harnesses and Select Properties

Create and customize test harness configurations for your model and subsystem.

Manage Test Harnesses

Manage test harnesses, including opening, converting, closing, deleting, and exporting.

Test Harness and Model Relationship

Test a Simulink® model in an isolated environment, using a separate workspace and configuration set accessed via the model canvas.

Synchronize Changes Between Test Harness and Model

Transfer configuration sets and workspace variables, update the component design, and rebuild the harness to reflect the latest design.

Test Harness Construction for Specific Model Elements

Describes how test harnesses are constructed for certain Simulink semantics and component types.

Customize Test Harnesses

Create reusable functions that customize test harnesses for your particular application, such as adding mixed source and sink block types and adding plant subsystems.

Create Test Harnesses from Standalone Models

Import standalone models as test harnesses in Simulink Test™.

Test Library Blocks

Test reusable components using tests for libraries, library blocks, and linked blocks.

Analyze Code and Test Software-in-the-Loop

Detect code errors, generate code metrics, test code and model equivalence, test code against requirements

Refine, Test, and Debug a Subsystem

Debug and refine a subsystem using a simple test harness.