Regression test case screening method, device, equipment, storage medium and product

CN119357059BActive Publication Date: 2026-10-16PEOPLE'S INSURANCE COMPANY OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411498504.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-24
Publication Date
2026-10-16
Estimated Expiration
2044-10-24

AI Technical Summary

Technical Problem

[0004]然而,由于代码的修改可能会引入新的功能,改变现有功能或移除某些功能,根据以上方法筛选出的测试用例不能覆盖新的功能

Benefits of technology

[0032]The regression test case screening method, apparatus, device, storage medium, and product provided in this application embodiment determine the set of methods to be regressed and the set of call relationships to be regressed for each test case based on the methods to be regressed and the call relationships to be regressed covered in the first call chain graph corresponding to each test case in the initial test case set. The union of the sets of methods to be regressed for all test cases is taken to obtain the first set of methods to be regressed corresponding to the initial test case set. The union of the sets of call relationships to be regressed for all test cases is taken to obtain the first set of call relationships to be regressed corresponding to the initial test case set. The complexity of the first call chain graph for each test case is iteratively calculated. The test case with the highest complexity is removed from the initial test case set. The methods to be regressed and the call relationships to be regressed covered by that test case in the first call chain graph corresponding to each test case are removed. The set of methods to be regressed corresponding to that test case is deleted from the first set of methods to be regressed, resulting in a second set of methods to be regressed. The set of call relationships to be regressed corresponding to that test case is deleted from the first set of call relationships to be regressed, resulting in a second set of call relationships to be regressed. When the second set of methods to be regressed or the second set of call relationships to be regressed is empty, a regression test case is obtained. Based on the first call chain diagram of each test case, the changed methods covered by each test case, the methods affected by the changes, and the call relationships between the methods are obtained. The complexity of the first call chain diagram corresponding to each test case is calculated, thereby determining the priority of each test case in the initial test case set. By extracting regression test cases in order of priority, regression test cases can be accurately screened. At the same time, when test resources are insufficient, it can provide a basis for decision-making to narrow down the scope of regression testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357059B_ABST
    Figure CN119357059B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a regression test case screening method, device, equipment, storage medium and product. The method comprises: determining each set of regression methods and each set of regression call relationships according to a first call chain graph of each use case; performing a union operation on the set of regression methods and the set of regression call relationships of all use cases to obtain a first set of regression methods and a first set of regression call relationships; iteratively calculating the complexity of the first call chain graph of each use case; removing the use case with the highest complexity and the regression methods and regression call relationships covered by the use case in the first call chain graph of all use cases, and removing the set of regression methods and the set of regression call relationships corresponding to the use case in the first set of regression methods and the first set of regression call relationships; if the sets after removal are all empty sets, ending the iteration process, and determining all removed use cases as regression test cases. The method is used to achieve the effect of accurately screening regression test cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software testing technology, and in particular to a regression test case screening method, apparatus, device, storage medium, and product. Background Technology

[0002] In software development and maintenance, regression testing is a crucial method to ensure that new or modified code does not introduce new defects. As software scales, the number of regression test cases also increases significantly, leading to increased testing costs and time. Therefore, accurately selecting regression test cases while maintaining test coverage becomes an important challenge.

[0003] In existing technologies, test cases are prioritized based on factors that testers consider important, such as the importance of the functional modules corresponding to the test cases, the number of defects associated with the test cases, the number of associated test requirements, and the severity of associated defects. These factors are combined with the weights set by the testers to calculate the priority of the test cases. Regression test cases are then selected based on the priority of each test case.

[0004] However, since code modifications may introduce new features, change existing features, or remove certain features, the test cases selected using the above methods may not cover the new features. Summary of the Invention

[0005] This application provides a method, apparatus, device, storage medium, and product for screening regression test cases, in order to achieve the effect of accurately screening regression test cases.

[0006] In a first aspect, embodiments of this application provide a regression test case screening method applied to a computer device, comprising: obtaining an initial test case set and a first call chain graph of each test case in the initial test case set; determining the set of methods to be regressed and the set of call relationships to be regressed corresponding to each test case based on the methods to be regressed and the call relationships to be regressed covered in the first call chain graph of each test case; performing a union operation on the sets of methods to be regressed for all test cases to obtain a first set of methods to be regressed; performing a union operation on the sets of call relationships to be regressed for all test cases to obtain a first set of call relationships to be regressed; iteratively executing the following steps based on the first call chain graph: calculating the complexity of the first call chain graph of each test case; removing the test case with the highest complexity from the initial test case set to obtain an updated test case set; removing the methods to be regressed and the call relationships to be regressed covered by the test cases from the first call chain graphs corresponding to all test cases in the updated test case set; removing the sets of methods to be regressed corresponding to the test cases from the first set of methods to be regressed to obtain a second set of methods to be regressed; removing the sets of call relationships to be regressed corresponding to the test cases from the first set of call relationships to be regressed to obtain a second set of call relationships to be regressed; and determining whether both the second set of methods to be regressed and the second set of call relationships to be regressed are empty sets. If both the second set of methods to be regressed and the second set of call relationships to be regressed are empty sets, then the iteration process ends, and all the discarded test cases are determined as regression test cases.

