A software defect detection method and system based on swarm intelligence

By combining a swarm intelligence-based software defect detection method with multiple testing techniques, potential defects in software can be discovered and repaired. This solves the problems of low detection accuracy and efficiency in existing technologies, and achieves more efficient defect detection and repair.

CN122285488APending Publication Date: 2026-06-26NANTONG UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANTONG UNIV
Filing Date
2026-02-14
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In existing technologies, static analysis methods cannot accurately analyze complex code structures, while dynamic analysis methods may miss vulnerabilities, thus affecting the accuracy and efficiency of software detection.

Method used

A swarm intelligence-based software defect detection method is adopted. By establishing a software testing model, collecting data, analyzing defect data, building a repair map and simulating repair, and combining static code analysis, symbolic execution and fuzz testing techniques, potential defects are discovered and repaired.

Benefits of technology

It improves the accuracy and efficiency of software defect detection, can effectively handle complex code structures, adaptively adjusts search strategies, provides more accurate defect reports and repair solutions, and improves system flexibility and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122285488A_ABST
    Figure CN122285488A_ABST
Patent Text Reader

Abstract

This invention relates to the field of computer technology, specifically to a software defect detection method and system based on swarm intelligence. It includes the following steps: S1, establishing a software testing model; This invention, by comprehensively applying swarm intelligence algorithms and multiple testing techniques, can discover more potential defects in defect detection, improving the accuracy and efficiency of detection. Through the analysis and mining of test data, defect data, and repair data, it optimizes swarm intelligence algorithms and testing techniques, improving the effectiveness of defect detection and repair. Through software repair mapping, it provides more accurate solutions and guidance for defect reporting and repair. By creating and managing virtual testing environments and automating the testing and repair process, it improves the system's flexibility and efficiency, provides users with reference solutions for software repair, can effectively handle complex code structures, and can adaptively adjust search strategies to adapt to different problems and environments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and more specifically, to a software defect detection method and system based on swarm intelligence. Background Technology

[0002] In modern software development, software defect detection is a critical task. Software defect detection mainly employs static and dynamic analysis methods to detect potential and actual problems in the code. However, static analysis methods cannot accurately analyze complex code structures, while dynamic analysis methods may miss some vulnerabilities, affecting the accuracy and efficiency of software detection. Therefore, this paper proposes a software defect detection method and system based on swarm intelligence. Summary of the Invention

[0003] The purpose of this invention is to provide a software defect detection method and system based on swarm intelligence to solve the problems mentioned in the background art.

[0004] To address the aforementioned technical problems, one objective of this invention is to provide a software defect detection method based on swarm intelligence, comprising the following steps:

[0005] S1. Establish a software testing model, collect data on the software to be tested, and test the software.

[0006] S2. Analyze the test data based on S1 to obtain software defect data;

[0007] S3. Establish a software repair map and find the corresponding repair data in the software repair map based on the defect data obtained in S2.

[0008] S4. Based on the repair data found in S3, simulate the repair of the software, and determine the repair method based on the simulation results.

[0009] As a further improvement to this technical solution, the steps for inputting the S1 data into the software test model for testing are as follows:

[0010] S1.1 Collect category data of the software to be tested and evaluate the category data;

[0011] S1.2 Test the software based on the evaluation data.

[0012] As a further improvement to this technical solution, step S1.1 involves collecting user-defined evaluation indicators and standards by distributing questionnaires, and classifying and entering the questionnaire content into the software testing model to measure and evaluate different types of software defects using the test case coverage formula.

[0013] As a further improvement to this technical solution, the step of S2 to obtain software defect data is as follows:

[0014] S2.1 Collect the test data from S1.2 and establish a test set;

[0015] S2.2. The test set established in S2.1 is verified and mined using a swarm intelligence algorithm.

[0016] As a further improvement to this technical solution, step S2.2 combines software testing techniques, such as static code analysis, symbolic execution, and fuzz testing, to verify and uncover potential defects, and to discover potential defect patterns and rules.

