-
Notifications
You must be signed in to change notification settings - Fork 9
/
runTests.m
59 lines (48 loc) · 1.89 KB
/
runTests.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function results = runTests(options)
arguments
options.reportHTML = true
options.reportPDF = true
end
import matlab.unittest.TestRunner;
import matlab.unittest.TestSuite;
import matlab.unittest.plugins.TestReportPlugin;
% Define test suite
suite = TestSuite.fromFolder('tests', ...
'IncludingSubfolders', true);
% Build the runner
runner = TestRunner.withTextOutput;
p = mfilename('fullpath');
[filepath, ~, ~] = fileparts(p);
% Add HTML plugin
if options.reportHTML
htmlFolder = fullfile(filepath,'test_results');
plugin = TestReportPlugin.producingHTML(htmlFolder);
runner.addPlugin(plugin);
end
% Add PDF plugin
if options.reportPDF
pdfFile = fullfile(filepath,'test_results.pdf');
plugin = TestReportPlugin.producingPDF(pdfFile);
runner.addPlugin(plugin);
end
% Run the tests
results = runner.run(suite);
end
% Copyright 2020 National Technology & Engineering Solutions of Sandia,
% LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the
% U.S. Government retains certain rights in this software.
%
% This file is part of WecOptTool.
%
% WecOptTool is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% WecOptTool is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with WecOptTool. If not, see <https://www.gnu.org/licenses/>.