[0007] In one possible implementation, before both the second set of methods to be regressed and the second set of call relations to be regressed are empty sets, the process further includes: if only the second set of methods to be regressed is empty, then all the eliminated test cases are determined as the minimum set of regression test cases, and the iteration process continues; if only the second set of call relations to be regressed is empty, then all the eliminated test cases are determined as the optimal set of regression test cases, and the iteration process continues.

[0008] In one possible implementation, if both the second set of methods to be regressed and the second set of call relationships to be regressed are empty sets, the iteration process ends, and all the eliminated test cases are determined as regression test cases, including: continuing the iteration process, if both the second set of methods to be regressed and the second set of call relationships to be regressed are empty sets, the iteration process ends; determining the priority of each eliminated test case according to the order in which they are eliminated; and determining the regression test cases according to the priority.

[0009] In one possible implementation, obtaining an initial test case set and a first call chain graph for each test case in the initial test case set includes: obtaining basic test cases of the software under test and the corresponding code of the software under test; determining the initial test case set based on the mapping relationship between the basic test cases and the code; performing method call chain analysis on the initial test case set to construct a directed call chain graph corresponding to each test case, wherein nodes in the directed call chain graph are methods called by each test case, and edges are the call relationships between methods, wherein methods include modified methods and non-modified methods; in each directed call chain graph, iteratively removing nodes with an out-degree of 0 and edges pointing to nodes in the non-modified method nodes, and determining the remaining non-modified methods as modified methods; determining the first call chain graph based on the modified methods and modified methods, as well as the call relationships between the modified methods and modified methods.

[0010] In one possible implementation, the formula for calculating the complexity of the first call chain graph for each use case is:

[0011]

[0012] In the formula, P i F represents the complexity of the first call chain graph for any use case. i E represents the method invoked by any use case. i This indicates the calling relationship between methods invoked by any use case.

[0013] Secondly, embodiments of this application provide a regression test case screening device, applied to a computer device, comprising:

[0014] The information acquisition module is used to acquire the initial test case set and the first call chain diagram of each test case in the initial test case set.

[0015] The module for determining the set of regression for each use case is used to determine the set of regression methods and the set of regression calls corresponding to each use case based on the regression methods and regression call relationships covered in the first call chain diagram of each use case.

[0016] The module for determining the first set of methods to be regressed is used to perform a union operation on the set of methods to be regressed for all test cases to obtain the first set of methods to be regressed.

[0017] The module for determining the first set of call relationships to be regressed is used to perform a union operation on the set of call relationships to be regressed for all test cases to obtain the first set of call relationships to be regressed.

[0018] The iterative execution module is used to iteratively execute the following steps based on the first call chain graph.

[0019] The iterative execution module includes:

[0020] The complexity calculation unit is used to calculate the complexity of the first call chain graph for each use case.

[0021] The test case set update unit is used to remove the most complex test cases from the initial test case set to obtain an updated test case set.

[0022] The call chain graph update unit is used to remove the methods to be regressed and the call relationships to be regressed that are covered by the test cases in the first call chain graph corresponding to all test cases in the update test case set.

[0023] The second set of methods to be regressed is determined by removing the set of methods to be regressed corresponding to the test cases from the first set of methods to be regressed, thereby obtaining the second set of methods to be regressed.

[0024] The second set of call relationships to be regressed is determined by removing the set of call relationships to be regressed corresponding to the test cases from the first set of call relationships to be regressed, thereby obtaining the second set of call relationships to be regressed.

[0025] The empty set judgment unit is used to determine whether both the second set of methods to be regressed and the second set of call relations to be regressed are empty sets.

[0026] The regression test case determination module is used to end the iteration process if both the second set of methods to be regressed and the second set of call relationships to be regressed are empty sets, and to determine all the discarded test cases as regression test cases.

[0027] Thirdly, embodiments of this application provide a computer device, including: a memory and a processor;

[0028] The memory stores the instructions that the computer executes;

[0029] The processor executes computer execution instructions stored in memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.

[0030] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.

[0031] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.

