Why does in Drupal 8 there are two different namespaces for test cases? In Drupal 8 core modules tests are under two different namespaces which maps to two different directories under the module.

\Drupal\Tests\&lt;mymodule&gt;\&lt;TestSuiteType&gt; =&gt; &lt;mymodule&gt;/tests/src/&lt;TestSuiteType&gt;
\Drupal\&lt;mymodule&gt;\Tests =&gt; &lt;mymodule&gt;/src/Tests direcotry.


For example in field_ui module.

\Drupal\field_ui\Tests\FieldUIDeleteTest =&gt; field_ui/src/Tests/FieldUIDeleteTest.php
\Drupal\Tests\field_ui\Functional\EntityDisplayModeTest =&gt; field_ui/tests/src/Functional/EntityDisplayModeTest.php


Can someone please explain the reason behind this and any advantage of writing test cases under two different namespace for the same module?
They're just different kinds of tests, with different requirements/dependencies, and so they're split up.

From PHPUnit file structure, namespace, and required metadata:


  File structure and namespace
  
  There's a special relationship between the location of test files within the file structure, the namespace they use, and the class which they extend.
  
  Drupal Unit Test Suites: Auto-detected Tests
  
  Drupal 8 uses a number of test suites to allow for choosing between different kinds of tests to run.
  
  Drupal 8 has the following test suites:
  
  
  Simpletest: Legacy tests based on the Drupal version of the Simpletest framework.
  Unit: PHPUnit-based tests with minimal dependencies.
  Kernel: PHPUnit-based tests with a bootstrapped kernel, and a minimal number of extensions enabled.
  Functional: PHPUnit-based tests with a booted Drupal instance.
  FunctionalJavascript: PHPUnit-based tests which use PhantomJS to perform tests of Javascript functionality.
  
  
  Drupal's test system can discover these different test suites for core, core extensions, and contrib extensions, as long as the tests are placed within the proper directories so they can be discovered as belonging to one of the test suites listed above.
  
  Simpletest-based tests must be placed in an extension, within that extension's src/Tests directory. They will have a namespace of \Drupal\$extension\Tests.
  
  PHPUnit-based: Generally, the other suites must be within a tests/src/$suite_type/ directory. These tests will have a namespace of \Drupal\Tests\$extension\$suite_type.
  
  Traits: The third class is traits. It is possible to write a trait which will be discovered and can be used by the various different test types. Each test suite will discover the trait if it is placed in the tests/src/Traits directory, and the trait will have a namespace of \Drupal\Tests\$extension\Traits.
  
  Note that the class names must END with the word Test. The test methods within the class must START with the word test.


Simpletest Class, File, and Namespace structure also provides a bit more insight.