8 Writing tests for microservices

This chapter covers

  • Writing good automated tests
  • Understanding the test pyramid and how it applies to microservices
  • Testing microservices from the outside
  • Writing fast, in-process tests for endpoints
  • Using Microsoft.AspNetCore.TestHost for integration and unit tests

Up to this point, we’ve written a few microservices and set up collaborations between some of them. The implementations are fine, but we haven’t written any tests for them. As we write more and more microservices, developing systems without good automated tests becomes unmanageable. In the first half of this chapter, I’ll discuss what you need to test for each individual microservice. Then we’ll dive into code, looking first at testing endpoints ...

Get Microservices in .NET, Second Edition 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.