Skip to content

Commit e635358

Browse files
committed
buildfile: add coverage task
1 parent 30bafdd commit e635358

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

buildfile.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@ function testTask(~)
1616
assertSuccess(r)
1717
end
1818

19+
function coverageTask(~)
20+
import matlab.unittest.TestRunner;
21+
import matlab.unittest.Verbosity;
22+
import matlab.unittest.plugins.CodeCoveragePlugin;
23+
import matlab.unittest.plugins.XMLPlugin;
24+
import matlab.unittest.plugins.codecoverage.CoberturaFormat;
25+
26+
name = "matmap3d";
27+
28+
suite = testsuite(name);
29+
30+
mkdir('code-coverage');
31+
mkdir('test-results');
32+
33+
runner = TestRunner.withTextOutput();
34+
runner.addPlugin(XMLPlugin.producingJUnitFormat('test-results/results.xml'));
35+
runner.addPlugin(CodeCoveragePlugin.forPackage(name, 'Producing', CoberturaFormat('code-coverage/coverage.xml')));
36+
37+
results = runner.run(suite);
38+
assert(~isempty(results), "no tests found")
39+
40+
assertSuccess(results)
41+
end
42+
1943
function publishTask(~)
2044
% publish (generate) docs from Matlab project
2145

0 commit comments

Comments
 (0)