-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_tests.m
57 lines (38 loc) · 1.68 KB
/
run_tests.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
function results = run_tests()
% main script to initialize PCSSP and run all tests in batch
import matlab.unittest.TestRunner
import matlab.unittest.TestSuite
import matlab.unittest.plugins.XMLPlugin
import matlab.unittest.plugins.TestReportPlugin
import matlab.unittest.plugins.CodeCoveragePlugin
% use testSuite method to build suite from Folder, selecting only those
% tests that have pcssp_test as superclass. More options here:
% https://nl.mathworks.com/help/matlab/ref/matlab.unittest.testsuite-class.html
pcssp_add_paths();
% add platform specific path to large test input data
test_data_path = getenv("TEST_DATA_PATH");
if ~isempty(test_data_path)
addpath(genpath(test_data_path));
end
suite = TestSuite.fromFolder(pwd,'IncludingSubfolders',true,'Superclass',{'pcssp_module_test','pcssp_wrapper_test','pcssp_topmodel_test'});
runner = TestRunner.withNoPlugins;
% add JUnit xml-writer plug-in to test
xmlFile = 'testResults.xml';
p = XMLPlugin.producingJUnitFormat(xmlFile);
% add html test report to suite
htmlFile = "testreport";
p1 = TestReportPlugin.producingHTML(htmlFile);
% add code coverage for pcssp
reportFormat = matlab.unittest.plugins.codecoverage.CoverageReport("coverageReportPCSSP");
% add m-files in repo, excluding scdds
dirOut = dir('**/*.m');
codeFilepaths = string({dirOut.folder}) + filesep + string({dirOut.name});
filePathsToExclude = fullfile(fileparts(mfilename('fullpath')),'scdds-core');
codeFilepaths(contains(codeFilepaths, filePathsToExclude)) = [];
p2 = matlab.unittest.plugins.CodeCoveragePlugin.forFile(codeFilepaths,'Producing',reportFormat);
% run the tests
runner.addPlugin(p)
runner.addPlugin(p1)
runner.addPlugin(p2)
results = runner.run(suite);
end