Skip to content

Commit

Permalink
Tests: Add code coverage
Browse files Browse the repository at this point in the history
Use built in MATLAB code coverage tool to generate code coverage report.

There are two warnings when this runs for which fixes are not readily
apparent:

Warning: Coverage result is empty for check_range.m because the file is invalid.

Warning: Coverage result is empty for blade_moments.m because the file is invalid.

These two warnings indicate that code coverage is not being generated
for those files.
  • Loading branch information
simmsa committed Nov 30, 2023
1 parent b0d93bb commit 1f5f93a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mhkit/tests/runTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import matlab.unittest.TestRunner;
import matlab.unittest.TestSuite;
import matlab.unittest.plugins.TestReportPlugin;
import matlab.unittest.plugins.CodeCoveragePlugin;
import matlab.unittest.plugins.codecoverage.CoverageReport;


% Define test suite
testFileName = mfilename('fullpath');
Expand All @@ -22,6 +25,14 @@
plugin = TestReportPlugin.producingPDF(pdfFile);
runner.addPlugin(plugin);

% Add Code Coverage Report
sourceCodeFolder = fileparts(testsFolder);
codeCoverageFolder = fullfile(testsFolder, 'coverage_report');
reportFormat = CoverageReport(codeCoverageFolder);

p = CodeCoveragePlugin.forFolder(sourceCodeFolder, Producing=reportFormat, IncludingSubfolders=true);
runner.addPlugin(p);

% Run the tests
results = runner.run(suite);

Expand Down

0 comments on commit 1f5f93a

Please sign in to comment.