Talking about black box test and white box test

Source: Internet
Author: User

1. Visual image of black box test and white box test

Can be seen directly, the black box test when the whole program is a black box, we do not see what has been done in it, only through the input and output to see if we can get what we need to test. And the white box test can be when the box is transparent, everything inside we see clearly, so we can measure the internal structure to test.  

2. Black box Test (Black-box testing)

Black-Box testing, also known as functional testing, data-driven testing, or testing based on specifications, is a test from a user's point of view. The tester generally treats the test procedure as a black box.

The main types of errors detected in the black box test are: Incorrect or missing functions, interfaces, interface errors, performance errors, data structures or external data access errors, initialization or termination condition errors, and so on.

Common black Box test methods are: Equivalence class partitioning method, boundary value analysis method, causality diagram method, scene method, orthogonal experiment design method, judgment table driving analysis method, error inference method, function diagram analysis method.

  · Equivalence class Partitioning method

The equivalence class is divided into valid equivalence class and invalid equivalence class, in which the effective equivalence class is a set of reasonable and meaningful input data for the specification of the program, while the invalid equivalence class refers to the set of input data which is unreasonable and meaningless for the specification of the program.

The principle of determining equivalence classes is: A. In cases where the input condition specifies the range of values or the number of values, a valid equivalence class and two invalid equivalence classes can be determined, such as if the specified input range is 1<x<10 of all numbers, then the valid is any number within the 1~10, and the invalid is-∞~0.9999 and 10.00001~ +∞; B. A valid equivalence class and an invalid equivalence class can be established if the input conditions specify a set of input values or a condition that stipulates "what must be"; c. In the case where the input condition is a Boolean quantity, a valid equivalence class and an invalid equivalence class can be determined; d. In the case of a set of values that specify the input data (assuming n), and if the program is to handle each input value separately, it is possible to establish n valid equivalence class and an invalid equivalence class. A valid equivalence class (conforming to a rule) and several invalid equivalence classes (violating rules from different angles) can be established in the case of rules that require the input data to be complied with. F. In the case of knowing that the elements in the equivalence class are different in the way of program processing, the modified equivalence class should be further divided into smaller equivalence classes.

· Boundary Value Analysis method

According to the rule of thumb, a large number of errors occur on the boundary of the input or output range, rather than within the input and output range. Therefore, for the various boundary conditions involving test cases, you can find more errors. The method of analyzing the boundary value involves the test case, and the boundary condition should be determined first. Usually the bounds of the input and output equivalence classes should be selected exactly equal to, just greater than or just below the boundary of the value as the test data, instead of picking a typical value in the equivalence class or any value as the test data.

The principle of the selection of boundary values: a. If the input condition specifies the range of values, then the value of the boundary that has just reached this range should be taken and the value of the boundary just beyond that range as the test input data. For example, if the specification of the program stipulates that: "Mail in the range of 10 kg to 50 kg, the postage calculation formula is ...". As a test case, we should take 10 and 50, we should take 10.01,49.99,9.99 and 50.01 and so on; B. If the input criteria specify the number of values, then the maximum number, the minimum number, a smaller than the minimum number of one, and the maximum number of first number as the test data. For example, if an input file should include 1~255 records, the test case would be 1 and 255, and 0 and 256 should be taken. C. Apply the preceding two principles to the output condition, that is, the test case involves the output value reaching the boundary value and its left and right values. D. If the program's specification indicates that the input field or output field is an ordered set, then the first and last element of the collection should be selected as the test case. e. If an internal data structure is used in the program, the value on the boundary of the internal data structure should be selected as the test case data; F. Analyze specifications to find other possible boundary conditions.

· Causality Diagram method

Causality diagram is a method of analyzing the various combinations of input using graphic method, which is suitable for checking the various combinations of the input conditions of the program.

The basic steps for generating test cases using causality diagrams are: 1. Analyze the Software specification description which is the reason (input, including prerequisites, operation Process), which is the result (output), and give each cause and result assigned an identifier; 2. Analyze the semantics of software specification descriptions, find out the relationship between cause and result, cause and reason, and draw causal diagram according to these relationships; 3. The constraint or restriction condition is indicated by some marks on the causality diagram; 4. Convert the causality diagram into a judgment table; 5. Each column of the decision table is taken out as the basis for designing the test case.

Basic symbols and constraint symbols for causality diagrams:

    

· Scene method

Scenario law typically consists of basic and alternate streams, starting with a process that describes the process that is determined by the path that passes through, traversing all the basic and alternate streams to complete the scene. Among them, the basic flow is normal, the correct scene; alternative flows generally refer to interrupt operations.

· Orthogonal experimental Design method

Orthogonal design method is the first to know the orthogonal table, orthogonal table is a multi-factor multi-level design method, it is the pattern of orthogonality from a comprehensive test to select some representative point of the test, these representative points with the "uniform dispersion, neat comparable" characteristics, orthogonal test design is a kind of orthogonal table-based, High efficiency, fast and economical test design method. The orthogonal table consists of three components, Runs: The number of rows in the orthogonal table, that is, the number of experiments; factors: The number of columns in the orthogonal table, that is, the number of factors; levels: The maximum number of values that any single factor can obtain. The expression of the orthogonal table is: L runs (number of levels factor) L (levels^factors).

