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

5 visualizzazioni (ultimi 30 giorni)
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 Commenti
Victor-Andrei Predescu
Victor-Andrei Predescu il 28 Mar 2022
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 il 28 Mar 2022
So in the meantime I've found a solution:
TestFile = sltest.testmanager.load(SomeTest);
TestSuite = getTestSuites(TestFile);
TestCases = getTestCases(TestSuite);

Accedi per commentare.

Risposte (1)

Kartik Saxena
Kartik Saxena il 5 Gen 2024
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.

Categorie

Scopri di più su Results, Reporting, and Test File Management in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by