How to connect database in UnitTestCase subclass?
See https://www.drupal.org/phpunit for better documentation.

There are 4 test base classes:


UnitTestBase, pure unit tests where everything but your code has to be mocked and only supports classes
KernelTestBase, which provide a basic in-memory drupal environment. Much faster than browser tests but more tedious to set up, you have to explicitly install tables you need and depend on all modules you need explicitly
BrowserTestBase, the replacement for WebTestBase, better apis (uses mink and so on) but just as slow.
JavaScriptTestBase, phantomjs based JS tests, even slower but can actually execute JS.