To design a test case with an orthogonal table: 1. What are the factors (variables); 2. Each factor has those levels (the value of the variable): divided by equivalence class; 3. Select an appropriate orthogonal table; 4. Map the value of the variable to the table; 5. The combination of each factor level of each row as a test case; 6. Add a combination that you think can and does not appear in the table.

How do I choose an orthogonal table? The smallest number of rows, the situation is divided into three kinds: 1. The number of factors (variables), the number of levels (variable value) match; 2. The number of factors is different: the number of factors closest to but slightly larger than the actual value of the table; 3. The number of levels is different: there are five factors (variables) A, B, C, D, and E. Two factors have two levels (the value of the variable), two factors have three levels, one factor has six levels. One of the least number of rows (one with the fewest number of rows (L49 (78), L18 (3661)

· Decision table Driven Analysis method

    A decision table is a tool for analyzing and expressing situations that perform different operations under multiple logical conditions. The decision table is composed of the following parts:? 1. Conditional pile (Condition Stub): Lists all the conditions of the problem. The order of the listed conditions is generally considered unimportant; 2. ? Action stub: Lists the actions that may be taken by the problem rule. The order of these operations is not constrained; 3. ? Conditional entry (Condition Entry): Lists the true and false values for the values of its left column conditions in all possible cases; 4.? Action Item (Action Entry): Lists the actions that should be taken in case of various values of the condition item.

· Error-guessing method

Error-guessing is a method of designing test cases based on empirical and intuitive inference of all possible errors in the program. The basic idea of the error-guessing method is to enumerate all the possible errors in the program and the special cases that are prone to errors, and select the test cases according to them.

Finally, the comprehensive strategy for black-box testing is: first, consider the boundary value analysis method, which is the method that must be used in any case, because experience has shown that the test cases designed by this method have the strongest ability to find program errors. If necessary, some test cases are supplemented by equivalence class partitioning methods. Second, some test cases can be appended with the error-guessing method. At this point, you can check the logical coverage of the test cases that have been designed against the program logic, and if the required coverage criteria are not met, sufficient test cases should be supplemented, and if the function description of the program contains a combination of input conditions, the causal graph method can be chosen from the outset.

3. White box Test (White-box testing)

Why should white box testing be considered? To give a chestnut description, set x=0,y=5, program design z=y/x, if only to consider the input and output of the black box test, we can not see the logic inside the program error (denominator cannot be 0), even if we use the black box test case coverage of the full can not find this problem, this time to consider the use of white box test.

And what is white-box testing? White-Box testing, also known as structural testing or logic-driven testing, is a test of how the inside of the unit under test is working. It designs test cases according to the control structure of the program and is mainly used for software or program validation. The White Box test method examines the internal logical structure of the program, tests all logical paths, and is a test method for the exhaustive path, but even if each path has been tested, there may still be errors. Because: Exhaustive path test can not check out whether the program itself violates the design specification, that is, whether the program is a wrong program; exhaustive path testing is not possible to check out the program because of missing the path and error; The exhaustive path test finds no data-related errors.

White box testing needs to follow the principles are: 1. Ensure that all independent paths in a module are tested at least once; 2. All logical values need to be tested for true (true) and False (false); 3. Check the internal data structure of the program to ensure the effectiveness of its structure; 4. All loops are run at the upper and lower bounds and within the operational range.

White box test methods are:

· Static Testing & Dynamic Testing

Static testing is a test that does not run the program, including code checking, static structure analysis, code quality measurement, document testing, etc., it can be done manually, give full play to the people's logical thinking advantage, can also be automated by means of software tools (FXCOP). Dynamic testing requires code execution, which is the most common test we use to run programs to find problems, including functional validation and interface testing, coverage analysis, performance analysis, memory analysis, and more.

· Unit Test

· Code Check

· Peer review

· Technical review

To test the effectiveness of testing, it is necessary to look at the coverage of the test, when coverage is greater, the better the test results, software defects less. But coverage is not a goal (quality is the goal) but only a means. Test coverage includes feature point coverage and fabric coverage, where feature point coverage is broadly used to represent the proportional relationship between the functionality that the software has implemented and the functionality that the software needs to implement, while the fabric coverage includes statement coverage, branch coverage, loop coverage, and path coverage.

In the logic covering method, according to the different coverage target and the detailed degree of the coverage source program statement, the logic overlay can be divided into: statement overlay, decision coverage, conditional coverage, decision/condition coverage, combined coverage, path coverage, and the more the extent of these coverage is more complete.

4. Grey box Test (Gray-box testing)

Gray-Box testing is more like white-box testing and black-box testing of hybrid testing, there is no clearer definition of gray-box testing at this stage, but more often, our test is to do gray-box testing, that is, both black-box testing and white-box testing.

Talking about black box test and white box test

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.