wasAsked.

Describe a practical strategy for unit, integration, contract, and end-to-end testing in a .NET full-stack product.

BrowserStack · Full Stack Developer · 3-4-years · technical

Published

Year not specified · .NET, React, Testing

Community answers

Posted by wasAsked editorial collection

Use a test pyramid driven by risk. Unit-test pure domain rules, integration-test database mappings and external adapters, and keep a smaller set of end-to-end tests for critical user journeys. Example: [Fact] public void Rejects_negative_quantity() => Assert.Throws<ArgumentOutOfRangeException>(() => new Line(-1, 10m)); For API integration tests, use WebApplicationFactory, a real disposable database matching production, and authenticated test identities. Test success, validation, authorization, tenant isolation, concurrency, cancellation, and dependency failures. Make tests deterministic: control time and IDs, avoid shared mutable fixtures, and assert observable behavior rather than implementation details.

Backbencher Developer · · 0 likes

Sign in to add your answer

Related interview topics