Regression testing method, device, equipment and medium

Through code change data analysis and dependency graph generation, combined with graph traversal algorithm and pre-training model, the scope of regression testing is determined, test cases are automatically generated and integrated into the continuous integration deployment pipeline, which solves the problem of low efficiency and poor timeliness of existing regression testing methods. problem, achieving efficient and automated regression testing.

CN119357055APending Publication Date: 2025-01-24SHUI YOU INFORMATION TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411472146.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

The existing regression testing methods rely on manual determination of the test range, resulting in low testing efficiency and poor timeliness, making it difficult to adapt to the needs of rapid iteration and change of software systems.

Method used

Change the data by collecting code, perform static and dynamic code analysis, generate initial and runtime dependency relationship diagrams, combine code change details to generate target dependency relationship diagrams, use diagrams and pre -training models to determine the regression test scope, automatically generate test cases, and automatically generate test cases. Integrated to continuously integrated deployment flow lines.

Benefits of technology

Improve the efficiency and timely rate of regression testing, ensure that the test covers all affected code paths, reduce redundant testing, improve test efficiency, and achieve automated test execution and results feedback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357055A_ABST
    Figure CN119357055A_ABST
Patent Text Reader

Abstract

The invention discloses a regression testing method and device, equipment and a medium, and relates to the technical field of software testing, and the method comprises the steps: collecting current code change data between a previous version code and a current version code of to-be-tested software, and generating current change details; performing static code analysis and dynamic code analysis on the current version code to obtain an initial dependency relationship graph and a runtime dependency relationship, and obtaining a target dependency relationship graph based on the initial dependency relationship graph, the runtime dependency relationship and the current change details; traversing each dependency relationship in the target dependency relationship graph by using a graph traversal algorithm to obtain a propagation path influenced by the current code change data, and determining a regression test range of the current version code by using the target pre-training model and the propagation path; and continuously integrating and deploying the assembly line to execute the test case set generated based on the regression test range, and completing the regression test to obtain a current regression test result. And the regression test efficiency and timeliness rate are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing, and in particular to a regression testing method, device, equipment and medium. Background Art

[0002] In current software testing practices, regression testing is a common type of testing used to verify that parts that previously worked correctly are still working correctly after code modifications. Conventional methods of regression testing usually include manually determining the test scope, that is, testers select and execute a series of test cases to cover code areas or functional modules that may be affected by the modification based on their understanding and experience of the software system. This approach relies on the testers' expertise and experience, as well as their understanding of software requirements and changes.

[0003] With the continuous development and change of software systems, the scope of testing is also expanding. Manually determining the scope of testing requires testers to invest a lot of time and energy to analyze, evaluate and select test cases, which not only increases the cost of testing, but may also affect the progress of testing. With the rapid iteration and change of software systems, the scope of testing is also constantly changing. The method of manually determining the scope of testing is difficult to adapt to such changes in a timely manner, resulting in problems such as test delays and inadequate testing.

[0004] From the above, it can be seen that how to improve the efficiency and timeliness of regression testing is a problem to be solved in this field. Summary of the invention

[0005] In view of this, the purpose of the present invention is to provide a regression testing method, device, equipment and medium to improve the efficiency and timeliness of regression testing. The specific scheme is as follows:

[0006] In a first aspect, the present application discloses a regression testing method, comprising:

[0007] Collect the current code change data between the previous version code and the current version code of the software to be tested to generate the current change details;

[0008] Obtaining static code analysis and dynamic code analysis for the current version code respectively to obtain an initial dependency graph and a runtime dependency graph respectively, and obtaining a target dependency graph based on the initial dependency graph, the runtime dependency graph, and the current change details;

[0009] Using a graph traversal algorithm to traverse each dependency in the target dependency graph to obtain a propagation path affected by the current code change data, and using a target pre-trained model and the propagation path to determine a regression test scope for the current version of the code;

[0010] The test cases generated based on the regression test scope are integrated into the continuous integration deployment pipeline, so that the continuous integration deployment pipeline executes the test cases, completes the regression test of the current version of the code, and obtains the current regression test result.

[0011] Optionally, collecting current code change data between a previous version code and a current version code of the software to be tested to generate current change details includes:

[0012] Use the version control tool to collect the current code change data between the previous version code and the current version code of the software to be tested, and generate the current change details according to the current code change data, the user identity corresponding to the current code change data, the change time, the code change annotation and the location information.

