What are the unit test tasks?

Source: Internet
Author: User

Unit test, in the early stage of software testing, the task mainly includes: module interface test, module local data structure test, module of all independent execution path test, module error processing path test, module boundary condition test.

  1. Module interface testing is the basis of unit testing. Other tests make sense only if the data flows correctly into and out of the module. The following factors should be considered when testing the interface correctly:

    (1) The actual parameters of the input are the same as the number of formal parameters, (2) whether the actual parameters of the input match the attributes of the formal parameters, and (3) whether the actual parameters of the input are consistent with the dimensions of the formal parameters; (4) whether the number of actual arguments given to the other modules is the same as the number ; (5) whether the properties of the actual parameters given to the other modules are matched with the parameter attributes of the module, (6) whether the dimensions of the actual parameters given to the other modules are consistent with the shape parameters of the module, and (7) whether the number, attributes and order of the parameters used to invoke the predefined function are correct ; (8) Whether there is a parameter reference unrelated to the current entry point, (9) whether the read-only parameter is modified, (10) whether the module is consistent with the definition of the whole variable, and (11) Whether some constraints are passed as parameters. If the module includes external input and output, the following factors should also be taken into account: (1) whether the file attributes are correct, (2) whether the Open/close statement is correct, (3) whether the format description matches the input and output statements, (4) whether the buffer size matches the record length, and (5) whether the file has been opened before use ; (6) Whether the end of the file is processed, (7) whether the input/output error is handled, and (8) whether there is a textual error in the output information;

  2. The local data structure is checked to ensure that the information stored temporarily in the module is complete and correct during the execution of the program. Local data structures are often the source of errors and should be carefully designed to identify the following types of errors: (1) inappropriate or incompatible type descriptions, (2) variable no initial value, (3) Incorrect variable initialization or default values, (4) Improper variable name (misspelled or improperly truncated), (5) overflow, Underflow and address exceptions.

  3. In addition to the local data structure, if possible, the unit test should also find out the impact of the global database on the module. Each independent execution path should be tested in the module, and the basic task of unit testing is to ensure that each statement in the module is executed at least once. The test case is designed to discover errors caused by incorrect calculations, incorrect comparisons, and inappropriate control flows. Basic path testing and cyclic testing are the most commonly used and most effective test techniques at this point. Common errors in the calculation include: (1) misunderstanding or using the wrong operator priority; (2) Mixed type operation;

(3) The variable initial value is wrong, (4) The precision is not enough; (5) The expression symbol is wrong. Comparative judgment is often closely related to control flow, and the test case should also focus on finding the following errors: (1) Comparing objects of different data types, (2) using logical operators or precedence incorrectly, (3) expecting theoretically equal and actually unequal two quantities due to limitations of computer representation; (4) Error in comparison operation or variable, (5) cyclic termination condition or impossibility of occurrence, (6) cannot exit when iteration is Divergent, (7) incorrectly modified loop variable.

    1. A good design should be able to anticipate all kinds of error conditions, and preset a variety of error handling pathways, error handling pathways also need to be carefully tested, the test should focus on the following issues: (1) The error information of the output is difficult to understand, (2) The errors recorded are not in accordance with the actual errors encountered; (3) before the program custom , the system has been involved, (4) Improper handling of the exception, (5) failure to provide adequate positioning error information in the error statement.

    2. Boundary condition testing is the last and most important task in unit testing. As is known to all, software often fails on the boundary, using boundary value analysis technology, for the boundary value and its left and right design test cases, it is likely to find new errors.

What are the unit test tasks?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.