When I am running the .vendor/bin/phpunit it is not giving any error. o/p:

Testing . 1 / 1 (100%)

Time: 00:00.014, Memory: 14.00 MB

OK (1 test, 1 assertion)

When I am running the same on acquia-pipeline's build it is giving the below error.

Executing step test.

  • ./vendor/bin/phpunit docroot/modules/custom

PHPUnit 9.5.9 by Sebastian Bergmann and contributors.

No tests executed!

Remaining direct deprecation notices (4)

1x: The "Drupal\Component\EventDispatcher\Event" class extends "Symfony\Component\EventDispatcher\Event" that is deprecated since Symfony 4.3, use "Symfony\Contracts\EventDispatcher\Event" instead.

1x in DeprecationErrorHandler::shutdown from Symfony\Bridge\PhpUnit

1x: The "PHPUnit\TextUI\DefaultResultPrinter" class is considered internal This class is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not use it from "Drupal\Tests\Listeners\HtmlOutputPrinter". 1x in DeprecationErrorHandler::shutdown from Symfony\Bridge\PhpUnit

1x: The "Drupal\Tests\Listeners\DrupalListener" class implements "PHPUnit\Framework\TestListener" that is deprecated Use the TestHook interfaces instead. 1x in DeprecationErrorHandler::shutdown from Symfony\Bridge\PhpUnit

1x: The "Drupal\Tests\Listeners\DrupalListener" class uses "PHPUnit\Framework\TestListenerDefaultImplementation" that is deprecated The TestListener interface is deprecated. 1x in DeprecationErrorHandler::shutdown from Symfony\Bridge\PhpUnit

Can you help me to figure out the problem?


1 Answer 1


From the creator of PHPUnit:

By default, PHPUnit's command-line test runner exits with shell exit code 0 when the use of a deprecated feature is reported. This shell exit code is used to indicate that no error occurred. This information is used by continuous integration environments, for instance, to decide whether or not the build was successful. If you want your build to fail because the tests use deprecated functionality from PHPUnit, configure failOnWarning="true" in phpunit.xml. This instructs PHPUnit to exit with shell exit code 1 when deprecated assertions are used.

So in your phpunit.xml file, change the failOnWarning flag to false:

<phpunit bootstrap="tests/bootstrap.php" colors="true"

You need to provide a custom phpunit.xml file that only tests your custom module or theme and set the appropriate flags. Then tell PHPUnit to use that file instead of the one shipped with Drupal core.

In mine, I have also added:

    <!-- To disable deprecation testing completely uncomment the next line. -->
    <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>

I never have tests fail because of deprecation notices.

Configure PHPUnit


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.