[0013] Optionally, the obtaining performs static code analysis and dynamic code analysis on the current version code to obtain an initial dependency graph and a runtime dependency graph, respectively, including:

[0014] Performing static code analysis on the current version code to identify dependencies of the current version code and obtain an initial dependency graph;

[0015] When the software to be tested runs the current version code, dynamic code analysis is performed on the current version code to obtain runtime dependencies of the current version code.

[0016] Optionally, the acquiring a target dependency graph based on the initial dependency graph, the runtime dependency, and the current change details includes:

[0017] The initial dependency graph and the runtime dependency graph are merged to obtain a merged dependency graph, and the merged dependency graph is correspondingly annotated based on the current change details to obtain a target dependency graph.

[0018] Optionally, merging the initial dependency graph and the runtime dependency graph to obtain a merged dependency graph includes:

[0019] Cleaning redundant data between the initial dependency graph and the runtime dependency to obtain a cleaned dependency graph and cleaned dependency relationships;

[0020] A mapping relationship between the cleaned dependency graph and the cleaned dependency relationship is established, so as to merge the cleaned dependency relationship into the cleaned dependency graph based on the mapping relationship to obtain a merged dependency graph, and the merged dependency graph is displayed on a preset display interface.

[0021] Optionally, before determining the regression test scope of the current version code by using the target pre-trained model and the propagation path, the method further includes:

[0022] Preprocessing the initial training data set to obtain a target training data set; wherein the initial training data set includes historical regression test results and corresponding historical code change data, and the preprocessing includes data cleaning and data normalization;

[0023] The constructed initial pre-training model is trained using the target training data set, and the weight parameters of the initial pre-training model are updated using a gradient descent algorithm to obtain a target pre-training model that meets a preset convergence condition.

[0024] Optionally, after performing static code analysis and dynamic code analysis on the current version code to obtain an initial dependency graph and a runtime dependency graph, the step further includes:

[0025] Generate a runtime dependency report according to the runtime dependency, and display the runtime dependency report on a preset display interface;

[0026] A code security check is performed on the runtime dependency report. If the generated check result indicates that an abnormality exists in the current version code, an abnormality alarm is generated and displayed on the preset display interface.

[0027] In a second aspect, the present application discloses a regression testing device, comprising:

[0028] A change generation module is used to collect the current code change data between the previous version code and the current version code of the software to be tested to generate the current change details;

[0029] A dependency graph acquisition module is used to perform static code analysis and dynamic code analysis on the current version code to obtain an initial dependency graph and a runtime dependency graph, respectively, and obtain a target dependency graph based on the initial dependency graph, the runtime dependency graph, and the current change details;

[0030] A scope determination module, configured to traverse each dependency in the target dependency graph using a graph traversal algorithm to obtain a propagation path affected by the current code change data, and determine a regression test scope of the current version of the code using a target pre-trained model and the propagation path;

[0031] The regression test module is used to integrate the test cases generated based on the regression test scope into the continuous integration deployment pipeline, so that the continuous integration deployment pipeline executes the test cases, completes the regression test of the current version of the code, and obtains the current regression test results.

[0032] In a third aspect, the present application discloses an electronic device, comprising:

[0033] Memory, used to store computer programs;

[0034] The processor is used to execute the computer program to implement the steps of the regression testing method disclosed above.

[0035] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of the regression testing method disclosed above are implemented.

[0036] The beneficial effects of the present application are as follows: the present application collects the current code change data between the previous version code and the current version code of the software to be tested to generate the current change details; obtains static code analysis and dynamic code analysis for the current version code respectively to obtain the initial dependency graph and the runtime dependency respectively, and obtains the target dependency graph based on the initial dependency graph, the runtime dependency and the current change details; uses a graph traversal algorithm to traverse each dependency in the target dependency graph to obtain the propagation path affected by the current code change data, and uses the target pre-trained model and the propagation path to determine the regression test scope of the current version code; integrates the test cases generated based on the regression test scope into the continuous integration deployment pipeline, so that the continuous integration deployment pipeline executes the test cases, completes the regression test of the current version code, and obtains the current regression test results. It can be seen that this application combines the initial dependency graph obtained by static code analysis, the runtime dependency obtained by dynamic code analysis, and the current change details to generate a comprehensive target dependency graph, thereby improving the accuracy and coverage of change impact analysis. The application of graph traversal algorithms and target pre-training models can more accurately predict the scope affected by the current code change data, that is, the regression test scope of the current version of the code, ensuring that the test covers all affected code paths, automatically generating and optimizing regression test cases, reducing redundant testing, and improving testing efficiency. The regression testing process can be integrated into the continuous integration deployment pipeline to achieve automated test execution and result feedback, ensuring continuous improvement and optimization of the testing process, and being able to perform regression testing on the current version of the code in a timely manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0038] Figure 1 A flow chart of a regression testing method disclosed in this application;

