How to calculate code coverage for main code by its unit tests?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am writing unit tests using the framework "matlab.unittest.TestCase". I want to calculate code coverage for the source file. By code coverage what I mean is the following: "I want to know that how many lines of the main code were touched when its unit tests were being executed?".
I have tried the following option for it and it shows me output in a html file. However, that output seems like it is showing that how many lines of the unittests were covered.
Whats wrong here? Any suggestions? Please feel free to ask for any clarifications.
test_dir = "unittest/sci";
suite = TestSuite.fromFolder(test_dir);
runner = TestRunner.withTextOutput;
runner.addPlugin(CodeCoveragePlugin.forFolder(test_dir));
result = runner.run(suite);
댓글 수: 0
답변 (1개)
Gargi Patil
2021년 9월 2일
편집: Gargi Patil
2021년 9월 2일
Hi,
In the MATLAB Code Coverage Report, the Breakdown by Source section will list the source file(s) and provide details about number of source code lines executed by the unit tests.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Testing Frameworks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!