Unit Testing
Until now, we’ve been focusing on creating the app, but there is danger in going too far without introducing unit testing. In this chapter, we will focus on writing comprehensive and meaningful unit tests using best practices.
Test-driven development (TDD)
Some developers believe that unit tests should come before the code (TDD), but that is beyond the scope of this book.
Unit testing is crucial to creating robust applications and knowing that your app works before you ship it. It is also a critical aspect of debugging, telling you right away if something you just changed or added broke some aspect of your app.
To facilitate unit tests, you’ll want to use dependency injection so that you can mock up time-consuming services, such as APIs, databases, and so on. We’ll spend time with mocks, injected into our test classes, to ensure that we are processing data as intended.
The specific topics in this chapter are as follows:
- Why create...