Is there any autosave option for tests results in test manager?

53 ビュー (過去 30 日間)
Iñaki Eizaguirre
Iñaki Eizaguirre 2024 年 11 月 13 日 8:12
回答済み: Guilherme Costa Nascimento 2024 年 11 月 14 日 16:40
I just left my computer executing tests cases with test manager during the entire night and at the morning I see that's been turned off. Completely sure that the whole bunch of tests were executed. Therefore, is there any available option for autosaving results?

回答 (2 件)

Madheswaran
Madheswaran 2024 年 11 月 13 日 8:58
編集済み: Madheswaran 2024 年 11 月 13 日 9:30
Starting from MATLAB R2024b, you can view test and coverage results for the five most recent previous runs. I think this would help you to view most recent run. To view a previous run, click the button to the left of the Run button and, under Previous Runs, select a run.
For more information, refer to the following MathWorks documentation page:
With my current understanding, there are no autosave option in the MATLAB Test Manager as of now. However if you would like to save the test report without any manual intervention after every test runs, you can achieve that with the following script:
import matlab.unittest.TestSuite;
import matlab.unittest.TestRunner;
import matlab.unittest.plugins.TestReportPlugin;
% Create test suite from tests directory
suite = TestSuite.fromFolder('tests_folder');
% Create runner and add HTML report plugin
runner = TestRunner.withTextOutput;
runner.addPlugin(TestReportPlugin.producingHTML('TestReport.html'));
% Run tests
runner.run(suite);
The above code creates a test suite from the test files in 'tests_folder' and runs the test suite with 'HTML report plugin'. This would generate and save the report in 'TestReport.html' file.
For more information, refer to the following MathWorks documentation on:
  1. TestReportPlugin: https://mathworks.com/help/matlab/ref/matlab.unittest.plugins.testreportplugin-class.html
  2. Various ways to run MATLAB tests: https://mathworks.com/help/matlab-test/ug/run-matlab-tests.html
Hope this helps!

Guilherme Costa Nascimento
Guilherme Costa Nascimento 2024 年 11 月 14 日 16:40
Assuming you are using Simulink Test:
If you need to save the results themselves rather than a report, use sltest.testmanager.exportResults function.
To do it incrementally, try something like:
testFile = sltest.testmanager.load('myTests.mldatx');
testSuites = getTestSuites(testFile);
for ts = testSuites
res = run(ts);
sltest.testmanager.exportResults(res, [ts.Name ' results.mldatx']);
end

カテゴリ

Help Center および File ExchangeResults, Reporting, and Test File Management についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by