Relative/ Absolute path in Baseline Text

조회 수: 4 (최근 30일)
Saurabh Dhakate
Saurabh Dhakate 2024년 7월 16일
댓글: Saurabh Dhakate 2024년 7월 17일
Is it possible to use relative path instead of absolute when adding baseline criteria?

채택된 답변

Gayatri
Gayatri 2024년 7월 16일
Hi Saurabh,
One way to handle this is by leveraging the ‘preLoadFcn’ property of your test cases.
1. Create a Preload Function: Write a function that calculates the path to your MAT file relative to the common base directory and sets this path in a way that your test can use it.
function preloadFunction(testCase)
% Example of setting a relative path for a MAT file
basePath = fileparts(which('yourTestFile.m'));
relativePathToMat = fullfile(basePath, 'relative', 'path', 'to', 'yourMatFile.mat');
testCase.TestData.matFilePath = relativePathToMat;
end
2. Configure Your Test to Use the Preload Function: In the Test Manager or your test script, set the ‘preLoadFcn’ property of your test case to point to the preload function you just created.
Please refer the below documentation for ‘preLoadFcn’ property: https://www.mathworks.com/help/simulink/ug/model-callbacks.html
I Hope it helps!
  댓글 수: 1
Saurabh Dhakate
Saurabh Dhakate 2024년 7월 17일
Thanks for your response, It worked for me.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Testing Frameworks에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by