Running Tests in Drupal 8

The dust is still settling in core, but I wanted to get PHPUnit running on my D8 custom modules. I'm not going to go into how to write tests here, just how to run tests.

My problem was that PHPUnit was running core tests just fine, but it wasn't picking up my custom module tests. Initially I had my tests in: modules/mymodule/lib/Drupal/mymodule/Tests

I looked around core a bit and moved them to a new directory: modules/mymodule/tests/Drupal/mymodule/Tests

This worked, although I suspect the original directory I was trying to use will be the proper location once things settle. (Correct me if I'm wrong)

To run PHPUnit, open up a terminal and run it like this from the Drupal root:

$ cd core
$ ./vendor/bin/phpunit

Make sure you have the latest for this to work. You can follow the issue of PHPUnit picking up tests outside of core here: https://drupal.org/node/2025883 . (Thanks to Berdir for pointing that one out!)