Regression test case determination method and device, storage medium and electronic equipment

The vector machine model extracts the characteristics of the target change code and determines the potential defect scores, and intelligently selects regression test cases, solving the problem of low writing efficiency of regression test cases in the existing technology, and achieving more efficient and accurate regression testing.

CN119473916APending Publication Date: 2025-02-18INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 6 Cited by

Patent Information

Application Number
CN202411792168.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The inefficiency of writing regression test cases in the prior art leads to incomplete coverage of regression tests and easy introduction of human errors, which increases the cost of software development and maintenance.

Method used

By obtaining the target change code of the target program, input it into the vector machine model, extracting code features and determining potential defect scores, and then intelligently selecting them from multiple test cases based on the potential defect score, code features and use case features of test cases. Regression test cases for testing target change code.

Benefits of technology

It realizes automated analysis and evaluation of the potential risks of code changes, intelligently selects and generates regression test cases, improves the efficiency and accuracy of writing regression test cases, and solves the problem of inefficiency in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473916A_ABST
    Figure CN119473916A_ABST
Patent Text Reader

Abstract

The invention discloses a regression test case determination method and device, a storage medium and electronic equipment, and relates to the field of artificial intelligence. The method comprises the steps of obtaining a target change code of a target program; the target change code is input into a vector machine model, code features of the target change code are extracted through the vector machine model, a potential defect score of the target change code is determined according to the code features, and the potential defect score is used for representing the probability that the target program is abnormal due to the target change code; and determining at least one regression test case for testing the target change code from the M test cases according to the potential defect score of the target change code, the code feature of the target change code and the case feature of each test case in the M test cases. The technical problem that in the prior art, the efficiency of compiling the regression test case is low is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and in particular, to a method, device, storage medium and electronic device for determining regression test cases. Background Art

[0002] In the life cycle of software development, regression testing plays a vital role. It ensures that the original functions of the software can still operate normally after modification or upgrade, and avoids the negative impact of changes introduced by the new version on the existing functions. Traditional regression test cases and test scope are usually manually formulated by test engineers based on software development documents and their own experience. However, with the continuous increase in the scale of software systems and the increasing complexity of business logic, this method that relies on manpower has exposed a series of problems.

[0003] First, manually writing regression test cases is time-consuming and inefficient. Testers need to spend a lot of time analyzing code changes, functional requirements, and potential impacts, which is particularly difficult in a fast-paced software development environment. Second, due to differences in tester experience, different test engineers may overlook certain key test scenarios, resulting in incomplete regression test coverage. In addition, manual operations are prone to human errors, such as selecting incorrect test data and omitting necessary test steps, which will affect the accuracy and reliability of the test.

[0004] In summary, the existing methods of writing regression test cases have significant problems such as low efficiency, which greatly limits the effectiveness of regression testing and increases the cost of software development and maintenance.

[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0006] The main purpose of the present application is to provide a method, device, storage medium and electronic device for determining a regression test case, so as to at least solve the technical problem of low efficiency in writing regression test cases in the prior art.

[0007] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a method for determining a regression test case is provided, comprising: obtaining a target change code of a target program, wherein N is an integer greater than 1, and the target change code is a code that has been updated and has not undergone regression testing; inputting the target change code into a vector machine model, extracting code features of the target change code through the vector machine model, and determining a potential defect score of the target change code based on the code features, wherein the potential defect score is used to characterize the probability that an abnormality occurs in the target program due to the target change code; determining at least one regression test case for testing the target change code from the M test cases based on the potential defect score of the target change code, the code features of the target change code, and the use case features of each test case in M ​​test cases, wherein M is an integer greater than 1.

[0008] Optionally, the code features of the target change code include at least one of the following features: a first feature, used to characterize the number of code lines of the target change code; a second feature, used to characterize the number of code lines of the functional module where the target change code is located; a third feature, used to characterize the number of historical changes and / or the historical change frequency of the target change code; a fourth feature, used to characterize the transaction function information corresponding to the functional module where the target change code is located.

[0009] Optionally, the use case characteristics of the test case include at least one of the following characteristics: a first type of use case characteristics, used to characterize the test transaction scenario corresponding to the test case; a second type of use case characteristics, used to characterize the test implementation step information of the test case; a third type of use case characteristics, used to characterize the table field information verified using the test case; a fourth type of use case characteristics, used to characterize the upstream transaction information and downstream transaction information associated with the target transaction tested using the test case.

[0010] Optionally, determining a potential defect score of a target change code based on code features includes: encoding the code features to obtain feature coding values; filtering the repeated feature coding values ​​when duplicate feature coding values ​​are detected, and using the remaining feature coding values ​​as first feature values; normalizing the first feature value to obtain a target feature value; and determining a potential defect score of the target change code based on the target feature value.

[0011] Optionally, determining at least one regression test case for testing the target change code from the M test cases based on the potential defect score of the target change code, the code features of the target change code, and the use case features of each test case in the M test cases, includes: obtaining association features between the target program and the target change code, wherein the association features characterize the structural proportion of the target change code in all the codes of the target program; determining at least one regression test case for testing the target change code from the M test cases based on the potential defect score of the target change code, the code features of the target change code, the use case features of each test case, and the association features.

[0012] Optionally, obtaining the association features between the target program and the target change code includes: converting all the codes of the target program into an abstract syntax tree, wherein each code module corresponds to a tree node of the abstract syntax tree, and the connection relationship between adjacent tree nodes in the abstract syntax tree represents the dependency relationship between different code modules corresponding to the adjacent tree nodes; determining the tree node corresponding to the target change code in the abstract syntax tree as the target tree node; and determining the association features between the target program and the target change code based on the position of the target tree node in the abstract syntax tree.

[0013] Optionally, the association characteristics between the target program and the target change code are determined based on the position of the target tree node in the abstract syntax tree, including: determining the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree based on the position of the target tree node in the abstract syntax tree; determining the association characteristics based on the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree.