[0032] The regression test case screening method, apparatus, device, storage medium, and product provided in this application embodiment determine the set of methods to be regressed and the set of call relationships to be regressed for each test case based on the methods to be regressed and the call relationships to be regressed covered in the first call chain graph corresponding to each test case in the initial test case set. The union of the sets of methods to be regressed for all test cases is taken to obtain the first set of methods to be regressed corresponding to the initial test case set. The union of the sets of call relationships to be regressed for all test cases is taken to obtain the first set of call relationships to be regressed corresponding to the initial test case set. The complexity of the first call chain graph for each test case is iteratively calculated. The test case with the highest complexity is removed from the initial test case set. The methods to be regressed and the call relationships to be regressed covered by that test case in the first call chain graph corresponding to each test case are removed. The set of methods to be regressed corresponding to that test case is deleted from the first set of methods to be regressed, resulting in a second set of methods to be regressed. The set of call relationships to be regressed corresponding to that test case is deleted from the first set of call relationships to be regressed, resulting in a second set of call relationships to be regressed. When the second set of methods to be regressed or the second set of call relationships to be regressed is empty, a regression test case is obtained. Based on the first call chain diagram of each test case, the changed methods covered by each test case, the methods affected by the changes, and the call relationships between the methods are obtained. The complexity of the first call chain diagram corresponding to each test case is calculated, thereby determining the priority of each test case in the initial test case set. By extracting regression test cases in order of priority, regression test cases can be accurately screened. At the same time, when test resources are insufficient, it can provide a basis for decision-making to narrow down the scope of regression testing. Attached Figure Description

[0033] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0034] Figure 1 A schematic diagram illustrating a scenario for the regression test case selection method provided in this application embodiment;

[0035] Figure 2 A flowchart illustrating the regression test case selection method provided in this application embodiment;

[0036] Figure 3 This is a schematic diagram of the structure of the regression test case screening device provided in the embodiments of this application;

[0037] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of this application.

[0038] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0039] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0040] First, let me explain the terms used in this application:

[0041] Regression testing: A type of software testing designed to verify that modifications to the code (such as fixing defects, enhancing functionality, or other changes) do not introduce new errors or cause existing functionality to fail.

[0042] Baseline test cases: These typically refer to a set of basic test cases in software testing, used to verify whether the core functions of a software system are working properly.

[0043] Change methods: These are the methods used to modify or update software during the software development process. Change methods involve code refactoring, adding or removing features, performance optimization, etc.

[0044] The method affected by the change: the method that directly or indirectly calls the change method.

[0045] To clearly understand the technical solution of this application, we will first provide a detailed introduction to the solutions of existing technologies. Some systems with long business processes and complex processing logic accumulate a large number of basic test cases after long-term iterations. Precise testing identifies the method sets affected by version changes by scanning for differences between system versions and combining this with call chain analysis. It then filters out the basic test cases affected by version changes by establishing a mapping relationship between code and test cases, thereby narrowing the scope of regression testing. However, when the total number of basic test cases reaches tens of thousands, the number of test cases filtered by precise testing may still exceed the testing scope that test resources can cover. Furthermore, these test cases all satisfy the condition that at least one of the methods they cover has changed or that at least one method's dependent code has changed. It seems that every test case needs to be included in regression testing; however, exhaustive testing is inefficient and impractical. Therefore, a matching, universally applicable test case recommendation strategy is needed to prioritize test cases.

[0046] To address the aforementioned technical problems, the inventors devised a method to analyze the call chain of the recommended test cases for accurate testing, obtaining an initial test case set and a first call chain diagram for each test case. Based on the methods to be regressed and the call relationships to be regressed covered in the first call chain diagram of each test case, the set of methods to be regressed and the set of call relationships to be regressed corresponding to each test case are determined. A union operation is performed on the set of methods to be regressed for all test cases to obtain the first set of methods to be regressed corresponding to the initial test case set. A union operation is performed on the set of call relationships to be regressed for all test cases to obtain the first set of call relationships to be regressed corresponding to the initial test case set. Based on the first call chain diagram, the first call relationship of each test case is iteratively calculated. Using the complexity of a chain graph, the most complex test cases are removed from the initial test case set to obtain an updated test case set. In the first call chain graph corresponding to all test cases in the updated test case set, the methods and call relationships to be regressed covered by the test cases are removed. The set of methods to be regressed corresponding to these test cases is then removed from the first set of methods to be regressed, resulting in a second set of methods to be regressed. Similarly, the set of call relationships to be regressed corresponding to these test cases is removed from the first set of call relationships to be regressed, resulting in a second set of call relationships to be regressed. The iteration continues until both the second set of methods to be regressed and the second set of call relationships to be regressed are empty. All removed test cases are then identified as regression test cases. By considering the complexity of the first call chain graph for each test case and prioritizing each test case, precise filtering of regression test cases can be achieved. Furthermore, when test resources are insufficient, this provides a basis for narrowing the scope of regression testing.

