The code coverage message incorrectly indicates 100% controller coverage

I am running a series of PHPunit tests and have a controller that reports 100% coverage. However, only 5 out of 84 lines of code are green in the reach report.

I am wondering what factors can cause this problem?

One interesting point that can cause it is "indirect calls." This particular controller is the parent of a number of other controllers, and since many other objects inherit it, the code may be called elsewhere ... but then will it not turn green?

As the only method that turns green, is the method __construct.

I don’t know if this is enough to continue, but if someone has a little more knowledge about how Unit Testing determines coverage, I would like to hear it.

Edit in response to Gaurav comment:

Phpunit command line phpunit --configuration admin.xml

and admin.xml reads

 <phpunit bootstrap="./admin/applications/admin/bootstrap.php" colors="true">
     <testsuite name="AdminTestSuite">
        <directory suffix=".php">./admin/applications/admin/</directory>        
        <directory suffix=".php">./admin/applications/shared/</directory>
    </testsuite>
     <filter>
         <whitelist>
            <directory suffix=".php">../admin/applications/admin/controllers</directory>
            <directory suffix=".php">../admin/applications/shared/controllers</directory>           
            <directory suffix=".php">../admin/applications/shared/helpers</directory>
            <directory suffix=".php">../admin/lib/controllers</directory>           
            <directory suffix=".php">../admin/lib/helpers</directory>
            <directory suffix=".php">../admin/lib/models</directory>
            <directory suffix=".php">../admin/lib/utils</directory>         
         </whitelist>
         <blacklist>
                 <file>../dm_admin/applications/shared/controllers/DashboardController.php</file>
            <directory suffix=".php">../admin/lib/crons</directory>
         </blacklist>                
     </filter>
     <logging>
         <log type="coverage-html" target="/projects/ut/admin/" charset="UTF-8"
             yui="true" highlight="true"
             lowUpperBound="50" highLowerBound="80"/>
         <log type="testdox-html" target="/projects/ut/admin/testdox.html" />
     </logging>
 </phpunit>

In response to jakenoble:

assistant reads 100% coverage The report reading 100% coverage on the helper

but inside we see Some text at the top of one of the methods - 1099 lines in all

This continues for 1099 lines, with random green ... but not red.

+3
source share
1 answer

The code coverage report shows three different metrics: classes, methods, and functions, as well as strings.

Classes is a report on the number of tested classes in essence. So, if you have one class for each file and you are testing part of this class, it shows when you test 100% of the classes.

, , 50% - .

0

Source: https://habr.com/ru/post/1787976/


All Articles