[0014] Optionally, the training process of the vector machine model includes the following steps: obtaining historical version data of the target program, wherein the historical version data includes historical change codes in each iteration process of the historical version, historical regression test cases selected for the historical change codes, test results for the historical change codes, and the number of subsequent iteration modifications of the historical change codes; extracting code features of the historical change codes and use case features of the historical regression test cases; determining the probability value of an abnormality in the target program due to the historical change codes based on the test results of the historical change codes and the number of subsequent iteration modifications of the historical change codes; using the code features of the historical change codes and the use case features of the historical regression test cases as model training features; using the probability value of an abnormality in the target program due to the historical change codes as the first training label; using the use case information of the historical regression test cases as the second training label; and training the vector machine model based on the model training features, the first training label, and the second training label.

[0015] Optionally, after determining the potential defect score of the target change code based on the code features, the method for determining the regression test cases also includes: determining the number of selected regression test cases based on the value of the potential defect score of the target change code, wherein the number of regression test cases is positively correlated with the value of the potential defect score.

[0016] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a device for determining a regression test case is also provided, including: an acquisition unit, used to acquire a target change code of a target program, wherein N is an integer greater than 1, and the target change code is a code that has been updated and has not undergone regression testing; a first determination unit, used to input the target change code into a vector machine model, extract code features of the target change code through the vector machine model, and determine a potential defect score of the target change code based on the code features, wherein the potential defect score is used to characterize the probability that an abnormality occurs in the target program due to the target change code; a second determination unit, used to determine at least one regression test case for testing the target change code from M test cases based on the potential defect score of the target change code, the code features of the target change code, and the use case features of each test case in M ​​test cases, wherein M is an integer greater than 1.

[0017] Optionally, the code features of the target change code include at least one of the following features: a first feature, used to characterize the number of code lines of the target change code; a second feature, used to characterize the number of code lines of the functional module where the target change code is located; a third feature, used to characterize the number of historical changes and / or the historical change frequency of the target change code; a fourth feature, used to characterize the transaction function information corresponding to the functional module where the target change code is located.

[0018] Optionally, the use case characteristics of the test case include at least one of the following characteristics: a first type of use case characteristics, used to characterize the test transaction scenario corresponding to the test case; a second type of use case characteristics, used to characterize the test implementation step information of the test case; a third type of use case characteristics, used to characterize the table field information verified using the test case; a fourth type of use case characteristics, used to characterize the upstream transaction information and downstream transaction information associated with the target transaction tested using the test case.

[0019] Optionally, the first determination unit includes: a first processing subunit, a second processing subunit, a third processing subunit, and a first determination subunit. The first processing subunit is used to encode the code features to obtain feature coding values; the second processing subunit is used to filter the repeated feature coding values ​​when repeated feature coding values ​​are detected, and use the remaining feature coding values ​​as the first feature values; the third processing subunit is used to normalize the first feature values ​​to obtain the target feature values; the first determination subunit is used to determine the potential defect score of the target change code according to the target feature value.

[0020] Optionally, the second determination unit includes: a first acquisition subunit and a second determination subunit. The first acquisition subunit is used to acquire the correlation feature between the target program and the target change code, wherein the correlation feature represents the structural proportion of the target change code in all the codes of the target program; the second determination subunit is used to determine at least one regression test case for testing the target change code from the M test cases according to the potential defect score of the target change code, the code feature of the target change code, the use case feature of each test case, and the correlation feature.

[0021] Optionally, the first acquisition subunit includes: a first conversion module, a first determination module, and a second determination module. The first conversion module is used to convert all codes of the target program into an abstract syntax tree, wherein each code module corresponds to a tree node of the abstract syntax tree, and the connection relationship between adjacent tree nodes in the abstract syntax tree represents the dependency relationship between different code modules corresponding to adjacent tree nodes; the first determination module is used to determine that the tree node corresponding to the target change code in the abstract syntax tree is the target tree node; the second determination module is used to determine the association characteristics between the target program and the target change code according to the position of the target tree node in the abstract syntax tree.

[0022] Optionally, the second determination module includes: a first determination submodule and a second determination submodule. The first determination submodule is used to determine the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree according to the position of the target tree node in the abstract syntax tree; the second determination submodule is used to determine the associated features according to the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree.

[0023] Optionally, the first determination unit includes: a second acquisition subunit, a first extraction subunit, a third determination subunit, a fourth determination subunit, a fifth determination subunit, and a first training subunit. The second acquisition subunit is used to acquire the historical version data of the target program, wherein the historical version data includes the historical change code in each iteration of the historical version, the historical regression test case selected for the historical change code, the test result for the historical change code, and the number of subsequent iterations and modifications of the historical change code; the first extraction subunit is used to extract the code features of the historical change code and the use case features of the historical regression test case; the third determination subunit is used to determine the probability value of the target program being abnormal due to the historical change code based on the test results of the historical change code and the number of subsequent iterations and modifications of the historical change code; the fourth determination subunit is used to use the code features of the historical change code and the use case features of the historical regression test case as model training features; the fifth determination subunit is used to use the probability value of the target program being abnormal due to the historical change code as the first training label; and use case information of the historical regression test case as the second training label; the first training subunit is used to train a vector machine model based on the model training features, the first training label, and the second training label.

[0024] Optionally, the second determination unit includes: a sixth determination subunit, used to determine the number of selected regression test cases according to the score of the potential defect score of the target change code, wherein the number of regression test cases is positively correlated with the score of the potential defect score.

[0025] According to another aspect of an embodiment of the present application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned method for determining the regression test case.

[0026] According to another aspect of an embodiment of the present application, an electronic device is also provided, including: a memory storing an executable program; and a processor for running the program, wherein the above-mentioned method for determining regression test cases is executed when the program is running.

[0027] According to another aspect of an embodiment of the present application, a computer program product is also provided, including computer instructions, which implement the steps of the above-mentioned method for determining regression test cases when executed by a processor.

