Filter löschen
Filter löschen

Change SimulationMode programmatically for one test run in TestSuite/TestRunner

3 Ansichten (letzte 30 Tage)
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 )

Antworten (1)

Pratik Patil
Pratik Patil am 20 Nov. 2020
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

Kategorien

Mehr zu Test Scripts finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by