1- function test_anymatrix_properties(regenerate_tests , warnings_on )
1+ function results = test_anymatrix_properties(regenerate_tests , ...
2+ warnings_on , results_out )
23% TEST_ANYMATRIX_PROPERTIES Test anymatrix matrix properties.
34% TEST_ANYMATRIX_PROPERTIES(regenerate_tests, warnings_on)
45% runs unit tests for anymatrix matrix properties.
56% It auto generates the function-based unit tests.
67% If regenerate_tests == 1 (default 0) then the tests are regenerated.
78% If warnings_on == 1 (default 0) then warnings are generated for
8- % properties that do not have tests available
9+ % properties that do not have tests available.
10+ % If results_out == 1 (default 0) then the test results are returned
11+ % which can be useful for generating reports with generatePDFReport()
12+ % and other similar functions.
13+
14+ import matlab .unittest .plugins .DiagnosticsRecordingPlugin
15+ import matlab .unittest .Verbosity
16+ import matlab .unittest .plugins .TestRunProgressPlugin
17+ import matlab .unittest .plugins .DiagnosticsOutputPlugin
918
1019anymatrix(' sc' );
1120root_path = fileparts(strcat(mfilename(' fullpath' ), ' .m' ));
1221
1322if nargin < 1 || isempty(regenerate_tests ), regenerate_tests = 0 ; end
1423if nargin < 2 , warnings_on = 0 ; end
24+ if nargin < 3 , results_out = 0 ; end
1525
1626% Check which properties recognized by anymatrix have tests and throw
1727% warnings for those that can't be tested.
@@ -120,13 +130,21 @@ function test_anymatrix_properties(regenerate_tests, warnings_on)
120130
121131% Configure a test runner.
122132runner = matlab .unittest .TestRunner .withNoPlugins ;
123- import matlab .unittest .plugins .TestRunProgressPlugin
124- import matlab .unittest .plugins .DiagnosticsOutputPlugin
125133runner .addPlugin(TestRunProgressPlugin .withVerbosity(2 ))
126134runner .addPlugin(DiagnosticsOutputPlugin(' OutputDetail' , 2 ))
127135
136+ if (results_out )
137+ runner .addPlugin(DiagnosticsRecordingPlugin( ...
138+ IncludingPassingDiagnostics= false ,LoggingLevel= Verbosity .Verbose ))
139+ end
140+
128141% Run the testsuite.
129142test_results = runner .run(anymatrix_func_based_tests );
130143table(test_results )
131144
145+ % Output the test results if required.
146+ if results_out
147+ results = test_results ;
148+ end
149+
132150end
0 commit comments