Change SimulationMode programmatically for one test run in TestSuite/TestRunner
3 次查看(过去 30 天)
显示 更早的评论
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 )
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Results, Reporting, and Test File Management 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!