[0017] As a further improvement to this technical solution, the step of S3 in establishing the software repair map is as follows:

[0018] S3.1 Collect software defect network data and send software testing knowledge questionnaires to users to obtain user feedback software data;

[0019] S3.2. Based on the defect network data and feedback software data collected in S3.1, preprocess the data and establish a software repair map based on the processed data.

[0020] As a further improvement to this technical solution, the step of S3 in finding the corresponding repair data within the software repair map is as follows:

[0021] S3.3 Combine the test set verified and mined in S2.2 to generate a defect report;

[0022] S3.4. Based on the defect report generated in S3.3, find the corresponding repair data in the software repair map established in S3.2, and sort the repair data according to the priority in the defect report.

[0023] As a further improvement to this technical solution, the S4 step of determining the software repair steps based on the simulation repair results is as follows:

[0024] S4.1 Create a virtual test environment and combine the repair data obtained in S3.4 with the software to perform repair simulation in the test environment;

[0025] S4.2 Upload the data from the S4.1 repair simulation to the cloud for user evaluation, and implement the repair data obtained in S3.4 to repair the software based on the user evaluation results.

[0026] The second objective of this invention is to provide a software defect detection system based on swarm intelligence, including any one of the above-mentioned software defect detection methods based on swarm intelligence, comprising a software testing unit, a defect acquisition unit, a data repair unit, and a simulation testing unit.

[0027] The software testing unit is used to establish a software testing model, collect data on the software to be tested, and test the software.

[0028] The defect acquisition unit is used to analyze the test data to acquire software defect data;

[0029] The data repair unit is used to establish a software repair map and to find the corresponding repair data in the software repair map based on the acquired defect data.

[0030] The simulation testing unit is used to simulate the repair of the software based on the repair data, and to determine whether to repair the software based on the simulation repair results.

[0031] Compared with existing technologies, the beneficial effects of this invention are as follows: By comprehensively applying swarm intelligence algorithms and multiple testing techniques, more potential defects can be discovered in defect detection, improving the accuracy and efficiency of detection; by analyzing and mining test data, defect data, and repair data, swarm intelligence algorithms and testing techniques are optimized, improving the effectiveness of defect detection and repair; through software repair maps, more accurate solutions and guidance are provided for defect reporting and repair; by creating and managing virtual testing environments and automating the testing and repair process, the flexibility and efficiency of the system are improved; it provides users with reference solutions for software repair; it can effectively handle complex code structures; and it can adaptively adjust search strategies to adapt to different problems and environments. Attached Figure Description

[0032] Figure 1 This is an overall flowchart of the present invention;

[0033] Figure 2 This is a flowchart illustrating the software testing process of the present invention.

[0034] Figure 3 This is a flowchart illustrating the process of obtaining software defect data according to the present invention.

[0035] Figure 4 This is a flowchart illustrating the process of finding the corresponding repair data in this invention.

[0036] Figure 5 This is a flowchart illustrating the process of determining software repair based on simulation repair results according to the present invention.

[0037] Figure 6 This is a schematic diagram of the software testing unit of the present invention.

[0038] The meanings of the labels in the diagram are as follows:

[0039] 10. Software testing unit; 20. Defect acquisition unit; 30. Data repair unit; 40. Simulation testing unit. Detailed Implementation

[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0041] Example

[0042] like Figure 1-6 As shown, one of the objectives of this invention is to provide a software defect detection method based on swarm intelligence, comprising the following steps:

[0043] S1. Establish a software testing model, collect data on the software to be tested, and test the software.

[0044] The steps for inputting the S1 data into the software test model for testing are as follows:

[0045] S1.1 Collect category data of the software to be tested and evaluate the category data;

[0046] S1.1 collects user-defined evaluation indicators and standards by distributing questionnaires, and classifies the questionnaire content into the software testing model. The software is classified according to its application area, function, and characteristics, such as desktop applications, mobile applications, web applications, and game software, so that different types of software defects can be measured and evaluated using the test case coverage formula.

