필터 지우기
필터 지우기

Exclude files for CodeCoveragePlugin

조회 수: 3 (최근 30일)
Ricardo Krause
Ricardo Krause 2020년 6월 24일
답변: Will 2020년 8월 20일
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

답변 (1개)

Will
Will 2020년 8월 20일
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.

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by