[0028] In the present application, the target change code of the target program is first obtained, that is, the code in the target program that has been updated and has not been regression tested, the target change code is input into a vector machine model, the code features of the target change code are extracted through the vector machine model, and the potential defect score of the target change code is determined based on the code features, wherein the potential defect score is used to characterize the probability of an abnormality in the target program caused by the target change code, and then at least one regression test case for testing the target change code is determined from the M test cases based on the potential defect score of the target change code, the code features of the target change code, and the use case features of each test case in the M test cases, thereby achieving the purpose of automatically analyzing and evaluating the potential risks of code changes through the vector machine model, and intelligently selecting and generating regression test cases based on this evaluation result, thereby achieving the technical effect of improving the efficiency of writing regression test cases, and thus solving the technical problem of low efficiency in writing regression test cases in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0030] Figure 1 A hardware structure block diagram of a computer terminal for implementing a method for determining regression test cases is shown;

[0031] Figure 2 is a flowchart of an optional method for determining a regression test case according to an embodiment of the present application;

[0032] Figure 3 is a schematic diagram of an optional device for determining a regression test case according to an embodiment of the present application;

[0033] Figure 4 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0034] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0035] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0036] It should be noted that the collected information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with relevant laws, regulations and standards, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation entrances are provided for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or institutions to provide users with corresponding operation entrances for users to choose to agree or refuse the results of automated decision-making; if the user chooses to refuse, the expert decision-making process will be entered.

[0037] Example 1

[0038] According to an embodiment of the present application, an embodiment of a method for determining a regression test case is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0039] It should be noted that a test case generation system can be used as the execution subject of the method for determining regression test cases in the embodiment of the present application. It is understandable that the method for determining regression test cases provided in the embodiment of the present application can also be executed by other systems or devices, and the embodiment of the present application does not specifically limit this.

[0040] The method embodiments provided in the present application may be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 The hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for determining regression test cases is shown. Figure 1As shown, the computer terminal 10 (or mobile device) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0041] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuit may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be fully or partially integrated into any of the other components in the computer terminal 10 (or mobile device). As in the method for determining regression test cases involved in the embodiments of the present application, the data processing circuit serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0042] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method for determining regression test cases in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the method for determining the regression test cases described above is implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0043] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0044] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).

[0045] Under the above operating environment, this application provides Figure 2 The method for determining regression test cases is shown. Figure 2 FIG. 1 is a flowchart of an optional method for determining a regression test case according to an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:

[0046] Step S201, obtaining a target change code of a target program.

[0047] In step S201 , N is an integer greater than 1, and the target changed code is the code that has been updated and has not undergone regression testing.

[0048] Optionally, the target program refers to a software system that is being modified, upgraded, or developed, and these modifications may be based on new requirements, functional improvements, bug fixes, etc.

[0049] Optionally, the target changed code refers to the code that has been modified or added during the latest development or maintenance process, and the changed code has not yet been verified by regression testing.

[0050] Step S202 : input the target change code into the vector machine model, extract the code features of the target change code through the vector machine model, and determine the potential defect score of the target change code according to the code features.

[0051] In step S202 , the potential defect score is used to characterize the probability that the target program will be abnormal due to the target changed code.

[0052] Optionally, the vector machine model refers to a support vector machine (SVM) model, a supervised learning algorithm widely used in classification and regression analysis. The test case generation system inputs the target change code into the SVM model, and the model can analyze and understand the structure, logic and potential impact of the code, thereby extracting the characteristics of the code, wherein the code characteristics are a set of indicators that describe the properties and behaviors of the target change code, including but not limited to the number of code lines, modification frequency, functional modules, involved transaction scenarios, upstream and downstream transaction associations, historical bug records, etc., and the potential defect score of the target change code can be determined based on the code characteristics.

[0053] It should be noted that the SVM model is a supervised learning algorithm widely used in the field of machine learning, mainly used for classification and regression analysis.

[0054] Optionally, the potential defect score is a numerical value used to quantify and characterize the possibility that the introduction of the target change code will cause software anomalies or defects. The higher the score, the greater the probability that the target program will fail due to the target change code.

[0055] Step S203, determining at least one regression test case for testing the target changed code from the M test cases according to the potential defect score of the target changed code, the code features of the target changed code, and the test case features of each test case in the M test cases.

[0056] In step S203, M is an integer greater than 1.

[0057] Optionally, based on the potential defect scores and code features of the target changed code, and the test case features in the existing test case library, the test case generation system can filter out the regression test cases most relevant to the target changed code from the M test cases for testing the target changed code.

[0058] It can be seen from the contents of steps S201 to S203 that in the present application, the target change code of the target program is first obtained, that is, the code in the target program that has been updated and has not undergone regression testing, the target change code is input into the vector machine model, the code features of the target change code are extracted through the vector machine model, and the potential defect score of the target change code is determined based on the code features, wherein the potential defect score is used to characterize the probability of an abnormality in the target program due to the target change code, and then at least one regression test case for testing the target change code is determined from the M test cases based on the potential defect score of the target change code, the code features of the target change code, and the use case features of each test case in the M test cases, thereby achieving the purpose of automatically analyzing and evaluating the potential risks of code changes through the vector machine model, and intelligently selecting and generating regression test cases based on this evaluation result, thereby achieving the technical effect of improving the efficiency of writing regression test cases, and thus solving the technical problem of low efficiency in writing regression test cases in the prior art.

[0059] In an optional embodiment, the code features of the target change code include at least one of the following features: a first feature, used to characterize the number of code lines of the target change code; a second feature, used to characterize the number of code lines of the functional module where the target change code is located; a third feature, used to characterize the number of historical changes and / or the historical change frequency of the target change code; a fourth feature, used to characterize the transaction function information corresponding to the functional module where the target change code is located.

[0060] Optionally, the first feature reflects the scale of the target change code, that is, how many lines of code are modified. The more lines of code, the higher the logical complexity that may be introduced by this code change, and the more potential errors and defects. The second feature represents the total number of lines of code in the module where the target change code is located. The third feature focuses on the historical record of code changes, especially the frequency and number of changes. Frequent changes may indicate that the code segment is unstable or complex. The fourth feature describes the transaction function corresponding to the functional module where the target change code is located.

