Resource · Guide or article
Unit Testing
Sets a strict definition of a unit test (reliable, fast, isolated) and covers the techniques and habits that keep tests that way. Engineers at any level who get asked how they test their code can use it to give precise answers instead of general ones.
Reviewed
Open the original: Unit Testing (opens the original site in a new tab)Add to a roadmap
Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.
Source content: English
Unit testing is a fundamental tool in every developer's toolbox. Unit tests not only help us test our code, they encourage good design practices, reduce the chances of bugs reaching production, and can even serve as examples or documentation on how code functions. Properly written unit tests can also improve developer efficiency.
PrepKit overview
PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.
- Suited to
- The source does not state a level
- Format
- Guide
What it covers
- The three properties of a unit test and the reasons given for writing them, such as earlier bug detection and tests as documentation
- Abstraction and thin facades over third-party code, plus dependency injection and the risk of overusing it
- Arrange/Act/Assert with a C# xUnit example and the UnitName_StateUnderTest_ExpectedResult naming convention
- Pitfalls to avoid: sleeps, reading expected values from disk and calling third-party APIs from unit tests
- When to shift coverage to fast integration tests that treat an API as a black box
How to use it
PrepKit study advice, not a claim made by the source.
Open a project you have worked on and pick three tests. Check each against the reliable, fast and isolated criteria and rename one to the UnitName_StateUnderTest_ExpectedResult pattern. Afterwards you should be able to describe, with a real example, one test you changed and why.
Scope and limitations
Engineering team guidance, not written for interviews. Examples and tooling lean toward C# and Visual Studio, and the TDD, abstraction and DI examples live on linked pages rather than this one.
Access and format
English page on microsoft.github.io, free to read; text from Microsoft's CC BY 4.0 Code-With Engineering Playbook repository.
Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 016770e43d8a
Evidence behind this overview
- docs/automated-testing/unit-testing/README.md
Pages that include this
Get the PrepKit newsletter
Optional. You don't need it to use PrepKit.