[0039] Figure 2 A specific regression test schematic diagram disclosed in this application;

[0040] Figure 3 This is a schematic diagram of the structure of a regression testing device disclosed in this application;

[0041] Figure 4 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0042] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0043] In current software testing practices, regression testing is a common type of testing used to verify that parts that previously worked correctly are still working correctly after code modifications. Conventional methods of regression testing usually include manually determining the test scope, that is, testers select and execute a series of test cases to cover code areas or functional modules that may be affected by the modification based on their understanding and experience of the software system. This approach relies on the testers' expertise and experience, as well as their understanding of software requirements and changes.

[0044] With the continuous development and change of software systems, the scope of testing is also expanding. Manually determining the scope of testing requires testers to invest a lot of time and energy to analyze, evaluate and select test cases, which not only increases the cost of testing, but may also affect the progress of testing. With the rapid iteration and change of software systems, the scope of testing is also constantly changing. The method of manually determining the scope of testing is difficult to adapt to such changes in a timely manner, resulting in problems such as test delays and inadequate testing.

[0045] To this end, this application provides a regression testing solution to improve the efficiency and timeliness of regression testing.

[0046] See also Figure 1 As shown, the embodiment of the present application discloses a regression testing method, including:

[0047] Step S11: collecting current code change data between the previous version code and the current version code of the software to be tested to generate current change details.

[0048] In this embodiment, the current code change data between the previous version code and the current version code of the software to be tested is collected to generate current change details, including: using a version control tool to collect the current code change data between the previous version code and the current version code of the software to be tested, and generating current change details based on the current code change data, the user identity corresponding to the current code change data, the change time, the code change comments and the location information.

[0049] Use version control tools to collect the current code change data between the previous version code and the current version code of the software to be tested, configure Git hooks or automation scripts to automatically record the change details of each submission, use a database to store the current code change data, and establish a change record database, such as MySQL or PostgreSQL.

[0050] For example, use the diff tool of Git to collect the current code change data. diff is a command-line tool widely used in Unix and Unix-like systems. Its main function is to compare the contents of two files or folders and output the differences between them. In version control systems, especially distributed version control systems like Git, the diff command is used to display code changes between different versions. Therefore, when developers modify the code base, they can use the Git diff command to view the differences between the current working directory (or staging area) and the last submission (or specified submission). A detailed change list can be generated through Gitdiff. This change record is the basis for subsequent change impact analysis and regression test scope determination. The list includes the names of all modified files, the current code change data, the user identity corresponding to the current code change data, the change time, code change comments, and location information; among which, the user identity corresponding to the current code change data is the identity of the developer or user who performed the code change, and the location information corresponding to the current code change data refers to the specific code lines or files involved in the code change. These modifications usually occur on one or more lines in a specific file. The specific lines or files refer to the collection of modified code lines or files, and the change time is the timestamp when the code change is submitted to the version control system.

[0051] Step S12: Obtain static code analysis and dynamic code analysis for the current version code respectively to obtain an initial dependency graph and a runtime dependency graph respectively, and obtain a target dependency graph based on the initial dependency graph, the runtime dependency graph, and the current change details.

[0052] In this embodiment, the acquisition performs static code analysis and dynamic code analysis on the current version code respectively to obtain an initial dependency graph and a runtime dependency, including: performing static code analysis on the current version code to identify the dependencies of the current version code to obtain an initial dependency graph; when the software to be tested runs the current version code, performing dynamic code analysis on the current version code to obtain the runtime dependencies of the current version code.

[0053] On the one hand, static code analysis tools are used to analyze the code structure and extract the code dependency graph. For example, SonarQube or PMD (Programming Mistake Detector) is used to perform static code analysis on the current version of the code to obtain the initial dependency graph. By analyzing the syntax and semantic structure of the code, the dependencies between classes, methods, variables, etc. are identified and displayed in a graphical manner. Automated scripts or tools are configured, such as SonarQube CLI (Command Line Interface), to run static analysis regularly and update the initial dependency graph. Based on the static analysis results, the initial dependency graph of the code is generated using a graph database, such as Neo4j, and the initial dependency graph is stored in the dependency database. On the other hand, runtime analysis tools such as JaCoCo and Dynatrace can be used to perform dynamic code analysis on the current version of the code to obtain runtime dependencies including code execution paths and actual call relationships.

