필터 지우기
필터 지우기

How to select the harness of model through scripting commands and select the harness in test manager automatically by just specifying the harness name

조회 수: 4 (최근 30일)
I am trying to access the test manager through scripting commands .I getted the harnessList = sltest.testmanager.find(Model_Name), getting list of harnesses present woth fields .I have used testmanager.SetProperty ('HarnessName' ,name) and testmanager.SetProperty('HarnessOwner', OwnerfullPath) by field names of the harnessList bybut still the property is not setted in test manager .I want to select the harness in the test manager through scripting functions .The above is not selecting the desired harness which I want to select from the harnessList.Please help to solve this if any one knows.Any UI method or command lines .The model is selected the Harness is drop down showing harness of internaly saved ,lets says the harnesses from XML saved info file .I want to select the harnesses by name .Help me out!

채택된 답변

Paras Gupta
Paras Gupta 2024년 5월 6일
Hi Mahesh,
I understand that you want to select a test harness within a test case programatically using commands. The following example on the 'f14' model shows one way to achieve the same:
openExample('f14');
% create test harnesses
sltest.harness.create('f14','Name','model_harness_test');
sltest.harness.create('f14/Controller','Name',...
'Controller_Harness_test');
harnessList = sltest.harness.find('f14');
% create test file, suite, and case
tf = sltest.testmanager.TestFile('Test Scripts');
ts = createTestSuite(tf,'Test Scripts Suite');
tc = createTestCase(ts,'baseline','Baseline API Test Case');
% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);
% Assign the system under test to the test case
setProperty(tc,'Model','f14');
setProperty(tc,'HarnessName','Controller_Harness_test','HarnessOwner','f14/Controller');
% We can see the harness set in test manager by opening it
sltest.testmanager.view;
It is to be noted that the 'HarnessName' and 'HarnessOwner' property should be set together in the same command. You can refer to the following documentation links for more information on the code above:
  1. 'setProperty' function - https://www.mathworks.com/help/sltest/ref/sltest.testmanager.testcase.setproperty.html
  2. 'createTestCase' function - https://www.mathworks.com/help/sltest/ref/sltest.testmanager.testsuite.createtestcase.html
  3. Create and Run Test Cases with Scripts - https://www.mathworks.com/help/sltest/ug/create-and-run-test-cases-with-scripts.html
  4. Create harnesses - https://www.mathworks.com/help/sltest/ref/sltest.harness.create.html
Hope this helps resolve your query.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Test Execution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by