Change SimulationMode programmatically for one test run in TestSuite/TestRunner

3 ビュー (過去 30 日間)
Alexander
Alexander 2020 年 8 月 5 日
回答済み: Pratik Patil 2020 年 11 月 20 日
Hello,
i run multiple tests with the following commands:
import matlab.unittest.TestSuite
import matlab.unittest.TestRunner
mytestsuite = testsuite('mytestmanager.mldatx') %this holds multiple external harness files
mytestrunner = TestRunner.withNoPlugins;
results = table(run(mytestrunner, mytestsuite));
For the test run, i would like to change the SimulationMode (see https://www.mathworks.com/help/simulink/ug/choosing-a-simulation-mode.html ) to Accelerator Mode.
This could normally be changed in the harness file. But how can i do this programmatically for my test run? From my understanding only the testrunner creates the TestClass where i maybe could change that parameter..
Thanks!
( I use Matlab 2019b )

回答 (1 件)

Pratik Patil
Pratik Patil 2020 年 11 月 20 日
Hello Alexander,
I assume you are trying to modify the simulation mode of the testcase in Simulink test file.
You can achieve the same using following lines of code in your script:
tf = sltest.testmanager.TestFile('mytestmanager');
ts = tf.getTestSuites % get first level of test suite in test file
tc = ts.getTestCases % get first level of test case in test suite
setProperty(tc, 'SimulationMode', 'Accelerator'); % set simulation mode to 'Accelerator'
You can refer to documentation for other 'setProperty' options:
https://www.mathworks.com/help/sltest/ref/sltest.testmanager.testcase.setproperty.html

カテゴリ

Help Center および File ExchangeResults, Reporting, and Test File Management についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by