[0054] In this embodiment, the target dependency graph is obtained based on the initial dependency graph, the runtime dependency, and the current change details, including: merging the initial dependency graph and the runtime dependency to obtain a merged dependency graph, and annotating the merged dependency graph accordingly based on the current change details to obtain a target dependency graph. In the process of merging the initial dependency graph and the runtime dependency to obtain a merged dependency graph, data cleaning, data mapping, data fusion and other operations are also required to obtain a merged dependency graph. The current change details include not only the change data, but also the specific location of the change data, which is annotated in the merged dependency graph according to the change details to obtain a target dependency graph.

[0055] In this embodiment, the merging of the initial dependency graph and the runtime dependency to obtain a merged dependency graph includes: cleaning redundant data between the initial dependency graph and the runtime dependency to obtain a cleaned dependency graph and cleaned dependencies; establishing a mapping relationship between the cleaned dependency graph and the cleaned dependencies, so as to merge the cleaned dependencies into the cleaned dependency graph based on the mapping relationship to obtain a merged dependency graph, and displaying the merged dependency graph on a preset display interface. Data cleaning refers to cleaning runtime and static dependency data to remove duplicate, erroneous or irrelevant information, that is, cleaning redundant data between the initial dependency graph and the runtime dependency. Data mapping refers to establishing a mapping relationship between runtime dependencies and static dependencies, and establishing a mapping relationship between the cleaned dependency graph and the cleaned dependencies, specifically, it is necessary to match the corresponding elements in the runtime and static data through identifiers. Data fusion refers to the fusion of the mapped runtime dependency data into the static dependency graph, that is, the cleaned dependencies are merged into the cleaned dependency graph based on the mapping relationship to obtain the merged dependency graph. Specifically, the structure of the static dependency graph needs to be modified to include the new information in the runtime data. The merged dependency graph is displayed in the preset display interface. Using data visualization tools can help developers better understand the structure and content of the dependency graph. These tools usually provide rich interactive functions such as zooming, searching, filtering, etc.

[0056] In this embodiment, after obtaining static code analysis and dynamic code analysis of the current version code to obtain an initial dependency graph and a runtime dependency respectively, it also includes: generating a runtime dependency report based on the runtime dependency, and displaying the runtime dependency report on a preset display interface; performing a code security check on the runtime dependency report, and if the generated test result indicates that there is an abnormality in the current version code, generating an abnormality alarm, and displaying the abnormality alarm on the preset display interface. Configure automated scripts or tools to run dynamic analysis regularly and generate runtime dependency reports. Runtime dependency reports can intuitively show how system components depend on and interact with each other at runtime. This is crucial for system architects and developers, as it helps them gain a deep understanding of the overall structure of the system and how its parts work together. By analyzing runtime dependencies, you can identify possible performance bottlenecks or failure points in the system. For example, if a component exhibits delays or errors when processing a large number of requests, the report may reveal interaction problems between the component and other components, thereby helping developers locate the root cause of the problem. Dynamic analysis not only focuses on dependencies between components, but also detects the behavior of programs at runtime. Therefore, runtime dependency reports can also be used to assist in security analysis and vulnerability detection. By analyzing the interaction data between components, potential security vulnerabilities or malicious behavior patterns can be identified; configuring automated scripts or tools to run dynamic analysis regularly means that the system's operating status and dependency changes can be continuously monitored. When an anomaly or potential problem is detected, the alarm mechanism can be automatically triggered to notify relevant personnel in a timely manner for processing; for project management and decision-makers, runtime dependency reports provide important information about the system's health, performance, and security status. This information can serve as the basis for decision support and help management formulate reasonable project plans and resource allocation strategies.

[0057] Step S13: Use a graph traversal algorithm to traverse each dependency in the target dependency graph to obtain a propagation path affected by the current code change data, and use the target pre-trained model and the propagation path to determine the regression test scope of the current version of the code.

