How to calculate code coverage for main code by its unit tests?

1 visualización (últimos 30 días)
Akshay Jajoo
Akshay Jajoo el 16 de Ag. de 2021
Editada: Gargi Patil el 2 de Sept. de 2021
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);

Respuestas (1)

Gargi Patil
Gargi Patil el 2 de Sept. de 2021
Editada: Gargi Patil el 2 de Sept. de 2021
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.
You can refer to the example given in the documentation for further information.

Categorías

Más información sobre MATLAB Report Generator en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by