필터 지우기
필터 지우기

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 CenterFile Exchange에서 Test Scripts에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by