How can I extract the number of test cases contained by a test file?

조회 수: 5 (최근 30일)
Victor-Andrei Predescu
Victor-Andrei Predescu 2022년 3월 28일
답변: Kartik Saxena 2024년 1월 5일
Hello,
I'm having some struggles trying to create statistics based on some test manager test files. What I need is to extract the number of test cases contained by all of the test suits found inside a test file. What I'm looking for is something like this:
TestFile = sltest.testmanager.load(SomeTest);
TestCases = sltest.testmanager.NumberOfTestCases(TestFile); %
This is my supposition, if only it would be this simple
The name of the test cases is not important, it's just the number that I need.
One solution would be to run the test file and get the test cases number based on the results, but this would be too much time consuming (Some tests take hours to run).
Is there a way to access that number just by loading the test file?
  댓글 수: 3
Victor-Andrei Predescu
Victor-Andrei Predescu 2022년 3월 28일
Hi KSSV,
A Test File is just the generic file used by Simulink Test Manager available by Simulink Testing App. The test file itself is not important as the structure for any Test File is the same. This is how a generic example looks like:
I need to extract the number of the Test Cases using general sltest.testmanager commands. In the attached example it is 2.
Victor-Andrei Predescu
Victor-Andrei Predescu 2022년 3월 28일
So in the meantime I've found a solution:
TestFile = sltest.testmanager.load(SomeTest);
TestSuite = getTestSuites(TestFile);
TestCases = getTestCases(TestSuite);

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

답변 (1개)

Kartik Saxena
Kartik Saxena 2024년 1월 5일
Hi,
I understand that you want to extract the number of test cases present in all the Test Suites.
To calculate this, you can loop over all the Test Suites and keep adding the number of test cases present in each of them. For this purpose you can use the 'getTestCases' function, which returns an array of test case objects. The size of this array will be the number of test cases present in a Test Suite.
Refer to the following MathWorks documentation for information regarding use of 'getTestCases':
I hope this resolves your issue.

카테고리

Help CenterFile Exchange에서 Results, Reporting, and Test File Management에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by