How to save test suit for TestBrowser

5 次查看(过去 30 天)
Ratchet
Ratchet 2023-12-29
回答: Strider 2024-8-17
I would like to use the TestBrowser
But I don't understand how I can save the settings I make in the TestBrowser. For example I might use the UI to add tests and configure other things regarding the tests. But when I close Matlab and open it again those settings are all gone.
What I was hoping for was some kind of text configuration file where I could specify the tests I want to run in the TestBrowser. That way I would also be able to version it using Git. But I couldn't find anything like that. There also doesn't seem a way to define a TestSuite in code and then have it run in the TestBrowser, or am I missing something?
I'm not asking for alternative TestRunners and Plugins like the runner = testrunner('textoutput') or matlab.unittest.plugins.TestReportPlugin which can be configured and run using simple *.m files that I can version with Git. What I want to know is if something similar is possible but using the TestBrowser.

回答(2 个)

Garmit Pant
Garmit Pant 2024-1-5
Hello Ratchet,
I understand that you are trying to find a method to save your test session with the configurations that you create using MATLAB’s Test Browser so that you can use it across different testing sessions.
To address your queries:
  1. There does not exist a method to write text configuration files where you can specify the tests that you want to run in the Test Browser. Currently, there is no method to run any other file other than M files with MATLAB Test Browser.
  2. The Test Browser does not directly support saving the entire session's configurations. Test Browser’s state is not designed to persist across MATLAB sessions.
  3. As stated above, the Test Browser is only designed to work with M files. Thus, it is not compatible with Test Suites. You can create Test Suites from different tests by using the function "testsuite" as follows:
suite = testsuite;
  1. This will create a Test Suite workspace variable containing all the tests in the working folder. This variable will not work with the Test Browser. But, you can run these tests using the "run" function as follows:
result = run(testsuite);
For further understanding on the “testsuite” function, you can refer to the following MATLAB documentations:
  1. MATLAB "testsuite" function. - https://www.mathworks.com/help/matlab/ref/testsuite.html
  2. Documentation for MATLAB Test Manager app that can be used to create and run test suites for projects. - https://www.mathworks.com/help/matlab-test/ref/matlabtestmanager-app.html#mw_58a2f2cb-81e6-403c-a592-3538596570d1
I hope you find the above explanation and suggestions useful!

Strider
Strider 2024-8-17
This may be what you are looking for. I find the Test Manager slower when updating / adding tests for projects with > 1000 unit tests when compared to the test browser. For this reason I have been reluctant to adopt the Test Manager.
However, this may be because it is using Projects to find related tests which I also find are slow even when using them prgomratically.

类别

Help CenterFile Exchange 中查找有关 Testing Frameworks 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by