How to skip a test manager case, or toggle the "Enabled" in a test case?

조회 수: 15 (최근 30일)
David
David 2025년 9월 24일
답변: Nidhi 2025년 10월 16일 9:46
I am using Simulink Test.
I would like to skip a test manager case, for example, if I have set a parameter to run a short suite of tests.
I can create a basic test manager file:
% Create a test file
tf = sltest.testmanager.TestFile("test_file");
% Create a test suite within the test file
ts = sltest.testmanager.TestSuite(tf, "My Test Suite");
% Cre a test case of type 'baseline'
tc = createTestCase(ts, "baseline", "My Baseline Test");
However I can not check if the test case is enabled. This seems to fail (I have also checked this with the AI helper).
% Assume 'tc' is your TestCase object
isEnabled = getProperty(tc, 'Enabled');
I can not set this programatically through MATLAB either.
% Assume 'tc' is your TestCase object
setProperty(tc, 'Enabled', false);
Is this possible any other way?
Or can I skip over the test case using another way?

답변 (1개)

Nidhi
Nidhi 2025년 10월 16일 9:46
Hi David,
Currently, Simulink Test does not support programmatically enabling or disabling test cases using MATLAB code.
You can disable a test case manually in the Test Manager GUI by right-clicking the test case and unchecking the "Enabled" option, as shown below:
If you need to skip a test case based on a parameter programmatically, a common workaround is to add conditional logic inside your test script to "skip" the test:
if skipThisTest
disp('Skipping this test case')
return;
end
Alternatively, you can structure your test suites or test file creation logic so that only the desired test cases are included when running tests programmatically.
I hope this helps!

카테고리

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

제품


릴리스

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by