📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

1325 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Phase 19 — Testing

Testing .NET 10 systems with confidence: the test types and when each pays off, the .NET testing tools (xUnit, NSubstitute, Testcontainers, WebApplicationFactory), good testing practice, and senior topics such as legacy code, async and time, flaky tests and contract testing.

  1. Should integration tests use the EF Core in-memory provider instead of a real database? Why or why not?
    Beginner Theory Test Types
  2. How do you test that an ASP.NET Core endpoint behaves correctly when a third-party API it calls is slow or returns errors?
    Intermediate Theory Test Types
  3. What is boundary-value analysis, and how does it help you write tests that kill mutants?
    Mid-Level Theory Test Types
  4. What is the difference between unit, integration and end-to-end tests? Explain what each one proves, how fast and costly each is, and where you draw the lines in an ASP.NET Core API.

    Unit, integration and end-to-end tests: what each proves, their speed, cost and failure signal, and where the boundaries sit in a .NET 10 ASP.NET Core API.

    Beginner Theory Test Types Β· πŸ”— 3 follow-ups
  5. What are smoke, regression and functional tests? Explain what each one checks, how they relate to unit and integration tests, and where each fits in a release pipeline for a .NET service.

    Smoke, regression and functional tests: what each checks, how they overlap with unit, integration and E2E tests, and where they run in a CI/CD release pipeline.

    Junior Theory Test Types Β· πŸ”— 2 follow-ups
  6. How do you write integration tests for an ASP.NET Core API? What do you run for real (database, HTTP pipeline, authentication) and what do you fake, and how do you keep the tests fast, isolated and reliable?

    Integration tests for ASP.NET Core 10 APIs: WebApplicationFactory, real SQL Server with Testcontainers, faking third-party HTTP and authentication, and keeping state isolated and the suite fast.

    Intermediate Theory Test Types Β· πŸ”— 2 follow-ups
  7. What is the difference between load, stress, soak and spike tests? What question does each one answer for a .NET API, which tools would you use (k6, Azure Load Testing, NBomber), and what would you look at in the results to decide whether the service is ready?

    Load, stress, soak and spike tests as distinct test types: the question each answers, workload shapes, tool choice (k6, Azure Load Testing, NBomber and its licence), pass/fail criteria and what to read in the results for a .NET 10 API.

    Mid-Level Theory Test Types Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  8. What is mutation testing, and why can a test suite with 90% code coverage still be weak? Explain how Stryker.NET works, what a mutation score means, how you read surviving mutants, and what it costs to run.

    Mutation testing with Stryker.NET: why line coverage overstates test quality, how mutants are generated and killed, mutation score and thresholds, surviving mutants, incremental runs and run-time cost.

    Mid-Level Theory Test Types Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  9. You are the senior engineer on a new .NET 10 service: an orders API on Azure that publishes events to Service Bus and calls a payment provider. Design its test strategy. Which test types do you use and roughly how many, where does each run, what blocks a merge or a release, and how will you know the strategy is working?

    Designing a test strategy for a new .NET 10 service: choosing test types by risk, the shape and size of each layer, where each runs in CI/CD, merge and release gates, ownership, and the metrics that show whether the strategy works.

    Senior Architecture Test Types Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  10. Tell me about a time a bug reached production even though the code had high test coverage, say 90%. What kind of bug was it, why didn't the tests catch it, and what did you change in your test strategy afterwards?

    A real-world escaped defect despite high coverage: diagnosing why the suite missed it (mocked boundaries, missing contract and integration tests, weak assertions), the incident response, and the test strategy changes that followed.

    Senior RealWorldScenario Test Types Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  11. How do you share an expensive resource, such as a database container, across many xUnit test classes without starting it once per test?

    Sharing an expensive test resource (such as a SQL Server container) across xUnit test classes with IAsyncLifetime, class, collection and xUnit v3 assembly fixtures, and keeping tests independent with Respawn or unique keys.

    Junior Theory .NET Testing Tools Β· πŸ”— 1 follow-ups
  12. What are the different kinds of test doubles (dummy, stub, fake, mock, spy), and when would you write a hand-rolled fake instead of using a mocking library?

    The five kinds of test double (dummy, stub, fake, mock, spy), how they differ in state versus interaction verification, and when a hand-rolled fake beats a mocking library in .NET 10 tests.

    Junior Coding .NET Testing Tools Β· πŸ”— 1 follow-ups
  13. When would you use snapshot testing with Verify instead of writing explicit assertions?

    When snapshot testing with Verify beats explicit assertions, how .verified and .received files, scrubbing and accepting changes work, and how to keep snapshots reviewable and maintainable.

    Intermediate Theory .NET Testing Tools
  14. How do you stop a package update from silently changing the licence of a dependency in your solution?

    Preventing a NuGet update from silently bringing in a new licence: Central Package Management, pinned majors and lock files, Dependabot ignore rules, CI licence allow-lists (dependency-review-action, nuget-license), and treating test packages like production dependencies.

    Intermediate Theory .NET Testing Tools
  15. How do you combine WebApplicationFactory with Testcontainers so each test class gets a real SQL Server database?

    Wiring a Testcontainers SQL Server into WebApplicationFactory: container lifecycle with IAsyncLifetime, overriding the connection string, migrating once, resetting with Respawn, and sharing one container across classes with a database per class.

    Mid-Level Coding .NET Testing Tools Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  16. How do you configure and test retries, timeouts and circuit breakers for an HttpClient in .NET 10?

    Configuring HttpClient resilience in .NET 10 with Microsoft.Extensions.Http.Resilience (the standard handler's strategies and defaults, attempt versus total timeout, no blind retries on unsafe methods, custom Polly pipelines) and testing it deterministically with WireMock.Net.

    Mid-Level Coding .NET Testing Tools Β· πŸ”— 1 follow-ups Β· πŸ›  1 real-world
  17. How do you manage test data across unit, integration and end-to-end tests without using production data?

    Managing test data at each level of the test pyramid without production data: builders and object mothers for unit tests, unique data and Respawn resets for integration tests, seeded synthetic data (Bogus) for end-to-end environments, edge cases, versioned seed scripts, and Australian privacy obligations.

    Intermediate Theory .NET Testing Tools Β· πŸ”— 1 follow-ups
  18. Flaky tests are blocking releases. How do you find the cause, decide whether to quarantine, and stop new flaky tests from appearing?

    A team-level approach to flaky tests in .NET: measuring flakiness from CI test reports, reproducing failures (loops, parallelism, limited CPU, blame options), the common root causes, a visible quarantine with an owner and deadline, and prevention with TimeProvider, banned-API analysers, xUnit analysers and a flaky-rate dashboard.

    Senior RealWorldScenario .NET Testing Tools Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  19. xUnit, NUnit and MSTest: how do they differ? Compare the test lifecycle (instances, setup and teardown), shared fixtures, parameterised tests and parallelism, and explain what changed in xUnit v3.

    Compares xUnit, NUnit and MSTest on test-class lifecycle, setup and teardown, shared fixtures, data-driven tests and parallel execution, and covers xUnit v3 and Microsoft.Testing.Platform on .NET 10.

    Junior Theory .NET Testing Tools Β· πŸ”— 2 follow-ups
  20. How do you mock dependencies in .NET unit tests with NSubstitute and Moq? Show how you set up return values, use argument matchers, verify calls and simulate exceptions, and tell me what happened with Moq and SponsorLink in 2023.

    Covers creating substitutes with NSubstitute and Moq, configuring returns, argument matchers, verifying received calls, throwing exceptions, async members, analysers, and the 2023 Moq SponsorLink supply-chain controversy.

    Junior Coding .NET Testing Tools Β· πŸ”— 2 follow-ups

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me