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.
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.
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.
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.
Uses Testcontainers with xUnit and a custom WebApplicationFactory to run integration tests against a real database in a throwaway Docker container.