How to do System Tests / Functional Tests with an existing database the last few weeks and days I have been reading into Drupal 8 testing with phpunit. 

For a project I want to use Unit testing to test out functionality and services and the cooperation between different components.

Run the tests against an existing database / installation and not against a fresh Drupal installation, since we have configured a lot already and I need to make sure the new code does work with the whole configuration and data.

I can Unit tests to test out simple functions or classes but what I cannot use is the BrowserTests or KernelTest bases since they all create a new, fresh installation.

Maybe I have misunderstood something or I am on the wrong path.

Can anybody help me out or has an example on how to do that?
I have once answered this exact same question for Drupal 7. Though some things have changed, the concept remains the same; extend the test class.

The normal setup of a BrowserTest would look something like this:

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

    // Create an article content type that we will use for testing.
    $type = $this-&gt;container-&gt;get('entity_type.manager')-&gt;getStorage('node_type')
      -&gt;create([
        'type' =&gt; 'article',
        'name' =&gt; 'Article',
      ]);
    $type-&gt;save();
    $this-&gt;container-&gt;get('router.builder')-&gt;rebuild();
  }


All you need to is to remove the database definitions from parent::setUp();

So copy setUp() from core/tests/Drupal/Tests/BrowserTestBase.php and remove the database definitions. That should make the test run on the current database. 

Though this is very simplistic and you might run into more problems along the way. All is in the BrowserTestBase class. Make sure to read my other answer, make sure to implement the teardown properly. And most of all, make proper backups!