[0061] From the above content, we can see that the test case generation system can significantly improve the efficiency and accuracy of regression testing by analyzing the code features of the target change code. The SVM model uses these features to more comprehensively evaluate the impact of the target change code on the software system.

[0062] In an optional embodiment, the use case characteristics of a test case include at least one of the following characteristics: a first type of use case characteristics, used to characterize the test transaction scenario corresponding to the test case; a second type of use case characteristics, used to characterize the test implementation step information of the test case; a third type of use case characteristics, used to characterize the table field information verified using the test case; a fourth type of use case characteristics, used to characterize the upstream transaction information and downstream transaction information associated with the target transaction tested using the test case.

[0063] Optionally, the first type of use case features describe the specific business scenarios or functions covered by the test case. In software development, different transaction scenarios may have different levels of complexity and risk. By identifying whether the test case is related to the transaction scenario involved in the code change, the model can filter out the use cases that cover these scenarios, ensuring that regression testing can fully cover all business scenarios that may be affected by the code change.

[0064] Optionally, the second type of use case features describes in detail the specific steps for executing the test case, including setting up the environment, inputting data, performing operations, and expected results. The detailed information of these steps is crucial for evaluating the pertinence of the test case. By analyzing these implementation steps, the SVM model can understand the coverage and depth of the test case for the code changes, thereby selecting test cases whose implementation steps are highly relevant to the target changed code.

[0065] Optionally, the third type of use case features refers to specific data fields or data tables that need to be verified during the execution of the test case. In database-driven software systems, specific code changes may directly affect the correctness and integrity of the data. By identifying the table fields verified by the test case, the SVM model can ensure that the selected regression test case can check the correctness of these fields and prevent data errors.

[0066] Optionally, the upstream transaction and downstream transaction information in the fourth type of use case features describe the location and relevance of the target transaction in the software system. Upstream transaction information refers to transactions that need to be completed before the target transaction is executed, while downstream transaction information refers to transactions that may be affected after the target transaction is executed. By analyzing this information, the SVM model can consider the impact of the target change code on the entire transaction link, ensuring that the selected regression test cases can cover the entire transaction process and avoid missing possible indirect impacts.

[0067] From the above content, we can see that the test case generation system divides the test case features into four categories, which describe the properties and coverage of the test cases from different perspectives. Through the quantification and analysis of these features, the SVM model can more accurately match regression test cases with target change codes, ensuring the pertinence and effectiveness of the test.

[0068] In an optional embodiment, the test case generation system first encodes the code features to obtain feature coding values. When repeated feature coding values ​​are detected, the repeated feature coding values ​​are filtered out and the remaining feature coding values ​​are used as the first feature values. The first feature values ​​are then normalized to obtain a target feature value, and the potential defect score of the target change code is determined based on the target feature value.

[0069] Optionally, the test case generation system encodes the code features of the target change code by using a natural language processing tool, which includes but is not limited to the number of lines of code of the target code, the number of lines of code of the functional module, the number and frequency of historical changes, and the transaction function information corresponding to the functional module. Encoding processing usually converts non-numerical features into numerical representations that can be processed by the machine, for example, using one-hot encoding to convert text or categorical data into numerical features. After feature encoding, the test case generation system checks whether there are repeated feature encoding values. Repeated feature encoding values ​​may come from similar or identical change records, or the same transaction scenario associated with multiple changes. The system will filter these repeated feature encoding values ​​to reduce their weight influence in model training, ensure the independence and uniqueness of each feature encoding value, and use the remaining feature encoding values ​​as the first feature value (i.e., the feature value after encoding and filtering). Then, in order to enable the SVM model to process all features at the same scale, the system normalizes the first feature value. Normalization converts the feature value into a numerical value within a standard range, such as scaling all features to between 0 and 1, so as to avoid the size of certain feature values ​​from having a disproportionate impact on model decisions. After feature preprocessing, the system uses the trained SVM model to predict the possibility of introducing potential defects in the target code change based on the target feature value (normalized feature value). The model outputs a score that reflects the potential risk of the code change introducing problems.

[0070] It should be noted that one-hot encoding is a data preprocessing technique that is mainly used to convert categorical variables (i.e. variables with discrete values, such as color, category labels, etc.) into numerical form for processing by machine learning models. This encoding method maps each categorical value into a binary vector whose length is equal to the number of categories of the categorical variable. Only one element in the vector has a value of 1, representing the categorical value, and the values ​​of the remaining elements are all 0.

[0071] From the above content, it can be seen that the test case generation system automatically extracts, encodes, filters and normalizes the target change code, and then intelligently generates potential defect scores to guide testers to efficiently select and prioritize the most relevant regression test cases, thereby saving a lot of time and energy in manually screening test cases. The potential defect scoring mechanism ensures that the selection of regression test cases is more accurate and targeted, and testers can focus on those change codes with higher scores that may introduce problems, thereby improving the effectiveness of the test.

[0072] In an optional embodiment, the test case generation system first obtains association features between the target program and the target change code, wherein the association features characterize the structural proportion of the target change code in all the codes of the target program, and then determines at least one regression test case for testing the target change code from M test cases based on the potential defect score of the target change code, the code features of the target change code, the use case features of each test case, and the association features.

[0073] Optionally, the test case generation system first evaluates the structural weight of the target change code in the target program, that is, the degree of association between the change code and other code modules. This can be achieved by analyzing indicators such as the number of modules affected by the change code, the proportion of code lines, and the dependency relationship with upstream and downstream transactions. For example, if the change code modifies a part of the core transaction process, then its structural weight may be high, and the system will believe that this part of the change has a greater impact on the entire program and requires more testing attention. Then the system uses the potential defect score proposed above (based on SVM model prediction), as well as the code features of the target change code (such as the number of code lines, modification frequency, etc.) and the use case features of the test case (transaction scenario, implementation steps, verification fields, upstream and downstream transaction information, etc.), combined with the obtained association features, to comprehensively evaluate the relevance and importance of each test case with the target change code. Based on the above analysis, from M (M is the number of test cases in the test case library) test cases, the system can determine at least one regression test case that best reflects the potential impact of the target change code.

