Score:-1

PHPUNIT is running successfully on local but giving error on acquia-pipleine

ye flag

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?

Score:1
in flag

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"
         beStrictAboutTestsThatDoNotTestAnything="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutChangesToGlobalState="true"
         failOnWarning="false"
         printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter"
         cacheResult="false">

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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.