This example demonstrates how to perform requirements-based testing of a MATLAB Simulink model using the BTC EmbeddedPlatform (BTC). The example includes a Simulink model for a seat heating controller, which is tested against a set of requirements.
Preparation
- Create a new branch for your changes
- Open the
seat_heating_controller.slxmodel in MATLAB Simulink. - Click "Activate" in the BTC EmbeddedPlatform ribbon bar
First test
- Create a test case that cycles through the heating stages (button pressed 4 times) and link it to the relevant requirements
- Run the test case and observe the results in the BTC Test Manager
Debugging
- Activate the Debug-mode, then add a break in the
convert_to_stagesubsystem - Debug the test case and identify the issue
- Fix the issue in the model and re-run the test case
Hierarchical test case
- In order to test requirement '0 - CondCheck', convert the
activation_condition_checksubsystem to a referenced subsystem - Navigate into the subsystem and click "New" in the BTC EmbeddedPlatform ribbon bar, then click "Add" to create a test case
- Check that the correct combination of inputs activates the system
- Save the test case
Triggering Automated Tests
- Commit your changes to the branch and publish it to GitHub
- Create a pull request
- Navigate to the PR on github.com and check the status of the GitHub Actions pipeline
The GitHub Actions pipeline is triggered on pull requests and pushes. It performs the following steps:
- Checkout files: Uses the
actions/checkout@v4action to check out the repository files. - Run tests:
- Run MIL tests, only continue if all tests pass
- Run SIL tests
- Publish test results to Polarion
- Create HTML report with
- MIL + SIL test results
- Code coverage
- traceability information
- Publish test results to GitHub Pages: Uses the
peaceiris/actions-gh-pages@v4action to publish test results to GitHub Pages. - Publish results: Uses the
dorny/test-reporter@v1action to publish test results, regardless of success or failure. - Add test report link to PR: Adds a comment to the pull request with a link to the test report
The model directory contains all files relevant to the Simulink model:
seat_heating_controller.slx(main model)init.m
The test directory contains the test projects (interactive MIL project for developer testing + MIL/SIL project with full testing capabilities, code coverage, etc.) and a python script to automate the test execution