[0074] From the above content, it can be seen that the test case generation system can quickly filter out the most relevant test cases from a large number of test cases through correlation features and comprehensive scoring mechanism, avoiding redundant testing of codes that are not directly related or have little impact, thereby significantly improving testing efficiency. The analysis of correlation features ensures that the selection of test cases is more accurate and can focus on functional modules that are directly or potentially affected by the changed code, thereby improving the pertinence and effectiveness of the test.

[0075] In an optional embodiment, the test case generation system converts all codes of the target program into an abstract syntax tree, wherein each code module corresponds to a tree node of the abstract syntax tree, and the connection relationship between adjacent tree nodes in the abstract syntax tree represents the dependency relationship between different code modules corresponding to adjacent tree nodes. The tree node corresponding to the target change code in the abstract syntax tree is then determined as the target tree node. Finally, the association characteristics of the target program and the target change code are determined based on the position of the target tree node in the abstract syntax tree.

[0076] Optionally, the test case generation system uses an Abstract Syntax Tree (AST) as the basis for analyzing code structure and dependencies, and understands the location and role of the target change code in the target program in a more sophisticated and systematic way. By constructing the AST of the entire program, the system can capture the hierarchy and dependencies between code modules, and then determine the association characteristics between the target change code and other parts of the program, providing more comprehensive information for the selection of regression test cases.

[0077] Optionally, the test case generation system first converts all the code of the target program into an abstract syntax tree, which is a tree structure. Each tree node represents a code module. The connection relationship between nodes reflects the dependencies and interactions of different code modules. For example, if a code module calls a function of another module, then in the AST, the caller node will be connected to the callee node through an edge. After building the abstract syntax tree, the system will identify the node corresponding to the target change code, that is, the target tree node. This step helps the system locate the specific location of the change code in the program and its relationship with the surrounding code modules. Next, according to the position of the target tree node in the abstract syntax tree, the association features of the target program and the target change code are calculated. This may include the depth of the module where the target change code is located, the number of other nodes connected to it, the types of these nodes (such as function calls, data access, etc.), and their direct or indirect connection with the target change code.

[0078] From the above content, it can be seen that by utilizing the abstract syntax tree, the test case generation system can more accurately identify the dependencies between the target change code and other code modules, which is crucial for evaluating the potential impact of the change code. Based on the location and association characteristics of the change code in the AST, the system can intelligently select test cases that can fully test the change code and its related modules, avoiding excessive testing of irrelevant modules and improving the pertinence and efficiency of the test. At the same time, through refined analysis of code structure and dependencies, the system can allocate test resources more effectively, giving priority to testing modules that are highly associated with the change code and have higher risks, ensuring the rational use of resources.

[0079] In an optional embodiment, the test case generation system first determines the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree based on the position of the target tree node in the abstract syntax tree, and then determines the associated features based on the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree.

[0080] Optionally, the test case generation system first calculates the number of subordinate child nodes of the target change code (i.e., the target tree node) in the AST. The number of child nodes reflects the complexity and control scope of the module where the target change code is located. The more child nodes there are, the more complex the module is, and the more interactions and dependencies there are with other modules, so more complex defects and test requirements may be introduced. Next, the system calculates the depth between the target tree node and the root node of the AST, that is, the length of the path from the root node to the target node. The node depth reflects the position of the target change code in the program structure. The greater the depth, the more likely it is that the module is in a deeper logical structure and has a more direct impact on the underlying functions or data flows of the program. Finally, based on the number of child nodes and the node depth, the system can comprehensively evaluate the importance and potential impact of the target change code in the code structure. Modules with a large number of child nodes and a large node depth often have larger values ​​of associated features, indicating that these modules are more critical and need more attention. Therefore, when selecting regression test cases, the system will give these modules a higher weight.

[0081] From the above content, it can be seen that by quantifying the number of sub-nodes and node depth, the test case generation system can more accurately understand the structural complexity of each code module and the importance of its position in the program, providing a more targeted analysis basis for regression testing. Using these correlation features, the system can intelligently screen out those test cases that are most likely to be affected by the target change code, ensuring that test resources are efficiently allocated to the most critical parts, thereby improving the efficiency and effectiveness of regression testing.

[0082] In an optional embodiment, the test case generation system first obtains historical version data of the target program, wherein the historical version data includes historical change codes in each iteration process of the historical version, historical regression test cases selected for the historical change codes, test results for the historical change codes, and the number of subsequent iteration modifications of the historical change codes. Then, the code features of the historical change codes and the use case features of the historical regression test cases are extracted. Then, based on the test results of the historical change codes and the number of subsequent iteration modifications of the historical change codes, the probability value of an abnormality in the target program caused by the historical change codes is determined. Then, the code features of the historical change codes and the use case features of the historical regression test cases are used as model training features, and the probability value of an abnormality in the target program caused by the historical change codes is used as the first training label; the use case information of the historical regression test cases is used as the second training label. Finally, a vector machine model is trained based on the model training features, the first training label, and the second training label.

