In computer science, unit testing is a software detection and validation method that is suitable for individual units with programmer testing Source code. A unit is the smallest testable part of an application. A programmable unit on a program may be a separate function or procedure.
The goal of unit testing is to isolate the program into a number of small parts and verify that the individual components are correct. A unit
Interpretation: The ultimate goal: early detection of problems, unit testing in two major steps, 1. Isolate the program into a small part; 2. Verify that each widget is correct.
What is a good unit test?
I excerpt from the Art of code change. Good unit testing should have the quality: run fast, can help us locate the problem.
Unit tests cannot be fast if the unit tests interact with the database, communicate with the network, call the file system, and require you to make specific preparations for the environment, such as writing a configuration file.
Then, I add two points myself: it can be run at low cost and can be easily refactored with the official code.
Testing provides a rigorous, documented, code-block contract that must be met, so unit testing can bring many benefits. Unit tests can identify problems early in development.
Only run fast and low cost to run all unit tests before the programmer commits each commit code to verify that the code it modifies has affected existing functionality.
Unit Test Software Engineering overview