Laravel 代码覆盖率

use*_*258 5 php phpunit laravel

我试图让我的代码覆盖率报告涵盖我所有的 Laravel 应用程序代码(控制器和模型)。出于某种原因,它只涵盖了一项测试。下面这个配置有问题吗?

<phpunit colors="true"
         bootstrap="/Users/bob/projects/leonardo2/laravel/cli/tasks/test/phpunit.php"
         backupGlobals="false">

  <testsuites>
    <testsuite name="Test Suite">
                        <directory suffix=".test.php">/Users/bob/projects/leonardo2/application/tests</directory>
                  </testsuite>
  </testsuites>

  <filter>
    <blacklist>       
        <exclude>
          <directory suffix=".test.php">/Users/bob/projects/leonardo2/application/tests</directory>
        </exclude>
    </blacklist>
    <whitelist>
      <exclude>
        <directory suffix=".php">/Users/bob/projects/leonardo2/application/config</directory>       
        <directory suffix=".php">/Users/bob/projects/leonardo2/application/views</directory>
        <directory suffix=".php">/Users/bob/projects/leonardo2/application/migrations</directory>
        <directory suffix=".php">/Users/bob/projects/leonardo2/application/libraries</directory>
        <directory suffix=".php">/Users/bob/projects/leonardo2/application/tasks</directory>
        <directory suffix=".php">/Users/bob/projects/leonardo2/application/language</directory>
      </exclude>
    </whitelist>
  </filter>

   <logging>
      <log type="coverage-html" target="./storage/work/report/" charset="UTF-8"
       highlight="false" lowUpperBound="35" highLowerBound="70"/>
    </logging>
</phpunit>
Run Code Online (Sandbox Code Playgroud)

jis*_*han 3

我想不需要那么多复杂的调节。只需将应用程序目录添加到过滤标签下的白名单中即可。

<filter>
    <whitelist>
        <directory suffix=".php">app/</directory>
    </whitelist>
</filter>
Run Code Online (Sandbox Code Playgroud)

请点击此链接以获得更好的理解。 将代码覆盖率报告添加到 Laravel 项目