← .NET Core learning path.NET Core · Module 9 of 10
Testing .NET applications
Write unit and integration tests.
📖 Key ideas
- Test frameworks: xUnit, NUnit, MSTest.
- Mock dependencies with Moq or NSubstitute.
- WebApplicationFactory runs integration tests in memory.
- Use Testcontainers for real databases in tests.
- Run dotnet test in CI pipelines.
💡 Real-life example: Tests are smoke detectors: quiet most of the time, loud the moment something breaks.
xUnitPopular .NET test framework
MoqMocking library
WebApplicationFactoryIn-memory test server
[Fact]xUnit test method attribute