Why does my kernel test error with "Install profile will be a mandatory parameter in Drupal 9.0."? I've test classes based on KernelTestBase.

Previously everything was working smoothly, now I came back to the project and I'm hit by this error:


  Install profile will be a mandatory parameter in Drupal 9.0.


Drupal version: 8.3.5
PHPUnit version: 4.8.35

phpunit.xml:

&lt;phpunit bootstrap="web/core/tests/bootstrap.php" colors="true"
         beStrictAboutTestsThatDoNotTestAnything="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutChangesToGlobalState="true"
         checkForUnintentionallyCoveredCode="false"&gt;
&lt;!-- TODO set printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" once
 https://youtrack.jetbrains.com/issue/WI-24808 is resolved. Drupal provides a
 result printer that links to the html output results for functional tests.
 Unfortunately, this breaks the output of PHPStorm's PHPUnit runner. However, if
 using the command line you can add
 - -printer="\Drupal\Tests\Listeners\HtmlOutputPrinter" to use it (note there
 should be no spaces between the hyphens).
--&gt;
  &lt;php&gt;
    &lt;!-- Set error reporting to E_ALL. --&gt;
    &lt;ini name="error_reporting" value="32767"/&gt;
    &lt;!-- Do not limit the amount of memory tests take to run. --&gt;
    &lt;ini name="memory_limit" value="-1"/&gt;
    &lt;!-- Example SIMPLETEST_BASE_URL value: http://localhost --&gt;
    &lt;env name="SIMPLETEST_BASE_URL" value=""/&gt;
    &lt;!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix --&gt;
    &lt;env name="SIMPLETEST_DB" value="mysql://vagrant:vagrant@localhost/vagrant"/&gt;
    &lt;!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output --&gt;
    &lt;env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/&gt;
  &lt;/php&gt;
  &lt;testsuites&gt;
    &lt;testsuite name="mymod"&gt;
      &lt;file&gt;web/modules/custom/mymod/tests/src/Kernel/FooTest.php&lt;/file&gt;
    &lt;/testsuite&gt;
    &lt;!-- etc --&gt;
  &lt;/testsuites&gt;
  &lt;listeners&gt;
    &lt;listener class="\Drupal\Tests\Listeners\DrupalStandardsListener"&gt;
    &lt;/listener&gt;
  &lt;/listeners&gt;
  &lt;!-- Filter for coverage reports. --&gt;
  &lt;filter&gt;
    &lt;whitelist&gt;
      &lt;directory&gt;./web/core/includes&lt;/directory&gt;
      &lt;directory&gt;./web/core/lib&lt;/directory&gt;
      &lt;directory&gt;./web/core/modules&lt;/directory&gt;
      &lt;directory&gt;./web/core/modules&lt;/directory&gt;
      &lt;directory&gt;./web/core/sites&lt;/directory&gt;
      &lt;!-- By definition test classes have no tests. --&gt;
      &lt;exclude&gt;
        &lt;directory suffix="Test.php"&gt;./&lt;/directory&gt;
        &lt;directory suffix="TestBase.php"&gt;./&lt;/directory&gt;
      &lt;/exclude&gt;
     &lt;/whitelist&gt;
  &lt;/filter&gt;
&lt;/phpunit&gt;


Test class:

class FooTest extends KernelTestBase {

  protected static $modules = ['foo'];

  public function testFoo() {
    self::assertEquals(2, 2);
  }

}


I'm launching it from PHPStorm via:


  vagrant:///Users/drupality/Develop/drupal/myproj/usr/bin/php
  /home/vagrant/.phpstorm_helpers/phpunit.php --group foo
  --configuration /var/www/myproj/site/phpunit.xml --filter "/::testFoo( .*)?$/" Drupal\Tests\foo\Kernel\FooTest
  /var/www/myproj/site/web/modules/custom/myproj/tests/src/Kernel/FooTest.php


UPDATE

I've updated PHPUnit to 5.7.21 (newest supported by PHPStorm) but still no success.
Your problem is that your test and/or code is relying on a deprecated feature.

In Drupal 8.3, there was a push to have deprecated featured generate E_USER_DEPRECATED messages, eg in Drupal\Core\Config\ExtensionInstallStorage:

  public function __construct(StorageInterface $config_storage, $directory = self::CONFIG_INSTALL_DIRECTORY, $collection = StorageInterface::DEFAULT_COLLECTION, $include_profile = TRUE, $profile = NULL) {
    parent::__construct($directory, $collection);
    $this-&gt;configStorage = $config_storage;
    $this-&gt;includeProfile = $include_profile;
    if (is_null($profile)) {
      @trigger_error('Install profile will be a mandatory parameter in Drupal 9.0.', E_USER_DEPRECATED);
    }
    $this-&gt;installProfile = $profile ?: \Drupal::installProfile();
  }


This is to provide early warning to developers to update their code.

If the code is hit in a phpunit test (which includes unit tests, kernel tests, and functional tests using BrowserTestBase), anything from trigger_error will generate a fail.

So, you either need to fix your code, or you can cause the test to not fail by using the @expectedDeprecation annotation on the test method until you can fix it.