[0047] Based on the above-mentioned inventive discovery, the inventor has proposed the technical solution of this application.

[0048] Figure 1 This is a schematic diagram illustrating a scenario for the regression test case filtering method provided in an embodiment of this application, such as... Figure 1 As shown, the specific application scenarios of this application include: receiving device 101, processor 102 and display device 103.

[0049] It is understood that the structure illustrated in the embodiments of this application does not constitute a specific limitation on the regression test case screening method. In other feasible embodiments of this application, the above architecture may include more or fewer components than illustrated, or combine some components, or split some components, or arrange different components, which can be determined according to the actual application scenario and is not limited here. Figure 1 The components shown can be implemented in hardware, software, or a combination of both.

[0050] In the specific implementation process, the receiving device 101 can be an input / output interface or a communication interface, used to obtain the initial use case set and the first call chain diagram of each use case in the initial use case set.

[0051] The processor 102 can determine the set of methods to be regressed and the set of call relationships to be regressed for each test case based on the methods to be regressed and the call relationships to be regressed covered in the first call chain graph of each test case; perform a union operation on the sets of methods to be regressed for all test cases to obtain the first set of methods to be regressed; perform a union operation on the sets of call relationships to be regressed for all test cases to obtain the first set of call relationships to be regressed; and iteratively execute the following steps based on the first call chain graph: calculate the complexity of the first call chain graph of each test case; remove the test case with the highest complexity from the initial test case set to obtain the updated test case set; remove the methods to be regressed and the call relationships to be regressed covered by the test cases from the first call chain graphs corresponding to all test cases in the updated test case set; remove the sets of methods to be regressed corresponding to the test cases from the first set of methods to be regressed to obtain the second set of methods to be regressed; remove the sets of call relationships to be regressed corresponding to the test cases from the first set of call relationships to be regressed to obtain the second set of call relationships to be regressed; determine whether the second set of methods to be regressed and the second set of call relationships to be regressed are both empty sets; if the second set of methods to be regressed and the second set of call relationships to be regressed are both empty sets, then end the iteration process and determine all the removed test cases as regression test cases.

[0052] The display device 103 can be used to display the selected regression test cases.

[0053] The display device can also be a touch screen, used to receive user commands while displaying the above content, so as to realize the operation interaction with the user.

[0054] It should be understood that the aforementioned processor can be implemented by reading instructions from memory and executing those instructions, or it can be implemented through chip circuitry.

[0055] The technical solution of this application and how it solves the above-mentioned technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.

[0056] Figure 2 This is a flowchart illustrating the regression test case selection method provided in an embodiment of this application. Figure 2 As shown, the method includes:

[0057] S201: Obtain the initial use case set and the first call chain diagram of each use case in the initial use case set.

[0058] Specifically, the methods for obtaining the initial use case set and the first call chain diagram of each use case include Sa1~Sa5:

[0059] Sa1: Obtain the basic test cases and corresponding code of the software under test.

[0060] Specifically, a version control system is used to access the code repository of the software under test. The code corresponding to the software under test is obtained by cloning or checking out the code repository. The version control system contains the basic test cases of the software under test.

[0061] Sa2: Determine the initial test case set based on the mapping relationship between the baseline test cases and the code.

[0062] The initial test case set should be able to verify the correctness and stability of the core functions.

[0063] Specifically, code coverage analysis tools are used to identify the code paths covered by basic test cases, and test cases that call the modified methods are selected as the initial test case set.

[0064] Sa3: Perform method call chain analysis on the initial test case set and construct a directed graph of the call chain corresponding to each test case. In the directed graph of the call chain, the nodes are the methods called by each test case, and the edges are the call relationships between methods. The methods include modified methods and non-modified methods.

[0065] Among them, the changed method refers to the method that is modified or added during code changes.

[0066] Specifically, static or dynamic code analysis tools are used to collect method call information. During test case execution, the method call sequence is traced through logging or a debugger. For each test case in the initial test case set, the sequence of methods called during its execution is recorded, ensuring that all methods called directly or indirectly are included. A directed graph of call chains is constructed for each test case, where each node represents a method and edges represent the call relationships between methods.

[0067] For example, if method A calls method B, a directed edge is drawn from node A to node B in the directed graph of the call chain corresponding to the use case.

[0068] Sa4: In the directed graph of each call chain, iteratively remove nodes with an out-degree of 0 and edges pointing to nodes in the non-modified method nodes, and determine the remaining non-modified methods as the methods affected by the change.

