Unit testing/continuous integration with Simulink/Stateflow

后端 未结 8 1351
没有蜡笔的小新
没有蜡笔的小新 2021-02-01 05:22

How can I perform unit testing in Simulink, or preferably, Stateflow?

I\'m a fan of agile software methods, including test driven development. I\'m responsible for the d

8条回答
  •  遇见更好的自我
    2021-02-01 05:51

    R2016b introduces integration between Simulink Test and MATLAB Unit Testing framework. Tests created with Simulink Test using Test Manager (*.mldatx) are recognized by and can be run natively using the MATLAB Unit Test Runner and thus you can generate JUnit style XML test results or TAP test results facilitating Continuous integration workflows.

    See this reference for more information: https://www.mathworks.com/help/sltest/ug/run-test-files-using-matlab-unit-test.html?s_tid=gn_loc_drop

    The documentation shows an example of producing TAP results using matlab.unittest.plugins.TAPPlugin but you can use XMLPlugin (https://www.mathworks.com/help/matlab/ref/matlab.unittest.plugins.xmlplugin-class.html) instead just as easily.

    This should open up a better integration within just MATLAB environment even without CI in the picture with the ability to have MATLAB and Simulink Tests together in the same test suite and have them run together seamlessly. For example if you have a directory MYDIR with both native MATLAB unit tests and Simulink Tests, you can do something as simple as the follows to execute both kinds of tests in one shot:

    results = runtests(MYDIR)

提交回复
热议问题