[0083] Optionally, the test case generation system first collects data on historical software versions, including but not limited to currently existing transaction test cases, all functional test cases for the current version modifications, current code change records, design instructions for each modification point, descriptions of problems found in functional testing, code submitters, etc., and then extracts features from the collected data, including but not limited to the number of lines of code modified in each module, the total number of lines of code in the module, features related to the test case (transaction scenarios involved, test implementation steps, table fields to be verified in the case, upstream and downstream transactions, etc.), frequency and number of code changes, transaction functions corresponding to the code module, etc., and then preprocesses the collected data, and then based on the test results of the historically changed code (i.e., each time The system calculates the probability of each historical change code causing an exception in the target program, and defines the probability value of each historical change code causing an exception as the first training label, which is used to train the model to identify the risk level of the changed code; the detailed information of the historical regression test case is defined as the second training label to guide the model to learn how to select effective test cases, and finally uses the extracted features (code features of the historical change code, use case features of the historical regression test case) and the defined labels (first training label, second training label) to train the SVM model, and optimizes the output of the model by adjusting the SVM parameters including the kernel function, regularization parameter, error threshold, etc.

[0084] From the above content, it can be seen that the test case generation system can more accurately determine the regression test cases corresponding to the changed code through the SVM model trained by historical data, thereby improving the accuracy of the model.

[0085] In an optional embodiment, the test case generation system determines the number of selected regression test cases according to the score of the potential defect score of the target change code, wherein the number of regression test cases is positively correlated with the score of the potential defect score.

[0086] Optionally, the test case generation system uses the trained SVM model to evaluate the target change code and obtain a potential defect score, which reflects the probability that the change code may introduce anomalies or defects. Next, the system determines the number of regression test cases based on the value of the potential defect score. Here, the number of test cases is positively correlated with the potential defect score, that is, the system will select more test cases to verify the higher-risk change code to ensure quality. Conversely, for lower-risk change code, the system will reduce the number of test cases to avoid unnecessary resource consumption.

[0087] Optionally, the test case generation system uses a trained SVM model to check which of the existing cases involve the current modified content, selects cases with these characteristics as regression test cases, and determines the test priority of different regression test cases based on the different relevance evaluations given by the model to each regression test case.

[0088] Optionally, after determining the regression test cases and the number of regression test cases, the test case generation system executes the generated regression test cases and evaluates the accuracy and effectiveness of the constructed SVM model based on the test results. For cases that have passed the review and meet the regression requirements, they can also be added to the training set to improve the accuracy of the model. The model is continuously adjusted according to the training situation to continuously optimize the test case generation process.

[0089] From the above content, it can be seen that the test case generation system dynamically adjusts the number of test cases according to the potential defect scores. The system can reasonably allocate test resources, so that the generation and execution of test cases are more focused on high-risk changed codes, which improves the targetedness of the test, ensures that the key code is fully verified, avoids excessive testing of low-risk code, effectively controls the test cost, and improves the overall test efficiency.

[0090] The method for determining regression test cases provided in the embodiment of the present application obtains the target change code of the target program, that is, the code in the target program that has been updated and has not undergone regression testing, inputs the target change code into a vector machine model, extracts the code features of the target change code through the vector machine model, and determines the potential defect score of the target change code based on the code features, wherein the potential defect score is used to characterize the probability of an abnormality in the target program due to the target change code, and then determines at least one regression test case for testing the target change code from the M test cases based on the potential defect score of the target change code, the code features of the target change code, and the use case features of each test case in the M test cases, thereby solving the technical problem of low efficiency in writing regression test cases in the prior art, and thereby achieving the effect of improving the efficiency and accuracy of writing regression test cases.

[0091] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0092] Example 2

[0093] The embodiment of the present application also provides a device for determining a regression test case. It should be noted that the device for determining a regression test case in the embodiment of the present application can be used to execute the method for determining a regression test case provided in the embodiment of the present application. The device for determining a regression test case provided in the embodiment of the present application is introduced below.

[0094] According to an embodiment of the present application, a device for implementing the above-mentioned method for determining regression test cases is also provided. Figure 3 is a schematic diagram of an optional device for determining a regression test case according to an embodiment of the present application, such as Figure 3 As shown, the device includes: an acquisition unit 301, a first determination unit 302, and a second determination unit 303.

[0095] Optionally, an acquisition unit 301 is used to acquire a target change code of a target program, wherein N is an integer greater than 1, and the target change code is a code that has been updated and has not undergone regression testing; a first determination unit 302 is used to input the target change code into a vector machine model, extract code features of the target change code through the vector machine model, and determine a potential defect score of the target change code based on the code features, wherein the potential defect score is used to characterize the probability that an abnormality occurs in the target program due to the target change code; a second determination unit 303 is used to determine at least one regression test case for testing the target change code from M test cases based on the potential defect score of the target change code, the code features of the target change code, and the use case features of each test case in M ​​test cases, wherein M is an integer greater than 1.

[0096] Optionally, the code features of the target change code include at least one of the following features: a first feature, used to characterize the number of code lines of the target change code; a second feature, used to characterize the number of code lines of the functional module where the target change code is located; a third feature, used to characterize the number of historical changes and / or the historical change frequency of the target change code; a fourth feature, used to characterize the transaction function information corresponding to the functional module where the target change code is located.

[0097] Optionally, the use case characteristics of the test case include at least one of the following characteristics: a first type of use case characteristics, used to characterize the test transaction scenario corresponding to the test case; a second type of use case characteristics, used to characterize the test implementation step information of the test case; a third type of use case characteristics, used to characterize the table field information verified using the test case; a fourth type of use case characteristics, used to characterize the upstream transaction information and downstream transaction information associated with the target transaction tested using the test case.

[0098] Optionally, the first determination unit 302 includes: a first processing subunit, a second processing subunit, a third processing subunit, and a first determination subunit. The first processing subunit is used to encode the code feature to obtain a feature code value; the second processing subunit is used to filter the repeated feature code values ​​when repeated feature code values ​​are detected, and use the remaining feature code values ​​as the first feature value; the third processing subunit is used to normalize the first feature value to obtain a target feature value; and the first determination subunit is used to determine the potential defect score of the target change code according to the target feature value.

[0099] Optionally, the second determination unit 303 includes: a first acquisition subunit and a second determination subunit. The first acquisition subunit is used to acquire the correlation feature between the target program and the target change code, wherein the correlation feature represents the structural proportion of the target change code in all the codes of the target program; the second determination subunit is used to determine at least one regression test case for testing the target change code from the M test cases according to the potential defect score of the target change code, the code feature of the target change code, the use case feature of each test case, and the correlation feature.