[0069] Specifically, after drawing the directed graph of call chains for all use cases, all non-modified method nodes are searched in each directed graph. If any non-modified method node has an out-degree of 0 (meaning it does not call any other methods), these non-modified method nodes with an out-degree of 0, along with their adjacent edges, are removed from the directed graph of that call chain. This process is repeated until no more non-modified method nodes with an out-degree of 0 can be removed. After the iterative removal process, the remaining non-modified methods are identified as the methods affected by the change.

[0070] Sa5: Determine the first call chain diagram based on the change method, the change-affected method, and the call relationship between the change method and the change-affected method.

[0071] Specifically, the directed graph of the call chain formed by the changed methods and the methods affected by the changes after the iterative elimination process is completed, as well as the call relationships between the changed methods and the methods affected by the changes, is determined as the first call chain graph.

[0072] S202: Based on the methods to be regressed and the call relationships to be regressed covered in the first call chain diagram of each use case, determine the set of methods to be regressed and the set of call relationships to be regressed corresponding to each use case.

[0073] The methods to be regressed include modified methods and non-modified methods.

[0074] Specifically, the first call chain diagram for each use case illustrates the changed methods and methods affected by the changes during the execution of that use case, as well as the call relationships between them. Within the first call chain diagram for each use case, all non-changed and changed methods are identified, and all changed and non-changed methods are summarized to obtain the set of methods to be regressed for each use case. The call relationships between all methods are identified, and all call relationships are summarized to obtain the set of call relationships to be regressed for each use case.

[0075] S203: Perform a union operation on the set of methods to be regressed for all use cases to obtain the first set of methods to be regressed.

[0076] Specifically, an empty set is initialized, called the first set of methods to be regressed. For each test case's set of methods to be regressed, a union operation is performed with the first set of methods to be regressed. In the set operation, it is ensured that each method to be regressed appears only once.

[0077] S204: Perform a union operation on the set of call relationships to be regressed for all use cases to obtain the first set of call relationships to be regressed.

[0078] Specifically, an empty set is initialized, called the first set of call relationships to be regressed. For each test case's set of methods to be regressed, a union operation is performed with the first set of call relationships to be regressed. In the set operation, it is ensured that each call relationship to be regressed appears only once.

[0079] S205: Based on the first call chain graph, iteratively execute the following steps:

[0080] S051: Calculate the complexity of the first call chain graph for each use case.

[0081] The complexity includes both the method to be regressed and the call relationships to be regressed.

[0082] Specifically, based on the methods and call relationships in the first call chain diagram of each use case, the complexity of the first call chain diagram is determined, and the calculation formula is: P i =F i +E i .

[0083] In the formula, P i F represents the complexity of the first call chain graph for any use case. i E represents the method invoked by any use case. i This indicates the calling relationship between methods invoked by any use case.

[0084] S052: Remove the most complex use case from the initial use case set to obtain the updated use case set.

[0085] Specifically, the use case with the highest complexity in the first call chain graph of each use case is identified as the highest priority use case, and this use case is removed from the initial use case set to obtain the updated use case set.

[0086] S053: In the first call chain graph corresponding to all test cases in the updated test case set, remove the methods to be regressed and the call relationships to be regressed that are covered by the test cases.

[0087] Specifically, for all use cases in the updated use case set that removes the use case, if the method to be regressed and the call relationship to be regressed in the first call chain graph of any use case involve the method to be regressed and the call relationship to be regressed covered by the use case, then the method to be regressed and the call relationship to be regressed covered by the use case are removed from the first call chain graph of any use case.

[0088] S054: Remove the set of methods to be regressed corresponding to the test cases from the first set of methods to be regressed to obtain the second set of methods to be regressed.

[0089] Specifically, the second set of methods to be regressed is obtained by removing all methods corresponding to the highest priority use cases from the first set of methods to be regressed.

[0090] S055: Remove the set of call relationships corresponding to the test cases from the first set of call relationships to be regressed to obtain the second set of call relationships to be regressed.

[0091] Specifically, the second set of call relationships to be regressed is obtained by removing all call relationships corresponding to the highest priority use cases from the first set of call relationships to be regressed.

[0092] S056: Determine whether both the second set of methods to be regressed and the second set of call relations to be regressed are empty sets.

[0093] Specifically, after obtaining the second set of methods to be regressed and the second set of call relationships to be regressed, it is checked whether there are any methods in the second set of methods to be regressed and whether there are any call relationships in the second set of call relationships to be regressed. If there are no methods in the second set of methods to be regressed or no call relationships in the second set of call relationships to be regressed, it is determined that both the second set of methods to be regressed and the second set of call relationships to be regressed are empty sets.

[0094] S057: If both the second set of methods to be regressed and the second set of call relationships to be regressed are empty sets, then the iteration process ends and all the discarded test cases are determined as regression test cases.

