forked from bastibe/MatlabCodeAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_unittests.m
More file actions
28 lines (23 loc) · 713 Bytes
/
run_unittests.m
File metadata and controls
28 lines (23 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function run_unittests()
%RUN_UNITTESTS Runs all unit tests
import matlab.unittest.TestSuite
import matlab.unittest.TestRunner
try
% Create a test suite
suite = ...
TestSuite.fromPackage('UnitTest', ...
'IncludingSubpackages', true);
% Run all tests
runner = TestRunner.withTextOutput;
result = runner.run(suite);
% Display results
disp(table(result));
disp(result);
% Throw an error if any test failed
if sum([result(:).Failed]) + sum([result(:).Incomplete]) > 0
error('There are failing unittests!')
end
catch err
disp(err.getReport)
end
end