5 Integration Testing and Monitoring

 

This chapter covers

  • The fundamentals of application telemetry and how .NET Aspire processes logs, metrics, and traces.
  • How health checks are managed by .NET Aspire.
  • The fundamentals of setting up and running integration tests in .NET Aspire.
  • Using different testing frameworks for integration tests.
  • Testing the user interfaces of applications hosted by Aspire.

In this chapter, we will talk about making our application resilient by testing it before it’s deployed to production and monitoring it when it’s running in production. We will start with the monitoring, as the relevant dependencies are already included in the standard .NET Aspire starter project template.

Monitoring applications is crucial for several reasons. For example, Monitoring allows us to detect issues such as errors, failures, performance bottlenecks, or security breaches early on. Early detection enables proactive responses, minimizing the impact on users and the business.

Monitoring also helps ensure that our applications are reliable and available. By tracking uptime, response times, and error rates, we can identify areas for improvement and implement measures to enhance reliability and availability.

5.1 Components of monitoring systems

5.1.1 Logging

5.1.2 Metrics

5.1.3 Traces

5.2 Monitoring .NET Aspire applications

5.3 Configuring the telemetry

5.4 Viewing information on the dashboard

5.5 Health checks in .NET Aspire

5.5.1 Service statuses on .NET Aspire dashboard

5.5.2 Enabling health checks inside .NET Aspire apps

5.5.3 Mapping health check endpoints

5.5.4 Monitoring app health in production

5.5.5 Viewing health check information

5.6 Setting up integration tests in Aspire

5.6.1 Adding a test project

5.6.2 Installing required dependencies for testing

5.6.3 Examining an Aspire test method

5.6.4 Using different testing frameworks

5.7 Expanding test functionality

5.8 What about component testing?

5.9 Summary