Technology Sharing

How to analyze bugs found in software testing!

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

If you are asoftware testing engineer, what you face every day are those "tricky" bugs, which are like enemies hidden in the dark, jumping out from time to time to give you a "surprise". So, how can you effectively analyze and handle these bugs to make your testing work efficient and interesting? Let's talk about this topic today.

Start with the root cause: Where is the real culprit of the bug?

Let's take a look at a classic case. Xiao Li is an experiencedTest Engineer, he was recently responsible for testing a financial system. During a test, Xiao Li discovered a serious bug: when users were transferring money, the amount was incorrect. If this bug was put into the production environment, the consequences would be disastrous.

So, Xiao Li began his "detective journey". He started with the root cause and analyzed various factors that may have caused this bug. After some investigation, Xiao Li found that the problem was due to incomplete requirements analysis and program code problems. The requirements document did not detail certain boundary conditions, which caused errors in the program when handling special scenarios.

In this case, Xiao Li not only needs to fix the bug, but also needs to improve the requirements analysis and code review process to prevent similar problems from happening again.

Case sharing: Behind the program code problem

Let's look at another case. Xiao Wang is Xiao Li's colleague. They are jointly involved in the testing of an e-commerce project. Xiao Wang found a bug: the inventory quantity of some items in the shopping cart cannot be correctly displayed. This bug seems simple, but the reason behind it is very complicated.

After detailed analysis, Xiao Wang found that the programmer only considered normal scenarios when coding, but ignored abnormal situations. For example, when the inventory quantity was zero, the program did not make corresponding processing, resulting in a display error. This bug reminded Xiao Wang that when writing test cases, not only normal scenarios should be covered, but also various abnormal situations should be considered.

In order to help everyone understand better, Xiao Wang also wrote a sample code:

def check_inventory(item_id):    inventory = get_inventory(item_id)    if inventory > 0:        return f"库存数量:{inventory}"    else:        return "商品已售罄"

# 测试用例assert check_inventory(101) == "库存数量:10"assert check_inventory(102) == "商品已售罄"

This code uses simple conditional judgment to ensure that the information is displayed correctly even when the inventory is zero. This is the revelation that Xiao Wang got from Bug Analysis.

Analyze the defect discovery phase: Start from the source

When analyzing bugs, we also need to pay attention to the stage of the development process in which they are discovered. Generally speaking, the bug discovery stage can be divided into the test analysis stage and the test execution stage.

The test analysis phase mainly reviews the requirements documents and outline design documents. Bugs found in this phase are often related to document issues and review issues. The test execution phase, including smoke testing, functional testing, regression testing, etc., is a comprehensive verification of the software to ensure the normal operation of each functional module.

For example, Xiao Li and Xiao Wang found a lot of documentation problems at the beginning of the project. If these problems were not solved in time, they would probably cause more bugs in subsequent tests. Therefore, they strictly checked at each testing stage to ensure that all documents and codes were fully reviewed.

Defect introduction system analysis: Find the "high-incidence areas"

Sometimes, the occurrence of bugs is related to the complexity and amount of modification of a specific system. In a large project involving multiple systems, some systems may become "hot spots" for bugs due to the large amount of modification. For example, in the project of Xiao Li and Xiao Wang, System 2 and System 3 had the largest amount of modification, so they also had the most bugs.

By calculating the defect density of each system (i.e. the number of defects per thousand lines of code), they found that although system 4 had a large amount of modifications, it had relatively few defects. This shows that the code quality of system 4 is high, while systems 2 and 3 need further optimization.

Test missed detection analysis: Preventing "fish slipping through the net"

Finally, we also need to pay attention to the problem of missed detection in testing. Even if the testers are careful, some bugs may still "slip through the net" during the testing phase and enter the production environment. In order to reduce this situation, Xiao Li and Xiao Wang regularly review the testing process, analyze which links may have omissions, and make timely improvements.

For example, after a project was launched, they found some bugs in the production environment, one-third of which were caused by missed detection during the testing process. Some of these bugs were caused by insufficient test case coverage, and some were caused by low test data quality.

Final Thoughts

Through comprehensive analysis of bugs, we can not only find out the root cause of the problem, but also get inspiration for improvement. Whether it is demand analysis, code quality, or testing process, every link requires our careful attention and continuous optimization. Only in this way can we improve software quality and reduce the occurrence of bugs.

Finally, I would like to thank everyone who reads my article carefully. Seeing the number of fans and attention increasing all the way, I think it’s always good to reciprocate. Although it’s not something very valuable, you can take it directly if you need it! 

Software Testing Interview Document

We study in order to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet giants such as Alibaba, Tencent, and ByteDance, and ByteDance bosses have given authoritative answers. After finishing this set of interview materials, I believe everyone can find a satisfactory job.

insert image description here