[0095] Specifically, this includes steps Sb1 to Sb3:

[0096] Sb1: If, during the continued iteration process, both the second set of methods to be regressed and the second set of call relationships to be regressed are empty sets, then the iteration process ends.

[0097] Sb2: Determine the priority of each excluded test case based on the order in which they are excluded.

[0098] Sb3: Determine regression test cases based on priority.

[0099] Specifically, during the continued iteration process, if both the second set of methods to be regressed and the second set of call relationships to be regressed are empty sets, it means that all methods and call relationships have been covered, the iteration process ends, and the removed test cases are used as the selected regression test cases. The order in which test cases are removed in the whole process is the priority order of regression test cases.

[0100] In summary, based on the methods and call relationships to be regressed covered in the first call chain graph corresponding to each test case in the initial test case set, the set of methods to be regressed and the set of call relationships to be regressed for each test case are determined. The union of the sets of methods to be regressed for all test cases is taken to obtain the first set of methods to be regressed corresponding to the initial test case set. The union of the sets of call relationships to be regressed for all test cases is taken to obtain the first set of call relationships to be regressed corresponding to the initial test case set. The complexity of the first call chain graph for each test case is iteratively calculated. The test case with the highest complexity is removed from the initial test case set. The methods and call relationships to be regressed covered by that test case in the first call chain graph corresponding to each test case are removed. The set of methods to be regressed corresponding to that test case is deleted from the first set of methods to be regressed, resulting in the second set of methods to be regressed. The set of call relationships to be regressed corresponding to that test case is deleted from the first set of call relationships to be regressed, resulting in the second set of call relationships to be regressed. When the second set of methods to be regressed or the second set of call relationships to be regressed is empty, the regression test case is obtained. Based on the first call chain diagram of each test case, the changed methods covered by each test case, the methods affected by the changes, and the call relationships between the methods are obtained. The complexity of the first call chain diagram corresponding to each test case is calculated, thereby determining the priority of each test case in the initial test case set. By extracting regression test cases in order of priority, regression test cases can be accurately screened. At the same time, when test resources are insufficient, it can provide a basis for decision-making to narrow down the scope of regression testing.

[0101] In another embodiment of this application, before determining that both the second set of methods to be regressed and the second set of call relations to be regressed are empty sets, steps S301-S302 are further included:

[0102] S301: If only the second set of methods to be regressed is empty, then all the eliminated test cases are determined as the minimum set of regression test cases, and the iteration process continues.

[0103] Specifically, if the second set of methods to be regressed is initially empty, then all the eliminated use cases are determined as the minimum set of regression use cases, and the iterative process continues.

[0104] S302: If only the second set of regression calls is empty, then all the removed test cases are determined as the optimal set of regression test cases, and the iteration process continues.

[0105] Specifically, if the second set of regression call relationships is initially empty, then all the eliminated test cases are determined as the optimal set of regression test cases, and the iterative process continues.

[0106] In summary, when only the second set of methods to be regressed or the second set of call relationships to be regressed is empty, comprehensive coverage of test cases in regression testing cannot be guaranteed. Therefore, when only the second set of methods to be regressed or the second set of call relationships to be regressed is empty, the iteration process is continued. The complexity of the first call chain diagram of each test case is calculated based on the regressed methods or call relationships in the first call chain diagram of each test case until the second set of methods to be regressed or the second set of call relationships to be regressed is empty. This ensures comprehensive coverage of regression test cases in regression testing and improves the quality of software testing.

[0107] Figure 3 This is a schematic diagram of the structure of the regression test case screening device provided in the embodiments of this application, as shown below. Figure 3 As shown, the device includes: an information acquisition module 10, a test case set determination module 20, a first set of methods to be regressed module 30, a first set of call relationships to be regressed module 40, and an iterative execution module 50. The iterative execution module 50 includes a complexity calculation unit 501, a test case set update unit 502, a call chain graph update unit 503, a second set of methods to be regressed module 504, a second set of call relationships to be regressed module 505, an empty set judgment unit 506, and a regression test case determination unit 507.

[0108] The information acquisition module 10 is used to acquire the initial test case set and the first call chain diagram of each test case in the initial test case set.

[0109] The module 20 for determining the set of regression for each use case is used to determine the set of regression methods and the set of regression calls corresponding to each use case based on the regression methods and regression call relationships covered in the first call chain diagram of each use case.

[0110] The first regression method set determination module 30 is used to perform a union operation on the regression method sets of all test cases to obtain the first regression method set.

[0111] The first regression call relationship set determination module 40 is used to perform a union operation on the regression call relationship sets of all test cases to obtain the first regression call relationship set.

