How to Generate Requirements-Based Test Cases
Specification Modeling is the practice of creating models which define the expected behavior of a system. You can model “logic-driven” requirements, such as fault detection and mode logic requirements, using a Requirements Table from Requirements Toolbox. Learn how you can generate requirements-based test cases using Simulink Design Verifier from a Specification Model which uses the Requirements Table feature.
Published: 27 Jan 2023
Specification modeling, also known as requirements modeling, is the practice of creating models which define the expected behavior of a system. You can model logic-driven requirements, such as fault detection and mode logic requirements, using a requirements table from Requirements Toolbox. In this video, I will show you how you can generate requirements-based tests from a specification model which uses the Requirements Table feature.
The requirements-based test generation workflow is comprised of the following steps-- model the requirements, analyze the specification model for consistency and completeness, configure coverage settings, generate tests, and analyze and address gaps in the requirements. The example I will be using is available using the link below.
Pretend, for a moment, that we are engineers working on an autopilot controller. In this case, let's focus on requirements for the autopilot mode and for the roll reference and aileron commands. You ready? Let's begin walking through the workflow.
Step one-- model the requirements. In this case, we have split the requirements up and have modeled them, using two Requirements Tables. One table defines the requirements for the autopilot mode and the other table defines the requirements for the roll reference and aileron commands. Our specification model is therefore a set of Requirements Tables. I won't go through the details of how these requirements were modeled, but feel free to consult our documentation for more information on how to use a Requirements Table.
Step two-- analyze the specification model for consistency and completeness. Requirements are inconsistent if they define conflicting behavior. Requirements are incomplete if they do not fully define the expected behavior. You need to ensure both consistent and complete requirements to mitigate against incorrectly defined behavior.
Let's enable analysis for the entire model, then click Analyze Table to check for consistency and completeness issues. This will automatically launch Simulink Design Verifier to perform the analysis. It turns out the specification model is incomplete. This is due to a missing requirement for the roll reference command. Once we add the missing requirement, we can verify that the table is consistent and complete. Let's move on.
Step three-- configure coverage settings. Using Simulink Coverage, the Requirements Table block can be instrumented for several coverage metrics, such as condition, decision, MCDC, and relational boundary. When developing a Specification Model, I recommend you start by enabling decision coverage.
Step four-- generate requirements-based tests-- the most exciting part. We can generate tests using Simulink Design Verifier. Let's open the Design Verifier app, enable Test Generation mode then click Generate Tests.
Step five-- analyze and address gaps in the requirements. By analyzing the Requirements Table for consistency and completeness first, we are able to generate tests for all requirements. We can view the generated tests in a test harness or open them in Simulink tests.
The logical next steps are to establish traceability between the generated tests and the model requirements. Then, run the generated tests on the design model using the Requirements Table as a verification object. We will cover that workflow in a future video. Click on the link below to try the example.