[0058] The graph traversal algorithm can be specifically a depth-first search (DFS) algorithm or a breadth-first search (BFS) algorithm. The dependency graph is a graph data structure, in which nodes represent components in the code (such as classes, modules, functions, etc.), and edges represent dependencies between these components. After merging runtime and static dependencies, this graph contains more comprehensive dependency information. When a component in the code base changes, this change may propagate to other components along the dependency graph. Therefore, by using the graph traversal algorithm to traverse each dependency in the target dependency graph, this propagation process can be simulated, and components that may be affected by the change and how the impact propagates can be predicted, thereby predicting the propagation path affected by the current code change data. Among them, the depth-first search searches the branches of the graph as deeply as possible until it reaches a leaf node or encounters a visited node. This algorithm is suitable for situations where a specific path or tree structure needs to be explored in depth. The breadth-first search starts from the starting node and traverses the nodes in the graph layer by layer, first visiting all neighbors of the starting node, and then expanding outward layer by layer. This algorithm is suitable for finding the shortest path or when you need to traverse the graph structure hierarchically. The traversal process is as follows:

[0059] 1) Starting node selection: Usually the starting node of the traversal is the component that has changed. Starting from this node, the algorithm traverses along the edges in the dependency graph;

[0060] 2) Traversal strategy: Depending on the selected DFS or BFS algorithm, the traversal process will gradually deepen or expand layer by layer along the path in the dependency graph. During the traversal process, the visited nodes and edges will be recorded to avoid repeated visits and infinite loops;

[0061] 3) Impact prediction: By traversing the dependency graph, it is possible to predict how changes propagate to other components along the dependency path, which helps developers understand the potential impact of the change and take appropriate measures to mitigate or eliminate these impacts.

[0062] In this embodiment, before using the target pre-trained model and the propagation path to determine the regression test scope of the current version of the code, it also includes: pre-processing the initial training data set to obtain the target training data set; wherein the initial training data set includes historical regression test results and corresponding historical code change data, and the pre-processing includes data cleaning and data normalization; using the target training data set to train the constructed initial pre-trained model, and using the gradient descent algorithm to update the weight parameters of the initial pre-trained model to obtain a target pre-trained model that meets the preset convergence conditions. The model training process refers to the process of adjusting the model parameters so that the model can correctly predict or classify according to the input data. This process includes the following key steps:

[0063] 1) Data preprocessing: including data cleaning, data conversion, data normalization and other operations to ensure data quality and consistency;

[0064] 2) Model selection: Select a suitable machine learning or deep learning model based on specific tasks and data characteristics;

[0065] 3) Model initialization: Initialize the model parameters to prepare for subsequent parameter adjustment;

[0066] 4) Loss function selection: Select an appropriate loss function to evaluate the predictive performance of the model;

[0067] 5) Model training: Use the training data set to continuously adjust the model parameters through optimization algorithms (such as gradient descent) to minimize the loss function, and finally obtain the target pre-trained model that meets the preset convergence conditions;

[0068] 6) Model evaluation: Use a validation set or a test set to evaluate the performance of the model to ensure that the model performs well on unseen data.

[0069] Furthermore, data cleaning only retains data directly related to the analysis objectives. Data that is irrelevant or not relevant to the analysis should be deleted or marked to avoid interference with the analysis results. Data cleaning ensures the authenticity, completeness and accuracy of the data. Data with errors, omissions or inconsistencies should be corrected or supplemented, and the consistency of data formats, naming rules, etc. should also be maintained. Data from different sources or formats should be processed uniformly to facilitate subsequent analysis and comparison, and duplicate data records should be removed to ensure the uniqueness of each record in the database, which helps avoid duplicate counting or misleading results during statistics and analysis. It should be noted that when cleaning data, a data backup and recovery mechanism should be ensured to prevent data loss or damage. The process of cleaning data should record detailed operation logs for subsequent data tracing and auditing. The cleaned data should be quality checked and verified to ensure that the accuracy and consistency of the data meet the needs of analysis. Among them, the process of determining data that is irrelevant or not very relevant to the analysis can be: clarify the goal and scope of the analysis, and then identify data that is irrelevant to these goals and scopes. These data may include irrelevant fields, records or data sets. For the identified irrelevant data, you can choose to delete or mark it, such as setting it to "invalid" or "ignore". Deletion can directly remove these data, while marking can ignore these data in subsequent analysis. By comparing the various fields or records in the data set, duplicate data can be identified. Duplicate data may be exactly the same, or may be the same in some fields and different in other fields. For duplicate data, you can choose to merge or delete. Merging is to integrate duplicate data records into one record, while deletion is to remove the duplicate parts and keep only one record.

