Exclude files for CodeCoveragePlugin

Hi community,
I use the CodeCoveragePlugin to generate a coverage report for m-scripts. This is working well (more, less)
Now I try to exclude some files like interfaces and other abstract classes.
Does somebody know how I can do this?
At the moment my configutration looks like:
runner.addPlugin(CodeCoveragePlugin.forFolder([pwd, '\\src\\main'], ...
'IncludingSubfolders', true, 'Producing', codeCovFormat));
But I don't want to separate my interfaces into a folder and list each single folder.
BR

Respuestas (1)

Will
Will el 20 de Ag. de 2020
I came here hoping to find an answer to this question, but unfortunately there isn't one yet.
The only solution I can come up with right now is to instead use CodeCoveragePlugin.forFile to explicitly list the files that we do want included in the coverage report.
I would use dir to list all m-files in all subfolders of the folder and then take from that the files to exclude...
% get all m-code files under the folder
dirOut = dir(fullfile(folderPath, '**', '*.m'));
codeFilePaths = string({dirOut.folder}) + filesep + string({dirOut.name});
% remove files to exclude
codeFilePaths(ismember(codeFilePaths, filePathsToExclude)) = [];
% add the code coverage plugin
runner.addPlugin(CodeCoveragePlugin.forFile(codeFilePaths), ...
"Producing", codeCoverageFormat)
I'm using MATLAB R2019b, but I can confirm the above will also work in R2017b.
According to the documentation matlab.unittest.plugins.CodeCoveragePlugin.forFile was introduced in R2017b, so this won't work for older releases.

Categorías

Más información sobre MATLAB Report Generator en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Preguntada:

el 24 de Jun. de 2020

Respondida:

el 20 de Ag. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by