Main Content

Create and Run a Back-to-Back Test

This example shows how to create and run a back-to-back test, which is also known as an equivalence test. Back-to-back tests compare the results of normal simulations with the generated code results from software-in-the-loop, processor-in-the-loop, or hardware-in-the-loop simulations.

  1. Set the current working folder to a writable folder.

  2. Open the rtwdemo_sil_block model.

    open_system('rtwdemo_sil_block')

  3. To select the component to test, click the Controller subsystem.

    Model with controller subsystem selected

  4. To open the Simulink Test tab, in the Apps tab, in the Model Verification, Validation, and Test section, click Simulink Test.

  5. To open the Test Manager, in the Tests tab, click Simulink Test Manager.

    Tests tab with Simulink Test Manager button highlighted

  6. Click New > Test for Model Component. The Create Test for Model Component wizard opens.

  7. To specify the Top model and Component to test, fill the fields by clicking the Use currently selected model component button next to the Component field.

    First page of wizard with top model and component fields filled in

  8. Click Next to specify how to obtain the test harness inputs. Select Use component input from the top model as test input. This option runs the model and creates the test harness inputs using the inputs to the selected model component.

    Test Inputs, second page of wizard, with Use component input selected

  9. Click Next to select the testing method. Click Perform back-to-back testing. For Simulation1, use Normal. For Simulation2, use Software-in-the-Loop (SIL).

    Verification strategy, third page of wizard, with perform back to back testing selected with the simulations set to Normal and software in the loop

  10. Click Next to specify the test harness input source, format, and where to save the test data and generated tests. For Specify the file format in which to save the test data, select EXCEL. For Specify the location to save test data, use the default location name. Enter B2BtestFile for the Test File Location.

    Generated test, last page of the wizard, with Inports as the harness source, Excel as the file format, and save location for test data and generated tests specified

  11. Click Done. The test harness and test case are created and the wizard closes.

    Test Manger with generated test case

Run the Back-to-Back Test

To run the back-to-back test, click Run.

View the Back-to-Back Test Results

Expand the Results hierarchy in the Results and Artifacts panel. Select Out1:1 under Equivalence Criteria Result. The upper plot shows that the output signals align and the lower plot shows that there is zero difference between the output signals.

Test Manager results plot of the baseline and simulation output signals, and another plot of the output differences

See Also

| |

Related Topics