Skip to content

Commit

Permalink
Update run_coverage_tests.m
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronBrennan1 authored Nov 5, 2024
1 parent 9b23530 commit 0055613
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions run_coverage_tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,18 @@
% Add MOcov to path
addpath(genpath('/opt/MOcov'));

% Get the current directory
current_dir = pwd;

try
% Create test suite from the test file
suite = matlab.unittest.TestSuite.fromFile('test/test_myfunction.m');

% Create a runner with detailed output
runner = matlab.unittest.TestRunner.withTextOutput('Verbosity', 3);

% Run the tests
results = runner.run(suite);
% Run tests directly
disp('Running tests...');
test_results = test_myfunction;

% Display summary
disp('==========================================');
disp('Test Summary:');
disp('==========================================');
disp(['Number of tests: ' num2str(numel(results))]);
disp(['Passed: ' num2str(nnz([results.Passed]))]);
disp(['Failed: ' num2str(nnz([results.Failed]))]);
disp(['Duration: ' num2str(sum([results.Duration])) ' seconds']);
disp('==========================================');

% Generate MOcov coverage report
% Generate coverage report
disp('Generating coverage report...');
mocov('-cover', current_dir, '-cover_xml_file', 'coverage.xml');

% Check if any tests failed
if any([results.Failed])
error('Some tests failed. Check the test report for details.');
end
mocov('-cover', pwd, '-cover_xml_file', 'coverage.xml');

disp('Testing completed successfully.');
exit(0);
catch e
% Display error and exit with failure
disp('Error running tests:');
disp(getReport(e));
exit(1);
Expand Down

0 comments on commit 0055613

Please sign in to comment.