-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestRunner.m
More file actions
36 lines (30 loc) · 1.16 KB
/
TestRunner.m
File metadata and controls
36 lines (30 loc) · 1.16 KB
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
30
31
32
33
34
35
36
function result = TestRunner(do_coverage)
%TESTRUNNER Run the Silver Lab Analysis Pipeline tests.
%
% Pass true as an argument to generate a coverage report.
if nargin < 1
do_coverage = false;
end
import matlab.unittest.TestRunner;
import matlab.unittest.TestSuite;
import matlab.unittest.plugins.CodeCoveragePlugin
[tests_folder, ~, ~] = fileparts(mfilename('fullpath'));
source_folder = fullfile(tests_folder, '..', 'source');
suite_folder = TestSuite.fromFolder(tests_folder);
runner = TestRunner.withTextOutput;
if do_coverage
% We have to setup our path fixture here, rather than per test, for the
% coverage plugin to work!
% https://uk.mathworks.com/matlabcentral/fileexchange/33972-coverage-report-generator
% may be a better option for the future...
fixtures = SharedFixtures();
fixtures{1}.setup();
c = onCleanup(@() fixtures{1}.teardown());
runner.PrebuiltFixtures = fixtures{1};
% At present this will only show coverage of the test code (if path changed), not source...
runner.addPlugin(CodeCoveragePlugin.forFolder(source_folder));
result = runner.run(suite_folder);
else
result = runner.run(suite_folder);
end
end