Summary
In this chapter, you learned to create unit tests to test simple functionality. These tests can be used with Live Unit Testing where test errors immediately show up during development. With unit tests, you learned to use a mocking library to replace functionality that is not in the scope of the unit test and is covered by a different unit test.
You learned how .NET Aspire makes integration tests simple using Aspire.Hosting.Testing
. There’s no need to start the service, as the handler of HttpClient
is replaced to send requests to the service in-process.
Using Microsoft Playwright, you created an integration test that makes HTTP requests to the API and can be used to test the solution under load.
While you monitored metrics data in this chapter, the next chapter expands on this so that you can create your own metric counts and add logging and distributed tracing to the microservices solution.