[0047] S1.2. Test the software based on the evaluation data. The test uses the example coverage formula, which is used to evaluate whether the tests cover all functional features of the code. The example coverage formula is as follows:

[0048]

[0049] in, For test case coverage, The number of lines of code to be covered. The total number of lines of code, based on The numerical judgment software function is more comprehensive in terms of its functions; the larger the numerical value, the more comprehensive the software function coverage.

[0050] S2. Analyze the test data based on S1 to obtain software defect data;

[0051] The steps for S2 to obtain software defect data are as follows:

[0052] S2.1. Collect the test data from S1.2 and establish a test suite; collect data and information gathered during software testing through network logs, such as statistical analysis of test case coverage, recording the number and type of defects; the steps are as follows:

[0053] Verify and filter test data: Before conducting software testing, it is necessary to verify and filter test data to eliminate inappropriate test data. Verify the validity of the test data, ensure that the data meets the testing requirements, and eliminate duplicate data.

[0054] Establish test suites: Classify test data according to its type and attributes to create test suites. Test suites should cover various scenarios and abnormal situations to ensure comprehensive and effective testing.

[0055] Record the source and attributes of the test data: Record the source and attributes of the test data, including data file name, data type, data range, data format, and other information.

[0056] S2.2. The test set established in S2.1 is verified and mined using a swarm intelligence algorithm.

[0057] S2.2 utilizes software testing techniques, such as static code analysis, symbolic execution, and fuzzing, combining them to verify and uncover potential defects, revealing patterns and regularities. These technical modules can be combined as needed to improve the accuracy and efficiency of defect detection.

[0058] Static code analysis metrics: The effectiveness of static code analysis can be evaluated using the following metrics:

[0059] Overall coverage: The ratio of lines of code covered by the symbolic execution tool through test cases to the total number of lines of code;

[0060] Branch coverage: The ratio of the number of branches executed by the symbolic execution tool through test cases to the total number of branches;

[0061] Path coverage: The ratio of the number of paths executed by the symbolic execution tool to the total number of paths.

[0062] Fuzzing metrics: The following metrics can be used to evaluate the effectiveness of fuzzing:

[0063] Vulnerability discovery rate: The ratio of the number of vulnerabilities detected in fuzzing tests to the total number of test cases; the expression is as follows:

[0064] Define a weight vector w containing n elements:

[0065]

[0066] make For each test case, the total number of test cases in the test set is [number]. Obtain their relative weights:

[0067]

[0068] in, This indicates that test case i is in the weight vector The contribution below, for each test case Calculate its test contribution bi:

[0069]

[0070] in, Represents the weight vector of the first element. The weight of each element, Indicates test cases In the weight vector The contribution of test case i can be calculated by multiplying these two factors and then summing them. , This indicates the sequence from the first test case to the last test case;

[0071] Calculate the priority of cases based on their contribution to the test:

[0072]

[0073] By test cases test contribution Divide by the total number of test cases in the test set Test cases can be obtained. priority Test cases with higher priority should be prioritized in the test plan;

[0074] Sort all test cases in the test set according to their priority to obtain the test case priority sequence:

[0075]

[0076] S3. Establish a software repair map and find the corresponding repair data in the software repair map based on the defect data obtained in S2.

[0077] The steps for S3 to establish the software repair map are as follows:

[0078] S3.1 Collect software defect network data and send software detection knowledge questionnaires to users to obtain user feedback software data; use web crawlers to search for knowledge and experience related to software defects on the network, and obtain software defect knowledge uploaded by users by sending software detection knowledge questionnaires to users, establish a software repair map to record the repair history of software defects, and provide reference and guidance for defect detection and repair.

[0079] S3.2. Based on the defect network data and feedback software data collected in S3.1, preprocess the data and establish a software repair map based on the processed data. The data preprocessing steps are as follows:

[0080] Data Acquisition: Acquiring raw data, which may include text, images, videos, or other formats;

[0081] Data cleaning: Examine the raw data, detect and eliminate invalid data, missing data, erroneous data, outliers, duplicate data, etc.

