-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrunTests.m
More file actions
29 lines (20 loc) · 977 Bytes
/
runTests.m
File metadata and controls
29 lines (20 loc) · 977 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
29
function results = runTests()
import matlab.unittest.TestSuite matlab.unittest.TestRunner
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.codecoverage.CoverageReport
root_path = nla.findRootPath();
% get all unittests folders
filelist = dir(fullfile(root_path, '**/unittests'));
% make cell array with extra check on if directory
test_folders = {filelist([filelist.isdir]).folder};
test_folders = convertCharsToStrings(unique(test_folders));
test_suite = TestSuite.fromFolder(test_folders(1));
for folder = 2:numel(test_folders)
test_suite = [test_suite TestSuite.fromFolder(test_folders(folder))];
end
runner = TestRunner.withTextOutput;
report_format = CoverageReport("coverageReport");
plugin = CodeCoveragePlugin.forFolder(root_path, "IncludingSubfolders", true, "Producing", report_format);
runner.addPlugin(plugin);
results = runner.run(test_suite);
end