[0070] Step S14: Integrate the test cases generated based on the regression test scope into the continuous integration deployment pipeline, so that the continuous integration deployment pipeline executes the test cases, completes the regression test of the current version of the code, and obtains the current regression test result.

[0071] After determining the scope of regression testing, it is necessary to select or design corresponding test cases based on the scope of regression testing to verify the correctness and stability of the changes. These test cases will constitute part of the regression test suite. According to the test strategy and the selected test cases, specific regression test cases are generated, which will be used for actual test execution. The test case generation process is: extract training data from the change record database and historical test results, build a training set, extract features such as the number of changed files, the number of changed lines, the type of change (new, modified, deleted), the historical test pass rate, etc., and use machine learning algorithms (such as decision trees and random forests) to train a suitable case generation model. The input is the change record, and the output is a recommended regression test case set. Combined with coverage data and regression test scope, the uncovered code paths are identified, and optimization algorithms (such as genetic algorithms and ant colony algorithms) are used to optimize the recommended test case set to ensure that all affected code paths are covered and redundant cases are deleted.

[0072] For example Figure 2 A specific regression test diagram shown in FIG. 1 integrates the execution process of regression test cases into the CI (Continuous Integration) / CD (Continuous Deployment, CD) pipeline. In the CI / CD (Continuous Integration / Continuous Deployment) pipeline, the determination of the test scope is usually completed before the pipeline starts or as part of the pipeline design. This scope determination process may include steps such as analyzing software changes, assessing the impact, formulating test strategies, and selecting or designing test cases. Once the test scope is determined and the corresponding regression test cases have been generated, these test cases can be integrated into the CI / CD pipeline, triggering the test execution by configuring the automatic execution script, and monitoring the test results in real time. In this way, whenever there is a new code submission or change occurs, the CI / CD pipeline will automatically execute these regression test cases to ensure that the changes do not introduce new problems and the overall quality of the software is maintained.

[0073] When new features are added to the software, regression test cases are used to verify that these new features work as expected while ensuring that they do not introduce any known or unknown errors. Regression testing has the following advantages: 1) Verification of fixable errors: For fixed errors, regression test cases ensure that these errors have indeed been resolved and that the repair process has not introduced new problems. This is done by re-executing previously failed test cases. 2) Prevent regression errors: The core purpose of regression testing is to prevent "regression errors", that is, problems with originally working functions due to code changes. By generating and executing regression test cases, such problems can be discovered and fixed early. 3) Improve software quality and reliability: Comprehensive test coverage: The generated regression test cases should cover all aspects of the software as much as possible, including main functions, edge cases, and exception handling. This helps ensure that the software works stably in various situations. 4) Continuous quality monitoring: With the continuous iteration and update of the software, the regression test case library also needs to be continuously updated and maintained. By continuously executing regression tests, the changing trend of software quality can be monitored and improvement measures can be taken in a timely manner. 5) Support rapid iteration and release: Regression test cases are often used in conjunction with automated testing frameworks to improve test efficiency and accuracy. Automated testing can significantly shorten the test cycle and support rapid iteration and release of software. 6) Risk assessment: By executing regression test cases, the risk of software changes can be assessed. For high-risk changes, testing efforts can be strengthened or other risk management measures can be taken. 7) Assisted decision-making and planning: Test planning and resource allocation: The generated regression test cases can help the test team develop test plans and reasonably allocate test resources. For key functions and important changes, test resources can be prioritized to ensure their quality and stability. 8) Product release decision: The results of regression testing can be used as one of the important bases for product release decisions. Only when all important regression test cases pass the test can the software be considered to have met the release standards.

[0074] The beneficial effects of the present application are as follows: the present application collects the current code change data between the previous version code and the current version code of the software to be tested to generate the current change details; obtains static code analysis and dynamic code analysis for the current version code respectively to obtain the initial dependency graph and the runtime dependency respectively, and obtains the target dependency graph based on the initial dependency graph, the runtime dependency and the current change details; uses a graph traversal algorithm to traverse each dependency in the target dependency graph to obtain the propagation path affected by the current code change data, and uses the target pre-trained model and the propagation path to determine the regression test scope of the current version code; integrates the test cases generated based on the regression test scope into the continuous integration deployment pipeline, so that the continuous integration deployment pipeline executes the test cases, completes the regression test of the current version code, and obtains the current regression test results. It can be seen that this application combines the initial dependency graph obtained by static code analysis, the runtime dependency obtained by dynamic code analysis, and the current change details to generate a comprehensive target dependency graph, thereby improving the accuracy and coverage of change impact analysis. The application of graph traversal algorithms and target pre-training models can more accurately predict the scope affected by the current code change data, that is, the regression test scope of the current version of the code, ensuring that the test covers all affected code paths, automatically generating and optimizing regression test cases, reducing redundant testing, and improving testing efficiency. The regression testing process can be integrated into the continuous integration deployment pipeline to achieve automated test execution and result feedback, ensuring continuous improvement and optimization of the testing process, and being able to perform regression testing on the current version of the code in a timely manner.

