Is there any way to connect to a second (MySQL) database in a Kernel Base test? Right now I have configured this environment variable in my phpunit.xml to connect to a Drupal database in a SQLite file:

&lt;env name="SIMPLETEST_DB" value="sqlite://localhost//Users/jepster/Dev/my-project/project/docroot/sites/default/files/db.sqlite"/&gt;


This works fine. But can I also connect to a second database like I am doing in the settings.php?

$databases['second-database']['default'] = array(
  'database' =&gt; 'second-database',
  'username' =&gt; 'second-database',
  'password' =&gt; 'second-database',
  'prefix' =&gt; '',
  'host' =&gt; 'localhost',
  'port' =&gt; '3306',
  'namespace' =&gt; 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' =&gt; 'mysql',
);


Currently my Kernel Base Test fails with the following error:


  The specified database connection is not defined: second-database


That's because I want to connect to my database from a service constructor:

  public function __construct() {
    $this-&gt;database = Database::getConnection('default','second-database');
  }


I have been digging in the Drupal core Kernel Base Tests ("core" folder), but I could not find a way there.
I have figured it out. The setUp() method in my Kernel Base Test must look like that:

/**
 * {@inheritdoc}
 */
protected function setUp() {
    parent::setUp();

    $databases['second-database']['default'] = array(
        'database' =&gt; 'second-database',
        'username' =&gt; 'second-database',
        'password' =&gt; 'second-database',
        'prefix' =&gt; '',
        'host' =&gt; 'localhost',
        'port' =&gt; '3306',
        'namespace' =&gt; 'Drupal\\Core\\Database\\Driver\\mysql',
        'driver' =&gt; 'mysql',
    );
    Database::setMultipleConnectionInfo(
        $databases
    );
}