-
Notifications
You must be signed in to change notification settings - Fork 5
/
testScript.m
35 lines (31 loc) · 1.12 KB
/
testScript.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
31
32
33
34
35
% TESTING CODE
import matlab.unittest.TestSuite;
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.codecoverage.CoverageReport
sourceCodeFolder = {'API', 'targetFunctions', 'utilities'};
reportFolder = 'htmlcov';
reportFormat = CoverageReport(reportFolder);
p = CodeCoveragePlugin.forFolder(sourceCodeFolder, ...
'Producing', reportFormat, ...
'IncludingSubfolders', true);
disp('Starting Parallel Pool')
% if parallel pool has already been started, continue with it
if isempty(gcp('nocreate'))
parpool('threads');
else
% display how many workers are in the pool
pool = gcp('nocreate');
disp(['Current Parallel Pool has ' num2str(pool.NumWorkers) ' workers. No need to start.'])
end
disp('Adding paths Initiated')
addPaths;
disp('Adding paths Completed')
allTests = TestSuite.fromFolder('tests','IncludingSubfolders', true);
disp('Running unit tests')
runner = testrunner;
runner.addPlugin(p)
result = run(runner, allTests);
if(any(arrayfun(@(x) x.Failed, result)))
error('Test failed');
end
disp('Unit Testing Complete')