[0075] See also Figure 3 As shown, the embodiment of the present application discloses a regression testing device, comprising:

[0076] The change generation module 11 is used to collect the current code change data between the previous version code and the current version code of the software to be tested to generate the current change details;

[0077] A relationship diagram acquisition module 12 is used to perform static code analysis and dynamic code analysis on the current version code to obtain an initial dependency diagram and a runtime dependency diagram, respectively, and obtain a target dependency diagram based on the initial dependency diagram, the runtime dependency diagram, and the current change details;

[0078] A scope determination module 13 is used to traverse each dependency in the target dependency graph using a graph traversal algorithm to obtain a propagation path affected by the current code change data, and determine the regression test scope of the current version of the code using a target pre-trained model and the propagation path;

[0079] The regression testing module 14 is used to integrate the test cases generated based on the regression testing scope into the continuous integration deployment pipeline, so that the continuous integration deployment pipeline executes the test cases, completes the regression testing of the current version of the code, and obtains the current regression testing results.

[0080] The beneficial effects of the present application are as follows: the present application collects the current code change data between the previous version code and the current version code of the software to be tested to generate the current change details; obtains static code analysis and dynamic code analysis for the current version code respectively to obtain the initial dependency graph and the runtime dependency respectively, and obtains the target dependency graph based on the initial dependency graph, the runtime dependency and the current change details; uses a graph traversal algorithm to traverse each dependency in the target dependency graph to obtain the propagation path affected by the current code change data, and uses the target pre-trained model and the propagation path to determine the regression test scope of the current version code; integrates the test cases generated based on the regression test scope into the continuous integration deployment pipeline, so that the continuous integration deployment pipeline executes the test cases, completes the regression test of the current version code, and obtains the current regression test results. It can be seen that this application combines the initial dependency graph obtained by static code analysis, the runtime dependency obtained by dynamic code analysis, and the current change details to generate a comprehensive target dependency graph, thereby improving the accuracy and coverage of change impact analysis. The application of graph traversal algorithms and target pre-training models can more accurately predict the scope affected by the current code change data, that is, the regression test scope of the current version of the code, ensuring that the test covers all affected code paths, automatically generating and optimizing regression test cases, reducing redundant testing, and improving testing efficiency. The regression testing process can be integrated into the continuous integration deployment pipeline to achieve automated test execution and result feedback, ensuring continuous improvement and optimization of the testing process, and being able to perform regression testing on the current version of the code in a timely manner.

[0081] Furthermore, an embodiment of the present application also provides an electronic device. Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.

[0082] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the regression testing method performed by the electronic device disclosed in any of the aforementioned embodiments.

[0083] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0084] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0085] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222 and data 223, etc. The storage method can be temporary storage or permanent storage.

[0086] Among them, the operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21, which can be Windows, Unix, Linux, etc. In addition to including a computer program that can be used to complete the regression test method performed by the electronic device disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks. In addition to data received by the electronic device and transmitted from an external device, the data 223 can also include data collected by its own input and output interface 25, etc.

[0087] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the regression testing method disclosed above. The specific steps of the method can refer to the corresponding contents disclosed in the above embodiments, and will not be repeated here.

[0088] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0089] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application. The steps of the method or algorithm described in conjunction with the embodiments disclosed herein can be implemented directly with hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in a random access memory (RAM), memory, read-only memory (ROM), electrically programmable EPROM (Erasable Programmable Read Only Memory), electrically erasable programmable EEPROM (Electrically Erasable Programmable read only memory), register, hard disk, removable disk, CD-ROM (Compact Disc Read-Only Memory), or any other form of storage medium known in the technical field.

