Unit Testing Stateflow Models

9 views (last 30 days)
Richard Good
Richard Good on 11 Mar 2021
Commented: Richard Good on 11 Mar 2021
Hello Mathworks Community,
I have looked at a similar post on unit testing in Stateflow, but the links didn't really help, maybe I'm using the wrong terms. I want to run a series of tests on a Stateflow model everytime we change it (regression tests) These tests involved introducing data into the charts. I want a sort of automated debugging session I guess. The idea would be to have all this kicked off by a simulink report and to run the various tests and create plots and output a test report. The model has been imported from another tool, so the practice of injecting data into the chart at various times automatically needs to be maintained. I can figure out how to do this manuall, but can't find an example of doing this using a script. Any wise words/ recommendations? Note I cannot use the Test toolbox as that is not available on the clients system.
Cheers
Richard

Answers (1)

Steven Lord
Steven Lord on 11 Mar 2021
If you know how to programmatically interface with the charts and how to execute them but cannot use the Simulink Test product, try using the testing framework included as part of MATLAB.
  1 Comment
Richard Good
Richard Good on 11 Mar 2021
Hi Steve
Thanks for your reply. I do know about the Stateflow API and I did have a look at the executing Standalone Charts article. The model I am looking at has several subsystems and lots of data going between them, I do not believe I can use this feature because of the limitations of Standalone charts. I think the Operating Points feature is the closest thing to what I want. Apologies, I mean regression tests not unit tests really. The legacy system created an executable model where you could inject chart data at the start and at various times during the simulation. I want to migrate the tests as directly as possible to verify I have migrated the model into Stateflow correctly. The legacy software is called Statemate if that helps.
Cheers for any pointers
Richard

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!