[0112] The iterative execution module 50 is used to iteratively execute the following steps based on the first call chain graph.

[0113] The iterative execution module 50 includes:

[0114] Complexity calculation unit 501 is used to calculate the complexity of the first call chain graph for each use case.

[0115] The use case set update unit 502 is used to remove the most complex use case from the initial use case set to obtain an updated use case set.

[0116] Call chain graph update unit 503 is used to remove the methods to be regressed and the call relationships to be regressed that are covered by the test cases in the first call chain graph corresponding to all test cases in the update test case set.

[0117] The second set of methods to be regressed is determined by the second set of methods to be regressed, which is used to remove the set of methods to be regressed corresponding to the test cases from the first set of methods to be regressed.

[0118] The second set of call relationships to be regressed is determined by the second set of call relationships to be regressed by removing the call relationships to be regressed corresponding to the test cases from the first set of call relationships to be regressed.

[0119] The empty set judgment unit 506 is used to determine whether both the second set of methods to be regressed and the second set of call relations to be regressed are empty sets.

[0120] The regression test case determination unit 507 is used to end the iteration process if both the second set of methods to be regressed and the second set of call relationships to be regressed are empty sets, and to determine all the eliminated test cases as regression test cases.

[0121] In one possible implementation, the regression test case determination unit 507 is specifically used to continue the iteration process, and if both the second set of methods to be regressed and the second set of call relationships to be regressed are empty, then the iteration process ends; the priority of each case to be removed is determined according to the order in which the cases are removed; and the regression test cases are determined according to the priority.

[0122] In one possible implementation, the iterative execution module 50 further includes a continuing execution unit, which is used to determine all the eliminated test cases as the minimum regression test case set and continue the iterative process if only the second set of methods to be regressed is empty; and to determine all the eliminated test cases as the optimal regression test case set and continue the iterative process if only the second set of call relations to be regressed is empty.

[0123] In one possible implementation, the information acquisition module 10 is specifically used to acquire the basic test cases of the software under test and the corresponding code of the software under test; determine the initial test case set based on the mapping relationship between the basic test cases and the code; perform method call chain analysis on the initial test case set to construct a directed graph of call chains corresponding to each test case, wherein the nodes in the directed graph of call chains are the methods called by each test case, and the edges are the call relationships between methods, wherein the methods include modified methods and non-modified methods; in each directed graph of call chains, iteratively remove nodes with an out-degree of 0 and edges pointing to nodes in the non-modified method nodes, and determine the remaining non-modified methods as modified methods; determine the first call chain graph based on the modified methods and modified methods, as well as the call relationships between the modified methods and modified methods.

[0124] In one possible implementation, the complexity calculation unit 501 calculates the complexity of the first call chain graph after each use case update using the following formula: P i =F i +E i

[0125] In the formula, P i F represents the complexity of the first call chain graph for any use case. i E represents the method invoked by any use case. i This indicates the calling relationship between methods invoked by any use case.

[0126] The regression test case screening device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0127] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of this application. For example... Figure 4 As shown, the computer device provided in this embodiment includes at least one processor 401 and a memory 402. Optionally, the computer device further includes a communication component 403. The processor 401, memory 402, and communication component 403 are connected via a bus 404.

[0128] In a specific implementation, at least one processor 401 executes computer execution instructions stored in memory 402, causing at least one processor 401 to perform the above-described method.

[0129] The specific implementation process of processor 401 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0130] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0131] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.

[0132] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0133] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0134] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.

[0135] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0136] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0137] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0138] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0139] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0140] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0141] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0142] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

Claims

