When testing models, you may find that your models do not meet design requirements. Resolving these problems requires additional component verification. Depending on your needs, you can use the Signal Editor block, blocks in the Model Verification library, or products such as Simulink® Test™, Simulink Design Verifier™, and Simulink Coverage™ to test model components.
Use Foundational Blocks
You can use the Model Verification library to verify the behavior of your model components. These blocks check if model signals meet specified requirements. If those requirements are not met during simulation, the blocks can stop the simulation or display a warning. For more information, see Test Model Components.
You can also create test cases by using the Signal Editor block to configure your input signals and then log the system outputs. For more information, see Create and Edit Signal Data. After creating the signal data, you can log the outputs and save the test cases for later use. For more information, see Mark Signals for Logging.
Perform Rigorous Component Verification
Some components require a large number of tests that are difficult to manage using only the Model Verification library and the Signal Editor block. If you require more rigorous component verification, use Simulink Test.
You can generate test case data for either a component in isolation or for a component that is part of a model.
Create Test Cases for an Isolated Component
To verify how a component behaves in absence of other components, you can test isolated components.
To create test case data for an isolated component:
Create a test harness for the component with Simulink Test and add the appropriate test cases. For more information on how to create a test harness, see Create a Test Harness (Simulink Test).
Log the test signals.
Repeat steps 1-2 until you configure the test cases to meet your design goals.
Create Test Cases for a Component in a Model
You can also create test case data for a component in a larger model, such as when the component is in a closed-loop controller or part of a broader container model.
To create test case data for a component in a model:
Use Simulink Test to add the appropriate test cases to the model.
Add the component to a test harness and generate the component test cases directly from the model. For more information, see Generate Tests and Test Harnesses for a Model or Components (Simulink Test).
If the test cases are not comprehensive, create a harness for the component and add or modify test cases.
Repeat steps 1-3 until you configure the test cases to meet your design goals.
Run the Test Suite on the Component
If you create test cases for both isolated components and components in a model by using Simulink Test, the resulting test suite contains all of the test cases. The Test Manager in Simulink Test allows you to manage and execute the test cases you created. For more information, see Create a Simple Baseline Test (Simulink Test). The Test Manager also allows you to perform additional verification activities, such as analyzing coverage. For more information, see Collect Coverage in Tests (Simulink Test). Once the results meet your design goals, you can prepare the component for additional testing.
Use Other Products for Additional Test Case Management
If the component coverage is incomplete, you can use Simulink Design Verifier to automatically create test cases that can supplement missing test coverage. For more information, see What Is Test Case Generation? (Simulink Design Verifier). You can then rerun the analysis in Simulink Test. If you are satisfied with the results, you can use the test case data to verify additional design objectives by using Simulink Coverage and Simulink Check™.
You can also perform some of the activities available in Simulink
Test with other products, although these options have more limited
For example, you can create a test harness with the
slvnvmakeharness (Simulink Coverage)
function. If you are only interested in the simulation outputs, you can run
the test case input signals by creating a
object and running multiple simulations. For more information, see Running Multiple Simulations.
- Get Started with Simulink Coverage (Simulink Coverage)
- Get Started with Simulink Test (Simulink Test)
- Get Started with Simulink Design Verifier (Simulink Design Verifier)
- Programmatic Code Generation Verification (Embedded Coder)