Coverage report from unit tests is inaccurate

조회 수: 4 (최근 30일)
Micah Fry
Micah Fry 2021년 6월 16일
댓글: Micah Fry 2022년 3월 18일
Using the matlab.unittest.plugins.CodeCoveragePlugin with class-based unit tests produces coverage reports that are not always accurate. I see them repeatedly (but not always) occur when function handles are split across multiple lines. The following image provides an example (code to reproduce it is attached).
The "missed line" goes away if you replace isequal(x) with x == x in line 4. Also, if you just remove the ellipsis and have the function handle defined entirely on one line, the report does not display a "missed line."

답변 (1개)

Neeraj Badamikar
Neeraj Badamikar 2021년 6월 17일
Hello Micah,
Thank you for reporting this. We've had a few other users reporting about this issue and we are working on addressing it.
One possible solution we're looking at is to report code coverage on entire MATLAB statements as opposed to lines. That would ensure that a statement like this -
function_handle_with_wrapping_line_for_isequal = @(x) ~isequal(x, x) || ...
isequal(x, x);
would either be marked as covered or not covered in entirety.
Is that something that you would find useful?
Regards,
Neeraj
  댓글 수: 4
Micah Fry
Micah Fry 2021년 6월 17일
Is there a bug tag I can keep track of for this issue? It looks like this may be related to another question (https://www.mathworks.com/matlabcentral/answers/575389-some-lines-missed-in-code-coverage-report).
Micah Fry
Micah Fry 2022년 3월 18일
I see with R2022a this issue is fixed! Thanks @Neeraj Badamikar!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Write Unit Tests에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by