1. A method for selecting regression test cases, characterized in that, Applied to computer equipment, including: Obtain the baseline test cases for the software under test and the corresponding code for the software under test; Based on the mapping relationship between the base quantity test cases and the code, the code coverage analysis tool is used to identify the code paths covered by the base quantity test cases, and the test cases that call the changed method are determined as the initial test case set; Method call chain analysis is performed on the initial test case set. Static code analysis tools or dynamic code analysis tools are used to collect method call information. During test case execution, the method call order is traced through log recording or debugger. For each test case in the test case set, a directed graph of the call chain corresponding to each test case is constructed. In the directed graph of the call chain, the nodes are the methods called by each test case, and the edges are the call relationships between the methods. The methods include modified methods and non-modified methods. In the directed graph of each call chain, iteratively remove nodes with an out-degree of 0 and edges pointing to the nodes in the non-change method nodes, and determine the remaining non-change methods as change-affected methods; Based on the change method and the change-affecting method, as well as the calling relationship between the change method and the change-affecting method, a first call chain diagram is determined; Based on the methods to be regressed and the call relationships to be regressed covered in the first call chain diagram of each use case, determine the set of methods to be regressed and the set of call relationships to be regressed corresponding to each use case; Perform a union operation on the set of methods to be regressed for all use cases to obtain the first set of methods to be regressed; Perform a union operation on the set of call relationships to be regressed for all the use cases to obtain the first set of call relationships to be regressed; Based on the first call chain graph, the following steps are executed iteratively: Calculate the complexity of the first call chain graph for each of the aforementioned use cases; The most complex use case is removed from the initial use case set to obtain the updated use case set; In the first call chain diagram corresponding to all test cases in the updated test case set, remove the methods to be regressed and the call relationships to be regressed covered by the test cases; The set of methods to be regressed corresponding to the test case is removed from the first set of methods to be regressed, resulting in the second set of methods to be regressed; Remove the set of call relationships corresponding to the use case from the first set of call relationships to be regressed to obtain the second set of call relationships to be regressed; Determine whether the second set of methods to be regressed and the second set of call relationships to be regressed are both empty sets; If only the second set of methods to be regressed is empty, then all the eliminated test cases are determined as the minimum set of regression test cases, and the iterative process continues. If only the second set of regression calls is empty, then all the eliminated test cases are determined as the optimal set of regression test cases, and the iterative process continues. If both the second set of methods to be regressed and the second set of call relationships to be regressed are empty, the iteration process ends. The priority of each test case to be removed is determined according to the order in which they are removed, and the regression test cases are determined according to the priority.

2. The method according to claim 1, characterized in that, The formula for calculating the complexity of the first call chain graph for each use case is: In the formula, P i F represents the complexity of the first call chain graph for any use case. i E represents the method invoked in any of the aforementioned use cases. i This indicates the calling relationship between methods invoked in any of the aforementioned use cases.

3. A regression test case screening device, characterized in that, Applied to computer equipment, including: The information acquisition module is used to acquire the basic test cases of the software under test and the corresponding code of the software under test; Based on the mapping relationship between the base quantity test cases and the code, the code coverage analysis tool is used to identify the code paths covered by the base quantity test cases, and the test cases that call the changed method are determined as the initial test case set; Method call chain analysis is performed on the initial test case set. Static code analysis tools or dynamic code analysis tools are used to collect method call information. During test case execution, the method call order is traced through log recording or debugger. For each test case in the test case set, a directed graph of the call chain corresponding to each test case is constructed. In the directed graph of the call chain, the nodes are the methods called by each test case, and the edges are the call relationships between the methods. The methods include modified methods and non-modified methods. In the directed graph of each call chain, iteratively remove nodes with an out-degree of 0 and edges pointing to the nodes in the non-change method nodes, and determine the remaining non-change methods as change-affected methods; Based on the change method and the change-affecting method, as well as the calling relationship between the change method and the change-affecting method, a first call chain diagram is determined; The module for determining the set of regression for each use case is used to determine the set of regression methods and the set of regression calls corresponding to each use case based on the regression methods and regression call relationships covered in the first call chain diagram of each use case. The module for determining the first set of methods to be regressed is used to perform a union operation on the set of methods to be regressed for all test cases to obtain the first set of methods to be regressed. The first regression call relationship set determination module is used to perform a union operation on the regression call relationship sets of all the test cases to obtain the first regression call relationship set; An iterative execution module is used to iteratively execute the following steps based on the first call chain graph; The iterative execution module includes: A complexity calculation unit is used to calculate the complexity of the first call chain graph for each use case; The use case set update unit is used to remove the most complex use case from the initial use case set to obtain an updated use case set; The call chain graph update unit is used to remove the methods to be regressed and the call relationships to be regressed covered by the use cases from the first call chain graph corresponding to all use cases in the updated use case set. The second set of methods to be regressed is determined by removing the set of methods to be regressed corresponding to the use case from the first set of methods to be regressed, thereby obtaining the second set of methods to be regressed. The second set of call relationships to be regressed is determined by removing the set of call relationships to be regressed corresponding to the use case from the first set of call relationships to be regressed, so as to obtain the second set of call relationships to be regressed. The empty set judgment unit is used to determine whether the second set of methods to be regressed and the second set of call relationships to be regressed are both empty sets. The execution unit is configured to determine all eliminated test cases as the minimum set of regression test cases if only the second set of methods to be regressed is empty, and continue to execute the iterative process. If only the second set of regression calls is empty, then all the eliminated test cases are determined as the optimal set of regression test cases, and the iterative process continues. The regression test case determination unit is used to end the iteration process if both the second set of methods to be regressed and the second set of call relationships to be regressed are empty, determine the priority of each case to be removed according to the order in which the cases are removed, and determine the regression test cases according to the priority.

4. A computer device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1 to 2.

5. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 2.

6. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1 to 2.