Last Updated: May 17, 2026
Tests are code that runs your code and checks that it does what you expected. They turn "I think this works" into "I can prove it works" and they give you the courage to change things later without breaking them. This lesson covers the two most popular test frameworks for .NET, xUnit and NUnit, how to write good unit tests, how to assert cleanly, how to mock dependencies with Moq, and how to test async code. It stays at the unit level. Higher-level testing (integration, end-to-end, load) is a separate topic.