What is a Unit Test?
A unit test is an automated test that verifies a small piece of code (also known as a unit), does it quickly, and does it in isolation.
What does it mean to verify a piece of code—a unit—in an isolated manner? It means that if a class has a dependency on another class, or on several classes, you have to replace all those dependencies with test mocks. In this way, you can focus on the class under test exclusively, separating its behavior from any external influence.
Poor quality usually manifests itself in tight coupling, which means that different pieces of production code are not sufficiently decoupled from each other, and it is difficult to test them separately.
Last updated