Search⌘ K
AI Features

Adding Automated Tests to a Serverless Application

Discover how to implement automated integration tests for serverless AWS Lambda applications using C# and ASP.NET Core. Learn the distinctions between unit and integration tests, prepare your application for testing, and use Microsoft.AspNetCore.Mvc.Testing to create a local test host that verifies API endpoint functionality.

Unit vs. integration tests

If we use a hosted ASP.NET Core web application as a serverless AWS Lambda application, we can run the same types of automated tests as we can for any standard ASP.NET Core application. Any business logic can be tested via standard unit tests. However, we can also test the endpoints using an integration test host provided by ASP.NET Core.

Here are the key differences between unit tests and integration tests.

  • Unit tests are designed to test a unit of functionality. They don’t rely on the application being hosted, and they call methods directly.

  • Integration tests rely on the application being hosted, even if it’s a local test host. They trigger the application via its endpoints, not by calling the methods directly.

Note: Even though the application needs to be hosted for integration tests, it doesn’t have to be fully deployed. In the context of integration tests, ...