[0100] Optionally, the first acquisition subunit includes: a first conversion module, a first determination module, and a second determination module. The first conversion module is used to convert all codes of the target program into an abstract syntax tree, wherein each code module corresponds to a tree node of the abstract syntax tree, and the connection relationship between adjacent tree nodes in the abstract syntax tree represents the dependency relationship between different code modules corresponding to adjacent tree nodes; the first determination module is used to determine that the tree node corresponding to the target change code in the abstract syntax tree is the target tree node; the second determination module is used to determine the association characteristics between the target program and the target change code according to the position of the target tree node in the abstract syntax tree.

[0101] Optionally, the second determination module includes: a first determination submodule and a second determination submodule. The first determination submodule is used to determine the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree according to the position of the target tree node in the abstract syntax tree; the second determination submodule is used to determine the associated features according to the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree.

[0102] Optionally, the first determination unit 302 includes: a second acquisition subunit, a first extraction subunit, a third determination subunit, a fourth determination subunit, a fifth determination subunit, and a first training subunit. The second acquisition subunit is used to acquire the historical version data of the target program, wherein the historical version data includes the historical change code in each iteration of the historical version, the historical regression test case selected for the historical change code, the test result for the historical change code, and the number of subsequent iterations and modifications of the historical change code; the first extraction subunit is used to extract the code features of the historical change code and the use case features of the historical regression test case; the third determination subunit is used to determine the probability value of the target program being abnormal due to the historical change code based on the test results of the historical change code and the number of subsequent iterations and modifications of the historical change code; the fourth determination subunit is used to use the code features of the historical change code and the use case features of the historical regression test case as model training features; the fifth determination subunit is used to use the probability value of the target program being abnormal due to the historical change code as the first training label; and use case information of the historical regression test case as the second training label; the first training subunit is used to train a vector machine model based on the model training features, the first training label, and the second training label.

[0103] Optionally, the second determination unit 303 includes: a sixth determination subunit, used to determine the number of selected regression test cases according to the score of the potential defect score of the target change code, wherein the number of regression test cases is positively correlated with the score of the potential defect score.

[0104] Example 3

[0105] An embodiment of the present application may provide an electronic device, Figure 4 is a structural block diagram of an electronic device according to an embodiment of the present application. Figure 4 As shown, the electronic device may include: one or more ( Figure 4 (only one is shown) processor 402, memory 404, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.

[0106] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above-mentioned method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0107] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain the target change code of the target program, wherein N is an integer greater than 1, and the target change code is the code that has been updated and has not undergone regression testing; input the target change code into the vector machine model, extract the code features of the target change code through the vector machine model, and determine the potential defect score of the target change code based on the code features, wherein the potential defect score is used to characterize the probability of an abnormality in the target program due to the target change code; determine at least one regression test case for testing the target change code from the M test cases based on the potential defect score of the target change code, the code features of the target change code, and the use case features of each test case in M ​​test cases, wherein M is an integer greater than 1.

[0108] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: the first feature is used to characterize the number of code lines of the target change code; the second feature is used to characterize the number of code lines of the functional module where the target change code is located; the third feature is used to characterize the number of historical changes and / or the historical change frequency of the target change code; the fourth feature is used to characterize the transaction function information corresponding to the functional module where the target change code is located.

[0109] The processor can call the information and application programs stored in the memory through the transmission device to perform the following steps: the first type of use case characteristics are used to characterize the test transaction scenarios corresponding to the test cases; the second type of use case characteristics are used to characterize the test implementation step information of the test cases; the third type of use case characteristics are used to characterize the table field information verified using the test cases; the fourth type of use case characteristics are used to characterize the upstream transaction information and downstream transaction information associated with the target transaction tested using the test cases.

[0110] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: encode the code features to obtain feature coding values; when repeated feature coding values ​​are detected, filter the repeated feature coding values ​​and use the remaining feature coding values ​​as the first feature values; normalize the first feature value to obtain the target feature value; and determine the potential defect score of the target change code based on the target feature value.

[0111] The processor can call the information and application programs stored in the memory through the transmission device to perform the following steps: obtain the association characteristics between the target program and the target change code, wherein the association characteristics represent the structural proportion of the target change code in all the codes of the target program; determine at least one regression test case for testing the target change code from M test cases based on the potential defect score of the target change code, the code characteristics of the target change code, the use case characteristics of each test case, and the association characteristics.

[0112] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: convert all the codes of the target program into an abstract syntax tree, wherein each code module corresponds to a tree node of the abstract syntax tree, and the connection relationship between adjacent tree nodes in the abstract syntax tree represents the dependency relationship between different code modules corresponding to adjacent tree nodes; determine the tree node corresponding to the target change code in the abstract syntax tree as the target tree node; and determine the association characteristics between the target program and the target change code based on the position of the target tree node in the abstract syntax tree.

[0113] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: determine the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree based on the position of the target tree node in the abstract syntax tree; determine the associated features based on the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree.

[0114] The processor can call the information and application programs stored in the memory through the transmission device to perform the following steps: obtain historical version data of the target program, wherein the historical version data includes historical change codes in each iteration of the historical version, historical regression test cases selected for the historical change codes, test results for the historical change codes, and the number of subsequent iteration modifications of the historical change codes; extract code features of the historical change codes and use case features of the historical regression test cases; determine the probability value of the target program being abnormal due to the historical change codes based on the test results of the historical change codes and the number of subsequent iteration modifications of the historical change codes; use the code features of the historical change codes and the use case features of the historical regression test cases as model training features; use the probability value of the target program being abnormal due to the historical change codes as the first training label; use the use case information of the historical regression test cases as the second training label; and train a vector machine model based on the model training features, the first training label, and the second training label.

[0115] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: determine the number of selected regression test cases based on the score of the potential defect score of the target change code, wherein the number of regression test cases is positively correlated with the score of the potential defect score.

[0116] It can be understood by those skilled in the art that Figure 4 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Figure 4 The structure of the electronic device is not limited. Figure 4 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 4 Different configurations are shown.

[0117] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0118] Example 4

[0119] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the method for determining regression test cases provided in the first embodiment.

[0120] Optionally, in this embodiment, the above storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.

[0121] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing the program of the determination method steps of the regression test case.