[0082] Data transformation: Converting cleaned data into a format and type suitable for the problem.

[0083] Establishing a Repair Graph: Based on the defect correlation model, a software repair graph is established. The repair graph can be represented graphically or using data structures. In the repair graph, each node represents a defect, and each edge represents a repair relationship for that defect. The repair graph can be used to identify and locate software defects, enabling timely discovery and resolution of problems. The repair graph can be represented by the following formula:

[0084]

[0085] in, This represents the set of nodes in the repair graph. Indicates the number of nodes;

[0086]

[0087] in, This represents the set of edges in the repaired graph. Indicates the number of edges;

[0088] For any pair of defects and If there exists a line from arrive A directed path, representing The repair conditions can be solved The defect problem is that such a path can be represented by a sequence:

[0089]

[0090] in, Indicates the termination node. Indicates the starting node. Based on the repair map and path. To accurately identify and locate software defects and improve software quality.

[0091] The steps of S3 in finding the corresponding repair data within the software repair map are as follows:

[0092] S3.3. Combine the test set verified and mined in S2.2 to generate a defect report; the steps for generating the defect report are as follows:

[0093] Integrate the test dataset: Integrate the validated and mined test datasets.

[0094] Defect localization: Based on the defects found in the test data, locate the corresponding source code.

[0095] Mark defects: Mark defects, including defect type and discovery time.

[0096] Generate defect reports: Classify, statistically analyze, and then generate defect reports from the marked defects.

[0097] S3.4. Based on the defect report generated in S3.3, locate the corresponding repair data in the software repair map established in S3.2, and sort the repair data according to the priority in the defect report. The sorting steps are as follows:

[0098] Matching with defect reports: Based on the defect type, impact level, and other information in the defect report, match it with the corresponding repair history in the software repair map.

[0099] Prioritize the repair data: Sort the matched repair history data according to the priority specified in the defect report. The priority formula is as follows:

[0100] ;

[0101] ;

[0102] Where X is the priority score, X1 is the defect impact score, X2 is the defect type score, Q is the repair effect score, Q1 is the repair time score, and Q2 is the repair effect score. After calculating the priority score and repair effect score according to the above formula, the total score for each repair history data can be calculated using the following expression:

[0103] ;

[0104] Where O is the total score for repairing historical data, and α is the weight of the priority score.

[0105] Output sorting results: The repair history data sorted by defect priority will be output as a report or table.

[0106] S4. Based on the repair data found in S3, simulate the repair of the software, and determine the repair method based on the simulation results.

[0107] The S4 step, based on the simulation repair results, determines the software repair steps as follows:

[0108] S4.1 Create a virtual test environment and combine the repair data obtained in S3.4 with the software to simulate repair within the test environment. Creating and managing a virtual test environment provides a more flexible and controllable testing environment, accelerating the defect detection and repair process. The simulation test steps are as follows:

[0109] Creating a virtual testing environment: Use the VirtualBox virtualization platform to create a virtual testing environment.

[0110] Importing Software and Repair Data: In the virtual testing environment, install the original software and integrate the acquired repair data with the software for uploading.

[0111] Perform repair simulation: Simulate the software repair process in a virtual testing environment using automated testing methods.

[0112] Generate test report: Based on the test results, generate a test report, including test data, test results, and repair results.

[0113] The corrected result expression in the test report is as follows:

[0114]

[0115]

[0116] in, For repair time, End time, For the start time, To increase the success rate of the repair, Rate the repair effect. The value ranges from 1 to 100, with the value being closer to 100 indicating a better simulation repair effect.

[0117] S4.2. Upload the simulation data from S4.1 to the cloud for user evaluation. Based on the user evaluation results, implement the repair data obtained in S3.4 to repair the software. Combine the obtained test report with the software and upload the test data to the cloud. Users evaluate the repair effect in the cloud. When the user decides to implement, the corresponding repair data is used to repair the software. When the user is unsure about implementation, the repair data is adjusted according to the modification plan uploaded by the user, and then the modified repair data is combined with the software to implement the repair.

