Lot of times we hear that Drupal is not a good choice for writing complex web applications. One of the chief reasons is that Drupal doesn't support TTD or automated testing. But in Drupal 8 we have the PHPUnit tests and Simpletest tests in the core.
Drupal 8 is developed keeping in mind the use of automated tests, including unit tests as well as functional tests. Unit test is at the lower level and used primarily to test the functionality of classes, whereas functional test is done at the higher level to check the web output.
Important is run both types of tests for most of the features we develop before making any changes to the existing Drupal system to make sure no existing functionality is breaking up. We also call this regression testing.
To follow TDD, we need to follow these two processes:
Whenever you make a patch to fix a bug or to change an existing functionality, make sure to write a test that fails before changes have been in the code and that it passes...