9

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 ...

Get .NET MAUI for C# Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.