[0118] The second objective of this invention is to provide a software defect detection system based on swarm intelligence, including any of the above-mentioned software defect detection methods based on swarm intelligence, comprising a software testing unit 10, a defect acquisition unit 20, a data repair unit 30, and a simulation testing unit 40.

[0119] The software testing unit 10 is used to establish a software testing model, collect data on the software to be tested, and test the software.

[0120] The defect acquisition unit 20 is used to analyze test data and acquire software defect data;

[0121] The data repair unit 30 is used to establish a software repair map and to find the corresponding repair data in the software repair map based on the acquired defect data.

[0122] The simulation test unit 40 is used to simulate the repair of the software based on the repair data, and to determine the repair of the software based on the simulation repair results.

[0123] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely preferred examples and are not intended to limit the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of the present invention is defined by the appended claims and their equivalents.

Claims

1. A swarm intelligence based software defect detection method, characterized in that: Includes the following steps: S1. Establish a software testing model, collect data on the software to be tested, and test the software. S2. Analyze the test data based on S1 to obtain software defect data; S3. Establish a software repair map and find the corresponding repair data in the software repair map based on the defect data obtained in S2. The steps for establishing the software repair map are as follows: S3.1 Collect software defect network data and send software testing knowledge questionnaires to users to obtain user feedback software data; S3.

2. Based on the defect network data and feedback software data collected in S3.1, preprocess the data and establish a software repair map based on the processed data. The steps for locating the corresponding repair data within the software repair map are as follows: S3.3 Combine the test set verified and mined in S2.2 to generate a defect report; S3.

4. Based on the defect report generated in S3.3, find the corresponding repair data in the software repair map established in S3.2, and sort the repair data according to the priority in the defect report; S4. Based on the repair data found in S3, simulate the repair of the software, and determine the repair method based on the simulation results.

2. The swarm intelligence based software defect detection method of claim 1, wherein: The steps for inputting the S1 data into the software test model for testing are as follows: S1.1 Collect category data of the software to be tested and evaluate the category data; S1.2 Test the software based on the evaluation data.

3. The swarm intelligence based software defect detection method of claim 2, wherein: S1.1 collects user-defined evaluation indicators and standards by distributing questionnaires, and classifies and enters the questionnaire content into the software testing model to measure and evaluate different types of software defects using the test case coverage formula.

4. The swarm intelligence based software defect detection method of claim 2, wherein: The steps for S2 to obtain software defect data are as follows: S2.1 Collect the test data from S1.2 and establish a test set; S2.

2. The test set established in S2.1 is verified and mined using a swarm intelligence algorithm.

5. The swarm intelligence based software defect detection method of claim 4, wherein: S2.2 uses software testing techniques, such as static code analysis, symbolic execution, and fuzz testing, to combine them for testing, verifying and uncovering potential defects, and discovering potential defect patterns and rules.

6. The swarm intelligence based software defect detection method of claim 5, wherein: The S4 step, based on the simulation repair results, determines the software repair steps as follows: S4.1 Create a virtual test environment and combine the repair data obtained in S3.4 with the software to perform repair simulation in the test environment; S4.2 Upload the data from the S4.1 repair simulation to the cloud for user evaluation, and implement the repair data obtained in S3.4 to repair the software based on the user evaluation results.

7. A system for implementing swarm intelligence based software defect detection, comprising the swarm intelligence based software defect detection method of any one of claims 1-6, characterized in that: It includes a software testing unit (10), a defect acquisition unit (20), a data repair unit (30), and a simulation testing unit (40); The software testing unit (10) is used to establish a software testing model, collect data of the software to be tested, and test the software. The defect acquisition unit (20) is used to analyze the test data to acquire software defect data; The data repair unit (30) is used to establish a software repair map and find the corresponding repair data in the software repair map based on the acquired defect data. The simulation test unit (40) is used to simulate the repair of the software based on the repair data, and to determine the repair of the software based on the simulation repair results.