One of the key goals of TDD is to write tests that execute quickly. We will be running the tests often when doing TDD— possibly even every few minutes. The TDD habit is to run the tests multiple times when developing code, refactoring, before checkins, and before deployments. If tests run any longer, we will be reluctant to run them often, which defeats the purpose of the tests.
With that in mind, some techniques for keeping tests fast are as follows:
Disable unwanted external services: Some services are not central to the purpose of the application and can be disabled. For instance, perhaps we use a service to collect analytics on how users use our application. Our application might be making a call to this service on every action. Such services can be disabled, enabling tests to run faster.
Mock out external services: Other external services such as servers, databases, caches, and so on might be central to the functioning of the application. External services take time...