[0122] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0123] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0124] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0125] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0126] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0127] If the integrated unit is implemented in the form of 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 the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0128] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for determining a regression test case, characterized in that: include: Obtaining a target change code of a target program, wherein N is an integer greater than 1, and the target change code is a code that has been updated and has not undergone regression testing; Inputting the target change code into a vector machine model, extracting code features of the target change code through the vector machine model, and determining a potential defect score of the target change code according to the code features, wherein the potential defect score is used to characterize the probability that the target program will be abnormal due to the target change code; Determine at least one regression test case for testing the target change code from the M test cases based on the potential defect score of the target change code, the code features of the target change code, and the use case features of each test case in M ​​test cases, where M is an integer greater than 1.

2. The method for determining a regression test case according to claim 1, characterized in that: The code features of the target change code include at least one of the following features: The first feature is used to characterize the number of lines of code of the target changed code; The second feature is used to characterize the number of code lines of the functional module where the target change code is located; The third feature is used to characterize the number of historical changes and / or the historical change frequency of the target change code; The fourth feature is used to characterize the transaction function information corresponding to the function module where the target change code is located.

3. The method for determining a regression test case according to claim 1, characterized in that: The test case features include at least one of the following features: The first type of use case characteristics is used to characterize the test transaction scenario corresponding to the test case; The second type of use case features is used to characterize the test implementation step information of the test case; The third type of use case features is used to characterize the table field information verified using the test case; The fourth type of use case features is used to characterize upstream transaction information and downstream transaction information associated with the target transaction tested using the test case.

4. The method for determining a regression test case according to claim 1, characterized in that: Determining a potential defect score of the target changed code according to the code features includes: Encoding the code feature to obtain a feature encoding value; In the case where repeated feature code values ​​are detected, the repeated feature code values ​​are filtered out, and the remaining feature code values ​​are used as the first feature values; Normalizing the first eigenvalue to obtain a target eigenvalue; A potential defect score of the target changed code is determined according to the target feature value.

5. The method for determining a regression test case according to claim 1, characterized in that: Determining at least one regression test case for testing the target changed code from the M test cases according to the potential defect score of the target changed code, the code features of the target changed code, and the use case features of each test case in the M test cases, including: Acquire a correlation feature between the target program and the target change code, wherein the correlation feature represents a structural proportion of the target change code in all codes of the target program; At least one regression test case for testing the target change code is determined from the M test cases according to the potential defect score of the target change code, the code features of the target change code, the use case features of each test case, and the associated features.

6. The method for determining a regression test case according to claim 5, characterized in that: Acquiring the associated features of the target program and the target change code, including: Converting all codes of the target program into an abstract syntax tree, wherein each code module corresponds to a tree node of the abstract syntax tree, and the connection relationship between adjacent tree nodes in the abstract syntax tree represents the dependency relationship between different code modules corresponding to the adjacent tree nodes; Determine a tree node corresponding to the target change code in the abstract syntax tree as a target tree node; According to the position of the target tree node in the abstract syntax tree, the association feature between the target program and the target change code is determined.

7. The method for determining a regression test case according to claim 6, characterized in that: Determining, according to the position of the target tree node in the abstract syntax tree, the association feature between the target program and the target change code, including: Determine, according to the position of the target tree node in the abstract syntax tree, the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree; The association feature is determined according to the number of child nodes under the target tree node and the node depth between the target tree node and the root node of the abstract syntax tree.

8. The method for determining a regression test case according to claim 1, characterized in that: The training process of the vector machine model includes the following steps: Acquire historical version data of the target program, wherein the historical version data includes historical change codes in each iteration process of the historical version, historical regression test cases selected for the historical change codes, test results for the historical change codes, and the number of subsequent iteration modifications of the historical change codes; Extracting code features of the historical change code and use case features of the historical regression test cases; Determining, according to the test result of the historical change code and the number of subsequent iterative modifications of the historical change code, a probability value that the target program is abnormal due to the historical change code; Using the code features of the historical change code and the use case features of the historical regression test cases as model training features; Using the probability value of the target program being abnormal due to the historical change code as the first training label; using the use case information of the historical regression test case as the second training label; The vector machine model is obtained by training according to the model training features, the first training labels and the second training labels.

9. The method for determining a regression test case according to claim 1, characterized in that: After determining the potential defect score of the target changed code according to the code feature, the method for determining the regression test case further includes: The number of the selected regression test cases is determined according to the score of the potential defect score of the target changed code, wherein the number of the regression test cases is positively correlated with the score of the potential defect score.

10. A device for determining a regression test case, characterized in that: include: An acquisition unit, configured to acquire a target change code of a target program, wherein N is an integer greater than 1, and the target change code is a code that has been updated and has not undergone regression testing; a first determining unit, configured to input the target change code into a vector machine model, extract code features of the target change code through the vector machine model, and determine a potential defect score of the target change code according to the code features, wherein the potential defect score is used to characterize a probability that the target program will be abnormal due to the target change code; The second determination unit is used to determine at least one regression test case for testing the target change code from the M test cases based on the potential defect score of the target change code, the code features of the target change code, and the use case features of each test case in the M test cases, wherein M is an integer greater than 1.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is run, the device where the computer-readable storage medium is located is controlled to execute the method for determining the regression test case according to any one of claims 1 to 9.

12. An electronic device, characterized in that: include: A memory storing an executable program; A processor is used to run the program, wherein the program executes the method for determining the regression test case according to any one of claims 1 to 9 when running.

13. A computer program product comprising computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method for determining a regression test case according to any one of claims 1 to 9 are implemented.

Citation Information

Cited By

  • Test case detection method and device, storage medium and electronic equipment

    CN120429241A

  • Test case detection method and device, storage medium and electronic equipment

    CN120429241B

  • Path-based test case priority sequence recommendation method and system

    CN120448267A

  • A path-based test case priority sequence recommendation method and system

    CN120448267B

  • Algorithm plug-in collaborative development method and system based on multi-version control

    CN120491956A