What is the role of black and white box testing in software testing?

I. Introduction

As the software market matures, people's expectations for the role of software are getting higher and higher. Software companies in my country have become more aware of the importance of software testing and gradually increase the proportion of software testing in the overall software development system engineering. .

Software testing is not a single "fault finding" process before product delivery in the traditional sense, but runs through the software process from beginning to end, and is a scientific quality control process. For any engineering product, one of the following two methods can be used for testing, namely black box testing and white box testing.

2. The role of black box testing in software testing

Black-box testing is also called functional testing, behavioral testing or data-driven testing. During testing, the program is regarded as a black box that cannot be opened. The tester does not consider the logic structure and internal characteristics of the program at all, and only based on the requirements of the program Specifications, check whether the function of the program meets its function description, so the black box test is the basic test. For example: we use C# to write a "calculator" application, if we enter 7 and press the sqrt key, the result will be 2.645751311. Using the black box test method, no matter how many complicated calculations are required to "find the square root", you only care about the results of its operation.

Black box testing methods mainly include equivalence class division, boundary value analysis, cause-effect graph, error speculation, etc., which are mainly used for software verification testing. The "black box" method focuses on the external structure of the program, does not consider the internal logical structure, and tests the software interface and software functions. The "black box" method is an exhaustive input test. Only when all possible inputs are used as test conditions can all errors in the program be detected by this method. In fact, there are an infinite number of test cases. People not only have to test all legal inputs, but also those illegal but possible inputs. The main defect of black box testing is that it is difficult to measure the integrity of the system, and white box testing can just make up for this defect.

"Black box" means that you can't see what's inside the box, which means that black box testing doesn't care about the internal design and program implementation of the software, but only the external performance, that is, the conclusion of the test can be known by observing the input and output. Anyone can perform black box testing based on software requirements. Black box testing focuses on the functional requirements of the test software, focuses on the external structure of the program, does not consider the internal logical structure, and mainly tests the software interface and software functions, and is mostly used in the later stages of the testing process. It is an actual test carried out with the system according to software requirements, design documents, and simulated customer scenarios. This test technology covers all aspects of testing. It is mainly for finding the following types of errors: whether there are functional errors or omissions; in the interface Whether it can perform correct input and output; whether there are data structure errors or external database access errors; whether performance can meet the requirements; whether there are initialization or termination errors.

So black box testing actually checks whether the following points meet the requirements:

1. Correctness of c: calculation results, naming, etc.

2. d Usability: Whether it can meet the requirements of the software.

3. E boundary condition (Boundary Condition): The boundary value of the input part is divided by equivalence class, try the maximum and minimum and illegal data, etc.

4. Performance (Performance): The performance of the program depends on two factors: the speed of operation and the system resources that need to be consumed. If performance problems are found during the test, it is very difficult to repair, because this often means that the program's algorithm is not good, the structure is not good, or the design is wrong. Therefore, at the beginning of product development, software performance issues must be considered.

5. g stress test (Stress): For multi-user situations, consider using stress test tools. It is recommended to combine stress and performance tests. If there is load balancing, you must also open the monitoring tool on the server side to check the server CPU usage and memory usage. If necessary, you can simulate a large amount of data input, the impact on the hard disk, and so on.

6, h Error Recovery (Error Recovery): error handling, page data verification, including sudden power failure, input wrong data, etc.

7. i security test (Security): especially some business websites, or web related to money or company secrets, need this test.

8. j Compatibility: The performance of different browsers and different application versions when implementing functions.

Using black box testing technology, it is possible to design a set of test cases that meet the following standards:

(1) The designed test cases can reduce the total number of test cases designed to achieve reasonable testing;

(2) The designed test case can tell us whether there are certain types of errors, not just whether there are errors related to a specific test.

3. The role of white box testing in software testing

White box testing is also called structural testing or logic-driven testing. It is a software testing technology based on understanding the internal structure of software and how programs run. It usually needs to track which input has been processed and whether these processing methods are correct. This method treats the test object as an open box, which allows testers to use the logic structure and related information within the program to design or select test cases to test all logic paths of the program.

White box testing focuses on the internal conditions of the tested object and needs to track the operation of the source code. By checking the logic structure inside the software, the logic path in the software is covered and tested; check points are set up in different places of the program to check the status of the program to determine whether the actual operating state is consistent with the expected state. White-box testers must understand the internal design and program implementation of the software, and be able to write test-driven programs. The developers generally take the role of testers concurrently. Many testers, especially junior testers, believe that white box testing is a test that can only be done by senior testers who know the program code very well. Familiar with the code structure and the process of function realization is of course very helpful for testing, but some white box testing does not require testers to understand every line of program code. Suppose we have the following program:
Insert picture description here
  For the above program, designing two test cases can meet the requirement of conditional coverage.

The input of the test case is:

{ a=5、b=15、c=15}

{ a=2、b=15、c=15}

Although the above two test cases can meet the requirement of condition coverage, they cannot check the judgment conditions. For example, the second condition b>15 is incorrectly written as b<15. The above test case also meets the branch coverage.

White box testing of software is a detailed inspection of the procedural details of the software. By checking the state of the program at different points, determine whether the actual state is consistent with the expected state. The main purpose of white box testing is to check program modules as follows:

1. Test all independent execution paths of program modules at least once.

2. For all logical judgments, the two cases of "true" and "false" can be tested at least once.

3. Execute the loop body within the boundary of the loop and the boundary of the operation.

4. Test the validity of internal data structures, etc.

The main methods of white box testing include statement coverage, judgment coverage, condition coverage, judgment/condition coverage, condition combination coverage, path coverage, etc. It is a test that goes deep to the code level. The use of this technology to find problems is the earliest and the effect is also the best. The main feature of this technology is that the test object enters the code. According to the developer's familiarity with the code and program, the software is coded for the necessary parts, and the developer performs software testing according to his own understanding and contact of the code.

Fourth, the relationship between white box testing and black box testing

Both white box testing and black box testing are very important links. There is no question of who is high in technology and who is low in technology. It is just that the emphasis of the two is different and the technology used is also different. Black box testers focus on business aspects, while white box testers focus on implementation methods; black box testing focuses on the whole, while white box testing focuses more on the part. White box testing is a test of process, and black box testing is a test of results.

Five, test cases

In fact, there are many testing situations, not only testing all limited inputs, but also testing those illegal but possible inputs. In this way, complete testing is impossible, so we have to conduct targeted testing and guide the implementation of testing by formulating test cases to ensure that software testing is organized, step-by-step, and planned. Testing behavior must be quantified in order to truly guarantee software quality, and test cases are one of the methods to quantify testing behavior. Among them, logic coverage technology is a typical technology of white box testing, while technologies such as equivalence division, boundary analysis, and causality diagram are more typical technologies of black box testing.

Six, conclusion

Black box testing and white box testing are two different testing methods. Both methods will be used in the entire testing process, but based on experience, in a project, test engineers still use black box testing as the main and white box testing as a supplement. Because you first need to use black box testing to verify whether the result is correct, or whether the target is correct, and if the result is correct, then use white box testing to verify whether the correct result is due to the correct process. If the result is not correct, use white box testing to find the wrong place in the process. Only by doing the black box test first and then verifying it with the white box test can the test be said to be complete.

I recommend a software testing exchange group, QQ: 642830685. The group will share software testing resources, interview test questions and industry information from time to time. Friends can actively communicate and interact in the group. There are also technical experts to answer related questions for you.

Guess you like

Origin blog.csdn.net/weixin_53519100/article/details/112795353