[0090] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0091] The above is a detailed introduction to a regression testing method, device, equipment and medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A regression testing method, characterized in that: include: Collect the current code change data between the previous version code and the current version code of the software to be tested to generate the current change details; Obtaining static code analysis and dynamic code analysis for the current version code respectively to obtain an initial dependency graph and a runtime dependency respectively, and obtaining a target dependency graph based on the initial dependency graph, the runtime dependency, and the current change details; Using a graph traversal algorithm to traverse each dependency in the target dependency graph to obtain a propagation path affected by the current code change data, and using a target pre-trained model and the propagation path to determine a regression test scope for the current version of the code; The test cases generated based on the regression test scope are integrated into the continuous integration deployment pipeline, so that the continuous integration deployment pipeline executes the test cases, completes the regression test of the current version of the code, and obtains the current regression test result.

2. The regression testing method according to claim 1, characterized in that: The collecting of current code change data between the previous version code and the current version code of the software to be tested to generate current change details includes: Use the version control tool to collect the current code change data between the previous version code and the current version code of the software to be tested, and generate the current change details according to the current code change data, the user identity corresponding to the current code change data, the change time, the code change annotation and the location information.

3. The regression testing method according to claim 1, characterized in that: The obtaining performs static code analysis and dynamic code analysis on the current version code to obtain an initial dependency graph and a runtime dependency graph, respectively, including: Performing static code analysis on the current version code to identify dependencies of the current version code and obtain an initial dependency graph; When the software to be tested runs the current version code, dynamic code analysis is performed on the current version code to obtain runtime dependencies of the current version code.

4. The regression testing method according to claim 1, characterized in that: The obtaining of a target dependency graph based on the initial dependency graph, the runtime dependency, and the current change details includes: The initial dependency graph and the runtime dependency graph are merged to obtain a merged dependency graph, and the merged dependency graph is correspondingly annotated based on the current change details to obtain a target dependency graph.

5. The regression testing method according to claim 4, characterized in that: The merging of the initial dependency graph and the runtime dependency graph to obtain a merged dependency graph includes: Cleaning redundant data between the initial dependency graph and the runtime dependency to obtain a cleaned dependency graph and cleaned dependency relationships; A mapping relationship between the cleaned dependency graph and the cleaned dependency relationship is established, so as to merge the cleaned dependency relationship into the cleaned dependency graph based on the mapping relationship to obtain a merged dependency graph, and the merged dependency graph is displayed on a preset display interface.

6. The regression testing method according to any one of claims 1 to 5, characterized in that: Before determining the regression test scope of the current version code by using the target pre-trained model and the propagation path, the method further includes: Preprocessing the initial training data set to obtain a target training data set; wherein the initial training data set includes historical regression test results and corresponding historical code change data, and the preprocessing includes data cleaning and data normalization; The constructed initial pre-training model is trained using the target training data set, and the weight parameters of the initial pre-training model are updated using a gradient descent algorithm to obtain a target pre-training model that meets a preset convergence condition.

7. The regression testing method according to claim 1, characterized in that: After the obtaining performs static code analysis and dynamic code analysis on the current version code to obtain an initial dependency graph and a runtime dependency graph, the method further includes: Generate a runtime dependency report according to the runtime dependency, and display the runtime dependency report on a preset display interface; A code security check is performed on the runtime dependency report. If the generated check result indicates that an abnormality exists in the current version code, an abnormality alarm is generated and displayed on the preset display interface.

8. A regression testing device, characterized in that: include: A change generation module is used to collect the current code change data between the previous version code and the current version code of the software to be tested to generate the current change details; A dependency graph acquisition module is used to perform static code analysis and dynamic code analysis on the current version code to obtain an initial dependency graph and a runtime dependency graph, respectively, and obtain a target dependency graph based on the initial dependency graph, the runtime dependency graph, and the current change details; A scope determination module, configured to traverse each dependency in the target dependency graph using a graph traversal algorithm to obtain a propagation path affected by the current code change data, and determine a regression test scope of the current version of the code using a target pre-trained model and the propagation path; The regression test module is used to integrate the test cases generated based on the regression test scope into the continuous integration deployment pipeline, so that the continuous integration deployment pipeline executes the test cases, completes the regression test of the current version of the code, and obtains the current regression test results.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the regression testing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein, when the computer program is executed by a processor, the steps of the regression testing method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Test case generation method and device, electronic equipment and readable storage medium

    CN120705056A

  • Regression test method and device, storage medium, electronic equipment and product

    CN121210329A

  • Test case accurate selection method, device and equipment based on dependency collection

    CN122432052A