📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials PHPUnit Testing PHPUnit Configuration

PHPUnit Configuration

4 min read
Configure phpunit.xml with test suites, bootstrap path, coverage settings, and environment variables.

phpunit.xml Configuration

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         colors="true"
         stopOnFailure="false">

  <testsuites>
    <testsuite name="Unit">
      <directory>tests/Unit</directory>
    </testsuite>
    <testsuite name="Feature">
      <directory>tests/Feature</directory>
    </testsuite>
  </testsuites>

  <coverage>
    <include>
      <directory>src</directory>
    </include>
  </coverage>

  <php>
    <env name="APP_ENV" value="testing"/>
    <env name="DB_DATABASE" value=":memory:"/>
  </php>
</phpunit>