8. What is unit testing and unit testing framework

Unit testing is defined as the inspection and verification of the smallest testable unit of software. This is what we often call white box testing .

 

I think the unit testing framework can be understood as a template. Write some use cases according to the template, which mainly has the following functions:

Provide use case organization and execution : When you have only a few test cases, you don't need to consider the use case organization. However, when there are hundreds or thousands of test cases, a large number of test cases are piled together, resulting in scalability and scalability. Maintenance and other issues need to consider the specification and organization of the use case. Unit testing frameworks are designed to solve this problem.

Provides rich assertion methods: whether it is a functional test or a unit test, after the execution of the use case, it is necessary to compare the actual result with the expected result (assertion), so as to determine whether the execution of the use case is passed. Unit testing frameworks generally provide rich assertion methods. For example, judging equality / inequality, inclusion / exclusion True/False  assertion methods, etc.

Provide rich logs: When the test case execution fails, it can throw a clear failure reason, and when all test cases are executed, it can provide rich execution results. For example, total execution time, number of failed use cases, number of successful use cases, etc. From these features, the role of the unit testing framework is: Help us better complete automated testing.
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324456667&siteId=291194637