forked from opencobra/cobratoolbox
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_coverage_tests.m
35 lines (28 loc) · 1.06 KB
/
run_coverage_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
function run_coverage_tests()
% Add MOcov to path
addpath(genpath('/opt/MOcov'));
try
% Run tests and capture results
disp('Running tests with coverage...');
% Run tests directly first to capture results
results = runtests('test/test_myfunction.m');
passed = all([results.Passed]);
% Now run MOcov with a simpler expression that just runs the tests
test_expression = 'runtests(''test/test_myfunction.m'')';
% Run MOcov for coverage analysis
mocov('-cover', '.', ...
'-cover_xml_file', 'coverage.xml', ...
'-expression', test_expression);
% Check results
if ~passed
error('Some tests failed. Check the test results for details.');
end
disp('All tests passed successfully!');
disp(['Number of passed tests: ' num2str(sum([results.Passed]))]);
exit(0);
catch e
disp('Error running tests:');
disp(getReport(e));
exit(1);
end
end