-
Notifications
You must be signed in to change notification settings - Fork 1
/
runMUtests.m
30 lines (25 loc) · 1.08 KB
/
runMUtests.m
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
function results = runMUtests
import matlab.unittest.constraints.StartsWithSubstring;
import matlab.unittest.selectors.HasName
import matlab.unittest.selectors.HasBaseFolder;
% find rootDir of tests based on path of this MATLAB function
testRootDir = fileparts(mfilename('fullpath'));
% create test suite from testRootDir
suite = testsuite(testRootDir, 'IncludeSubfolders', true);
% runtest is a utility function from eeglab-testcases when NOT using MATLAB
% Unit Testing Framework. Since it follows naming conventions of MU, we
% need to exclude it here explicitly
suite = suite.selectIf(~HasName('runtest/runtest'));
% disregards tests that are under eeglab subfolder
suite = suite.selectIf(~HasBaseFolder(StartsWithSubstring(fullfile(testRootDir, 'eeglab'))));
% run test suite from test runner
runner = testrunner;
results = run(runner, suite);
% if function is called without output arguments, store results in base
% workspace to not loose them by accident
if nargout == 0
assignin('base', 'results', results)
% display result summary
results %#ok<NOPRT>
clear results
end