title: Symfony 3.4 - Can we collect code coverage for functional testing?
body: <p>I am using symfony 3.4 for some of our projects. According to the docs, we should write functional tests for ours controllers. However, it seems that we cannot collect code coverage for functional test because symfony will run main code in another PHP processs. </p>
  
  <ul>
  <li>In phpunit process: <code>var_dump(xdebug_code_coverage_started()) =&gt; true</code></li>
  <li>In controller code: <code>var_dump(xdebug_code_coverage_started()) =&gt;
  false</code>.</li>
  </ul>
  
  <p>UPDATE: It seems that the problem only occurs when I put tests in separate folder to <code>src</code> folder. It works when I put tests in the same bundle folder (<code>src/MyBubndle/Tests</code>) </p>
  
  <p><strong>PHP Unit config</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.0/phpunit.xsd"
           backupGlobals="false"
           colors="true"
           processIsolation = "false"
           bootstrap="vendor/autoload.php"
  &gt;
      &lt;php&gt;
          &lt;ini name="error_reporting" value="-1" /&gt;
          &lt;server name="KERNEL_DIR" value="app/" /&gt;
          &lt;env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/&gt;
          &lt;!--&lt;env name="KERNEL_CLASS" value="App\Kernel" /&gt;--&gt;
          &lt;env name="APP_ENV" value="test"/&gt;
          &lt;env name="APP_DEBUG" value="1"/&gt;
          &lt;env name="SYMFONY_ENV" value="test"/&gt;
          &lt;env name="MYSQL_SERVER" value="127.0.0.1"/&gt;
          &lt;env name="MYSQL_DATABASE" value="db"/&gt;
          &lt;env name="MYSQL_USER" value="root"/&gt;
          &lt;env name="MYSQL_PASSWORD" value="root"/&gt;
          &lt;env name="MYSQL_PORT" value="3306"/&gt;
          &lt;env name="JWT_PUBLIC_KEY_PATH" value="jwt/public.pem"/&gt;
          &lt;env name="SYMFONY_PHPUNIT_VERSION" value="6.5.5"/&gt;
      &lt;/php&gt;
  
      &lt;testsuites&gt;
          &lt;testsuite name="Project Test Suite"&gt;
              &lt;directory suffix="Test.php" &gt;.&lt;/directory&gt;
              &lt;exclude&gt;vendor&lt;/exclude&gt;
          &lt;/testsuite&gt;
      &lt;/testsuites&gt;
  
      &lt;filter&gt;
          &lt;whitelist&gt;
              &lt;directory suffix=".php"&gt;.&lt;/directory&gt;
              &lt;exclude&gt;
                  &lt;directory&gt;src/*Bundle/Resources&lt;/directory&gt;
                  &lt;directory&gt;src/*/*Bundle/Resources&lt;/directory&gt;
                  &lt;directory&gt;src/*/Bundle/*Bundle/Resources&lt;/directory&gt;
                  &lt;directory&gt;app&lt;/directory&gt;
                  &lt;directory&gt;bin&lt;/directory&gt;
                  &lt;directory&gt;docker&lt;/directory&gt;
                  &lt;directory&gt;jwt&lt;/directory&gt;
                  &lt;directory&gt;var&lt;/directory&gt;
                  &lt;directory&gt;vendor&lt;/directory&gt;
                  &lt;directory&gt;web&lt;/directory&gt;
                  &lt;directory&gt;tests&lt;/directory&gt;
              &lt;/exclude&gt;
          &lt;/whitelist&gt;
      &lt;/filter&gt;
      &lt;logging&gt;
          &lt;log type="coverage-html" target="./var/logs/codeCoverage" charset="UTF-8"
               yui="true" highlight="true"
               lowUpperBound="50" highLowerBound="80"/&gt;
          &lt;log type="coverage-text" target="php://stdout" showOnlySummary = "true" showUncoveredFiles="false"/&gt;
          &lt;log type="testdox-html" target="./var/logs/testdox.html" /&gt;
          &lt;log type="junit" target="./var/logs/testreport.xml" logIncompleteSkipped="false"/&gt;
          &lt;log type="coverage-clover" target="./var/logs/coverage.xml"/&gt;
      &lt;/logging&gt;
      &lt;!--&lt;listeners&gt;--&gt;
          &lt;!--&lt;listener class="Symfony\Bridge\PhpUnit\CoverageListener" /&gt;--&gt;
      &lt;!--&lt;/listeners&gt;--&gt;
  &lt;/phpunit&gt;
  </code></pre>
  
  <p>Also tried:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;!-- https://phpunit.de/manual/current/en/appendixes.configuration.html --&gt;
  &lt;phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.0/phpunit.xsd"
           backupGlobals="false"
           colors="true"
           processIsolation = "false"
           bootstrap="vendor/autoload.php"
  &gt;
      &lt;php&gt;
          &lt;ini name="error_reporting" value="-1" /&gt;
          &lt;server name="KERNEL_DIR" value="app/" /&gt;
          &lt;env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/&gt;
          &lt;!--&lt;env name="KERNEL_CLASS" value="App\Kernel" /&gt;--&gt;
          &lt;env name="APP_ENV" value="test"/&gt;
          &lt;env name="APP_DEBUG" value="1"/&gt;
          &lt;env name="SYMFONY_ENV" value="test"/&gt;
          &lt;env name="MYSQL_SERVER" value="127.0.0.1"/&gt;
          &lt;env name="MYSQL_DATABASE" value="db"/&gt;
          &lt;env name="MYSQL_USER" value="root"/&gt;
          &lt;env name="MYSQL_PASSWORD" value="root"/&gt;
          &lt;env name="MYSQL_PORT" value="3306"/&gt;
          &lt;env name="JWT_PUBLIC_KEY_PATH" value="jwt/public.pem"/&gt;
          &lt;env name="SYMFONY_PHPUNIT_VERSION" value="6.5.5"/&gt;
      &lt;/php&gt;
  
      &lt;testsuites&gt;
          &lt;testsuite name="Project Test Suite"&gt;
              &lt;directory suffix="Test.php" &gt;./tests&lt;/directory&gt;
          &lt;/testsuite&gt;
      &lt;/testsuites&gt;
  
      &lt;filter&gt;
          &lt;whitelist&gt;
              &lt;directory suffix=".php"&gt;./src&lt;/directory&gt;
              &lt;exclude&gt;
                  &lt;directory&gt;src/*Bundle/Resources&lt;/directory&gt;
                  &lt;directory&gt;src/*/*Bundle/Resources&lt;/directory&gt;
                  &lt;directory&gt;src/*/Bundle/*Bundle/Resources&lt;/directory&gt;
                 &lt;/exclude&gt;
          &lt;/whitelist&gt;
      &lt;/filter&gt;
      &lt;logging&gt;
          &lt;log type="coverage-html" target="./var/logs/codeCoverage" charset="UTF-8"
               yui="true" highlight="true"
               lowUpperBound="50" highLowerBound="80"/&gt;
          &lt;log type="coverage-text" target="php://stdout" showOnlySummary = "true" showUncoveredFiles="false"/&gt;
          &lt;log type="testdox-html" target="./var/logs/testdox.html" /&gt;
          &lt;log type="junit" target="./var/logs/testreport.xml" logIncompleteSkipped="false"/&gt;
          &lt;log type="coverage-clover" target="./var/logs/coverage.xml"/&gt;
      &lt;/logging&gt;
      &lt;!--&lt;listeners&gt;--&gt;
          &lt;!--&lt;listener class="Symfony\Bridge\PhpUnit\CoverageListener" /&gt;--&gt;
      &lt;!--&lt;/listeners&gt;--&gt;
  &lt;/phpunit&gt;
  </code></pre>
  
  <p>Is there any workaround for this without using other testing framework?</p>
  
  <p>All helps are highly appreciated!</p>