Test utility pattern: Simulink Test

As I have written about in previous posts I recommend the use of reusable test utilities.  When working in the text-based MATLAB environment how to create reusable utilities is easily understood; they are simply MATLAB functions.  However,  within the Simulink Test graphical environment, it may not be as clear.

Libraries and Functions

Fortunately, there is a solution; if there wasn’t there would be no post today.  Within the Simulink Test environment, calls can be made to functions.  The functions can be either return a value (or values) or directly set an assert or verify flag.

testCalls

The functions are imported from a Simulink Library and can be constructed from MATLAB or Simulink Function blocks.

testLibrarySetup

In the case of MATLAB functions that are placed in a Stateflow block with the functions export option selected.

exportFunction

So there you have it, a simple solution to reusable test utilities within the Simulink Test environment.

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.