Unit Testing & TDD Interview Questions and Answers

Unit testing interview questions for .NET developers — xUnit, NUnit and MSTest, mocking with Moq, the AAA pattern, test doubles, TDD, and integration testing in ASP.NET Core.

Unit Testing & TDD
19Questions
5Topics
Basic to AdvancedDifficulty
Fresher to 5+ YrsExperience
All Unit Testing & TDD Questions (19)

    About these Unit Testing & TDD questions

    Almost every mid-level .NET interview asks about testing, because it reveals how you actually write code. Interviewers want to hear that you know the difference between a unit test and an integration test, when to use a mock versus a stub versus a real object, how to structure a test (Arrange-Act-Assert), and how dependency injection makes code testable in the first place.

    The .NET-specific parts are the frameworks (xUnit is the default for new projects, NUnit and MSTest are common in existing ones), Moq / NSubstitute for test doubles, and WebApplicationFactory for spinning up the app in-memory for integration tests.