Module 11 of 12

Testing ASP.NET Core Apps

Lessons

About This Module

An application that works today can quietly break tomorrow. Automated tests are the safety net that lets you change code, upgrade packages, and refactor with confidence, because a failing test tells you what broke before your users do.

This module starts with unit testing with xUnit, the most popular test framework in the .NET world, and then shows how to use Moq to replace dependencies so you can test controller actions in isolation. It then moves to integration testing: spinning up your app in memory, calling real endpoints, and using Testcontainers to run against a real database in Docker instead of fakes.

Watch the lessons in order, then continue on to Deployment & Performance.

Lessons

4 videos
01

Unit Testing with xUnit & .NET Core

The first video in a series on unit testing C# with the xUnit.net framework. Covers the basic definitions and gets you started writing your first tests.

02

How to Unit Test ASP.NET Core Controllers Using Moq

Shows how to write unit tests for controller action methods, using Moq to mock the services they depend on. This is Part 2 of a mocking and unit testing series.

03

Testing Endpoints with ASP.NET Core Integration Tests

Spins up a Minimal API and hits it with real HTTP calls to verify routing, middleware, and responses, going beyond what isolated unit tests can cover.

04

Integration Testing with Testcontainers in .NET

Uses Testcontainers with xUnit and a custom WebApplicationFactory to run integration tests against a real database in a throwaway Docker container.