The main task of unit testing is to verify whether the software unit specified in the detailed specification has been correctly implemented by developers in the form of code. Here, software units refer to a function in process-oriented programming, and to member methods of classes or classes in object-oriented programming. In this test, 100% of each function branch is covered, and 100% of each function is covered.
Unit Tests are generally white-box tests, which are generally divided into manual unit tests and automated unit tests. The basic principle of manual unit testing is to build the pile module and the test Chi module to drive the execution of the tested unit, and then the side testers enter the designed test cases, test whether the Unit to be tested can process the test cases as required. For test cases with exceptions, the tester should record them and report them to the developer. The purpose of Automated unit testing is to make up for the shortcomings of manual unit testing, so that some or all of the unit testing work is automatically completed by the computer, thus comprehensively improving the efficiency of unit testing.
To automate unit testing, Software Reuse Technology of the software framework is generally used. The Framework is an architecture designed to maximize reuse. An important mechanism of the framework is that user-defined methods are generally called by the framework, rather than the user's method call framework, this mechanism is called "reverse control ". When an external event occurs, the Framework scheduler notifies the event processing object, calls the user code, and responds to the event. The essence of Reverse control is to allow the framework, rather than deciding which method is activated by the application to respond to external events. The design pattern is the key to successful development of the framework. Mature frameworks usually use multiple design modes to provide good flexibility and scalability.
Similar to JUnit in Java and cppunit in C ++, developers can construct their own unit test framework based on their own needs.