Verify and Validate System
R2026bThis project includes test harnesses for a model component, the software architecture model, and the full system, enabling you to verify individual algorithms and then validate the full closed-loop system.
In this section, you:
Run simulations using test harnesses.
Define and run test cases in Simulink Test Manager (Simulink Test).
Compare results across battery pack fidelity variants.
Trace requirements to architecture, models, and tests.
Tip
Open Doc/BMSVerificationAndValidation.m in the project for
an interactive walkthrough of this section.
Test Harnesses
The project includes three test harnesses at increasing levels of integration:
| Harness | Level | Location | What It Tests |
|---|---|---|---|
StateMachineHarness.slx | Component | Tests/StateMachine/ | StateMachine component in isolation. Uses
Signal Editor inputs to test Standby, Charging, Driving, and Fault
scenarios. |
BMSAlgorithmArchitectureHarness.slx | Architecture | Tests/BMS/ | All three controller components connected through the reference architecture. |
BMSHarness.slx | System | Tests/BMS/ | Closed-loop simulation connecting the BMS controller to the
BatteryModel plant through the Input and
Output Adapters. |
Start with the model component test harness
(StateMachineHarness.slx) to verify and validate the
algorithmic behavior of the StateMachine component. Then, to
verify the BMS controller, simulate the software architecture model test harness
(BMSAlgorithmArchitectureHarness.slx). After model components
and intermediate systems are validated, you can simulate the full system, for
closed-loop validation, using the system-level test harness
(BMSHarness.slx).

For more information about generating test harnesses, see Test Harnesses for Models and Model Components (Simulink Test) and Create a Test Harness (Simulink Test).
Run a Simulation
To run a quick closed-loop simulation:
Set the battery pack to the Lumped fidelity level for fast execution. In
BatteryData.sldd, setBattModelResolutionto0.Open the system-level test harness:
open_system('BMSHarness')Run the simulation. View results in the Simulation Data Inspector.
For more information, see Decide How to Visualize Simulation Data.
Define and Run Test Cases
Use Simulink® Test™ Test Manager (Simulink Test) to organize test scenarios and automate test execution.
The project includes a predefined test file for the
StateMachine component:
StateMachineTest.mldatx— Test Manager file with test cases for Charging, Driving, Standby, and Fault Injection scenarios.StateMachineHarnessInputs.mat— Input signal data for the test scenarios.StateMachineTestResults.mldatx— Baseline results stored for comparison.
To run the tests:
Open the Simulink Test Manager.
If you have the
StateMachine.slxmodel open, on the toolstrip, select the Tests tab, and click Simulink Test Manager.If you have the
StateMachineHarness.slxmodel open, on the toolstrip, select the Harness tab, and click Simulink Test Manager.
Open the test file that defines the test cases,
StateMachineTest.mldatx.On the toolstrip, select Open > Open (.mldatx).
Browse for the test file in the project at this filepath:
"\UseMBDtoBuildaBMS\SystemIntegrationAndTest\Tests\StateMachine\StateMachineTest.mldatx".Once Test Manager loads the test file, the Dashboard shows the
StandBytest case.
Run the test suite and review pass/fail results.
Click Run.
For more information, see View Test Case Results (Simulink Test).
Compare Battery Pack Variants
To compare simulation results across battery pack fidelity levels:
Change the fidelity level by using the
BattModelResolutionparameter in the battery data dictionary,BatteryData.sldd:0= Lumped1= Grouped2= Detailed
For more information about model resolution options, see Define Model Resolution (Simscape Battery).
Run the system-level test harness,
BMSHarness.slx, for each battery fidelity level.Use the Simulation Data Inspector to compare signals across runs:
Simulink.sdi.view
For more information, see Running Multiple Simulations in Simulink.
Requirements Traceability
Link requirements to architecture elements, model blocks, and test cases to establish a complete digital thread:
Requirements → Architecture — Link requirements from
BMSSwRequirements.slreqxto their associated components in the software architecture,BMSAlgorithmArchitecture.slx.Requirements → Implementation — Link requirements to behavior models of each component, such as
StateMachine.slx.Requirements → Verification — Link requirements to test cases defined in
StateMachineTest.mldatx.For more information, see Link Test Cases to Requirements Documents (Requirements Toolbox).
Traceability files (.slmx) alongside each model store these
links. For example, StateMachineTest~mldatx.slmx stores the links
between test cases and their associated requirements.
Tip
To check whether there are any requirements that are not yet linked to an implementation or test, use the Requirements Perspective. For more information, see Export and Report Requirements and Traceability (Requirements Toolbox).
See Also
Requirements Editor (Requirements Toolbox) | Simulink Test Manager (Simulink Test)
Topics
- Create a Test Harness (Simulink Test)
- Test Model Against Requirements and Report Results (Simulink Check)