Case processing method and device, equipment, medium and program product

By generating and filtering test cases and prioritizing them based on code quality indicators, the problems of long test time and low coverage of test cases are solved, and the testing efficiency and the stability of software products are improved.

CN119718939APending Publication Date: 2025-03-28INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411840840.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The current test cases are put into production with a long test cycle, the test cases are redundant or outdated, the test coverage is low, and it is unable to effectively respond to frequent changes in demand, and the stability of software products is poor.

Method used

By generating initial test cases based on production cases and demand text, target test cases that meet preset conditions are selected, and prioritized based on code quality indicators, and target test cases are executed in the test environment in priority order.

Benefits of technology

It reduces redundant test cases, improves testing efficiency and coverage, shortens the test cycle, accurately locates potential risks, and improves the quality and stability of software products.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718939A_ABST
    Figure CN119718939A_ABST
Patent Text Reader

Abstract

The invention provides a case processing method which can be applied to the field of financial science and technology and the technical field of computer software. The case processing method comprises the steps that N initial test cases are generated based on a production case and a demand text, the demand text is used for indicating change information of source codes for the production case, and N is an integer larger than or equal to 2; screening M target test cases, 0lt, meeting a preset condition from the N initial test cases; m < = N and is an integer; under the condition that M is determined to be larger than or equal to 2, priority ranking is carried out on the M target test cases based on code quality indexes, and the code quality indexes are used for indicating risk conditions of the target test cases; and according to the sequence of the priorities, sequentially sending the sorted M target test cases to a test environment, so as to sequentially execute the target test cases in the test environment. The invention further provides a case processing device, equipment, a storage medium and a program product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the fields of fintech and computer software technology, specifically to the field of software testing, and more specifically to a case processing method, apparatus, device, medium and program product. Background Art

[0002] A test case is a set of test inputs, execution conditions, and expected results compiled for a specific purpose to test a certain program path or verify whether a specific requirement is met. The importance of test cases is mainly reflected in the following aspects: Test cases form the basis for designing and formulating the test process; the depth of testing is proportional to the number of test cases. Based on comprehensive and detailed test cases, the time arrangements for each stage of the test cycle can be estimated more accurately; the types of test design and development and the required resources are mainly controlled by test cases.

[0003] In the process of implementing the embodiments of the present disclosure, it is found that the current production test case test time cycle is long, the test cases are redundant or outdated, the test coverage rate is low, it is impossible to efficiently respond to frequently changing requirements, and the stability of software products is poor. Summary of the Invention

[0004] In view of the above problems, the present disclosure provides a case processing method, apparatus, device, medium and program product.

[0005] According to a first aspect of the present disclosure, there is provided a case processing method, including: generating N initial test cases based on production cases and requirement texts, where the requirement text is used to indicate change information for the source code of the production case, and N is an integer greater than or equal to 2; screening M target test cases that meet preset conditions from the N initial test cases, where 0 < M ≤ N and M is an integer; in the case of determining that M ≥ 2, performing priority sorting on the M target test cases based on code quality metrics, where the code quality metrics are used to indicate the risk situation of the target test cases; and sequentially sending the sorted M target test cases to the test environment in the order of priority for sequentially executing the target test cases in the test environment.

[0006] According to an embodiment of the present disclosure, in the case of determining that M ≥ 2, performing priority sorting on the M target test cases based on code quality metrics includes: for each target test case among the M target test cases: extracting features from the target test case based on the code quality metrics to obtain initial features; screening the initial features to obtain target features; determining a risk assessment value for the target test case based on the feature value corresponding to the target feature and the weight value corresponding to the target feature; and performing priority sorting on the M target test cases based on the risk assessment value of each target test case.

[0007] According to an embodiment of the present disclosure, code quality indicators include at least one of the following: code complexity, code change frequency, and defect density; based on the code quality indicators, feature extraction is performed on the target test case to obtain initial features, including: based on code complexity, extracting cyclomatic complexity, number of lines of code, and method length features from the target test case to obtain initial features; and / or based on code change frequency, extracting code change count features from the target test case to obtain initial features; and / or based on defect density, extracting features of the ratio of the number of defects to the number of lines of code from the target test case to obtain initial features.

[0008] According to an embodiment of the present disclosure, M target test cases that meet preset conditions are screened from N initial test cases, including: performing vector conversion on each of the N initial test cases to obtain N vectors, wherein the initial test cases correspond to the vectors one-to-one; and based on the similarity between any two vectors in the N vectors, screening the M target test cases that meet the preset conditions from the N initial test cases.

[0009] According to an embodiment of the present disclosure, vector conversion is performed on each of N initial test cases to obtain N vectors, including: for each of the N initial test cases: converting the initial test case into an image in a structured form; and converting the image into a vector based on graph embedding technology.

[0010] According to an embodiment of the present disclosure, based on the similarity between any two vectors among N vectors, M target test cases that meet preset conditions are screened from N initial test cases, including: in the case where it is determined that the similarity between any two vectors among the N vectors is greater than a threshold, a first vector pair whose similarity is greater than the threshold and a second vector pair whose similarity is less than or equal to the threshold are determined; in the case where it is determined that there is no common vector between the first vector pair and the second vector pair, an initial test case corresponding to any one vector in the first vector pair and an initial test case corresponding to a vector in the second vector pair are determined as target test cases; and in the case where it is determined that there is a common vector between the first vector pair and the second vector pair, an initial test case corresponding to a vector in the second vector pair is determined as a target test case.

[0011] According to an embodiment of the present disclosure, the change information includes the changed code snippet; based on the production case and the requirement text, N initial test cases are generated, including: based on the structure, comments and requirement specifications of the source code, the production case is parsed to obtain project information; and based on the changed code snippet and the project information, N initial test cases are derived and generated.

[0012] The second aspect of the present disclosure provides a case processing device, including: a generating module, configured to generate N initial test cases based on a production case and a requirement text, where the requirement text is used to indicate change information for the source code of the production case, and N is an integer greater than or equal to 2; a screening module, configured to screen M target test cases that meet preset conditions from the N initial test cases, where 0 < M ≤ N and M is an integer; a sorting module, configured to, when determining that M ≥ 2, perform priority sorting on the M target test cases based on a code quality metric, where the code quality metric is used to indicate the risk situation of the target test cases; and a sending module, configured to sequentially send the sorted M target test cases to a test environment in the order of priority, so as to sequentially execute the target test cases in the test environment.

[0013] The third aspect of the present disclosure provides an electronic device, including: one or more processors; a memory, configured to store one or more computer programs, where the above one or more processors execute the above one or more computer programs to implement the steps of the above method.

[0014] The fourth aspect of the present disclosure further provides a computer-readable storage medium, on which a computer program or instruction is stored, and when the computer program or instruction is executed by a processor, the steps of the above method are implemented.

[0015] The fifth aspect of the present disclosure further provides a computer program product, including a computer program or instruction, and when the computer program or instruction is executed by a processor, the steps of the above method are implemented.

[0016] According to the embodiments of the present disclosure, initial test cases are generated based on a production case and a requirement text, and then the initial test cases are screened to obtain target test cases, and further, risk priority sorting is performed on the target test cases based on a code quality metric, so as to be sequentially executed in a test environment in the order of priority. Since the initial test cases are generated based on the requirement text when generating the initial test cases, the verification requirements of change information can be timely responded to. Furthermore, the initial test cases are screened, which can reduce redundant test cases, improve test efficiency, increase test coverage, and shorten the test cycle. On this basis, risk priority sorting is performed through the code quality metric, so that the test cases with high risks can be executed in the test environment first, accurately locate potential risks, and improve the quality and stability of software products. At least partially solve the problems of long test time cycle of current production test cases, redundant or outdated test cases, low test coverage, inability to efficiently respond to frequently changing requirements, and poor stability of software products. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, the above content and other objects, features, and advantages of the present disclosure will become clearer. In the drawings:

[0018] Figure 1 A schematic diagram showing an application scenario of a case processing method, apparatus, device, medium, and program product according to an embodiment of the present disclosure;

[0019] Figure 2 A flowchart of a case processing method according to an embodiment of the present disclosure is schematically shown;

[0020] Figure 3 A schematic diagram of screening target test cases according to an embodiment of the present disclosure is schematically shown;

[0021] Figure 4 A schematic diagram of determining a risk assessment value for a target test case according to an embodiment of the present disclosure is schematically shown;

[0022] Figure 5 A flowchart of a case processing method according to another embodiment of the present disclosure is schematically shown;

[0023] Figure 6 A schematic diagram of a structure of a case processing device according to an embodiment of the present disclosure is shown; and

[0024] Figure 7 A block diagram of an electronic device suitable for implementing a case handling method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0025] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0026] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0027] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0028] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0029] It should be noted that the case processing method and device provided in the present disclosure can be used in the field of financial technology, and can also be used in any field other than the field of financial technology. The present disclosure does not limit the application field of the case processing method and device.

[0030] In the technical solution of the present disclosure, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all 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 the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0031] In the scenario of using personal information for automated decision-making, the methods, devices, and systems provided by the embodiments of the present disclosure provide users with corresponding operation portals for users to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered. The expression "automated decision-making" here refers to the activity of automatically analyzing and evaluating a person's behavioral habits, interests and hobbies, or economic, health, credit status, etc. through computer programs, and making decisions. The expression "expert decision-making" here refers to the activity of making decisions by people who specialize in a certain field, have specialized experience, knowledge and skills, and have reached a certain level of professionalism.

[0032] In the process of implementing the embodiments of the present disclosure, it was found that the production verification case system device usually relies on manual writing and maintenance of test cases, which has problems such as low efficiency, insufficient coverage, easy omission of boundary conditions and abnormal scenarios. In addition, the response to frequently changing requirements is not timely, and it is impossible to quickly adapt to the verification requirements after the introduction of new features. In addition, with the iteration of software products, verification cases are difficult to update synchronously, and cases are often redundant or outdated. The coverage rate is difficult to accurately calculate and dynamically optimize, and the risk of production is relatively high. In addition, the lack of automated feedback and iterative optimization mechanisms is not conducive to continuously improving the quality of software products and shortening the production cycle.

[0033] Based on this, embodiments of the present disclosure provide a case processing method, including: generating N initial test cases based on production cases and requirement texts, where the requirement texts are used to indicate change information for the source code of the production cases, and N is an integer greater than or equal to 2; screening M target test cases that meet preset conditions from the N initial test cases, where 0 < M ≤ N and M is an integer; when it is determined that M ≥ 2, performing priority sorting on the M target test cases based on code quality metrics, where the code quality metrics are used to indicate the risk situations of the target test cases; and sequentially sending the sorted M target test cases to the test environment in the order of priority for executing the target test cases in the test environment in sequence.

[0034] Figure 1 Schematically shows an application scenario diagram of a case processing method, apparatus, device, medium, and program product according to an embodiment of the present disclosure.

[0035] As Figure 1 shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used as a medium to provide a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0036] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0037] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, and desktop computers, etc.

[0038] The server 105 may be a server that provides various services, such as a background management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (only as an example). The background management server may analyze and process data such as user requests received, and feedback the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0039] It should be noted that the case processing method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the case processing device provided in the embodiment of the present disclosure can generally be set in the server 105. The case processing method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the case processing device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.

[0040] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0041] The following will be based on Figure 1 The scene described by Figure 2~Figure 5 The case processing method of the disclosed embodiment is described in detail.

[0042] Figure 2 The flowchart of the case processing method according to the embodiment of the present disclosure is schematically shown.

[0043] like Figure 2 As shown, the case processing method of this embodiment includes operations S210 to S240.

[0044] In operation S210 , N initial test cases are generated based on the production case and the requirement text.

[0045] In operation S220 , M target test cases that meet a preset condition are screened from the N initial test cases.

[0046] In operation S230 , when it is determined that M≧2, the M target test cases are prioritized based on the code quality index.

[0047] In operation S240 , the sorted M target test cases are sent to the test environment in sequence according to the order of priority, so that the target test cases are executed in sequence in the test environment.

[0048] According to an embodiment of the present disclosure, a production case can be used to indicate a specific instance or scenario of applying a software product solution in an actual production environment. A production case can be used to describe how a software product is used to solve practical problems, meet business requirements, or improve work processes. A production case can include source code and document data. Requirement text can be used to indicate change information for the source code of the production case, where N is an integer greater than or equal to 2. 0 < M ≤ N, and M is an integer.

[0049] According to an embodiment of the present disclosure, the historical source code and historical document data of historical production cases and multiple historical test cases can be obtained, enabling a case generation model to learn the relationships between the multiple historical test cases and the historical source code and historical document data. Subsequently, after inputting the requirement text and the production case into the case generation model, with the production case as a prompt, the case generation model will generate multiple initial test cases based on the requirement text.

[0050] According to an embodiment of the present disclosure, a preset condition can be used to indicate that the initial test cases are different test cases. That is, screening M target test cases that meet the preset condition from N initial test cases can be understood as de-duplicating the N initial test cases to obtain M target test cases.

[0051] According to an embodiment of the present disclosure, a code quality indicator can be used to indicate the risk situation of a target test case. Based on the code quality indicator, the risk level of the target test case can be determined, and according to the risk level, the M target test cases can be sorted in descending order, that is, those with a higher risk level are ranked first and those with a lower risk level are ranked later, completing the priority ranking.

[0052] According to an embodiment of the present disclosure, initial test cases are generated based on the production case and the requirement text, and then the initial test cases are screened to obtain target test cases. Furthermore, risk priority ranking is performed on the target test cases based on the code quality indicator for sequential execution in the test environment according to the priority order. Since the initial test cases are generated based on the requirement text during the generation process, it can promptly respond to the verification requirements of change information. Subsequently, the initial test cases are screened, which can reduce redundant test cases, improve test efficiency, increase test coverage, and shorten the test cycle. On this basis, through risk priority ranking using the code quality indicator, test cases with greater risks can be executed first in the test environment, accurately locating potential risks and improving the quality and stability of the software product. This at least partially addresses the problems of the long test time cycle of current production test cases, redundant or outdated test cases, low test coverage, inability to efficiently respond to frequently changing requirements, and poor stability of software products.

[0053] According to an embodiment of the present disclosure, the change information may include a changed code segment. The changed code segment may include but is not limited to newly added code, modified code, or deleted code.

[0054] For the above Figure 2 The operation S210 shown generates N initial test cases based on the production case and the requirement text, and may include the operations of: parsing the production case to obtain project information based on the structure, comments and requirement specifications of the source code; and deriving and generating N initial test cases based on the changed code snippets and the project information.

[0055] According to the embodiments of the present disclosure, deep learning and natural language processing (NLP) technologies can be used to parse production cases from the aspects of source code structure, annotations, and requirement specifications to obtain project information. Project information may include, for example, function points and business logic, important business rules and constraints, performance and security requirements, user interface and interaction requirements, key variables and parameters in the code, etc.

[0056] According to an embodiment of the present disclosure, derivation information can be derived based on the changed code snippets and project information. The derivation information may include change points that affect the behavior of the software product. For example, if a key function is modified, all functions that depend on this function may be affected. Based on the derivation information, an initial test case can be generated. The initial test case can be used to verify whether the change works as expected and whether new problems are introduced. The initial test case may include: a functional test case for verifying whether the change meets business requirements and function points, a regression test case for ensuring that the change does not destroy existing functions, a boundary value test case for testing input values ​​near the change point to discover potential boundary problems, and an exception test case for verifying the behavior of the change under abnormal or erroneous conditions.

[0057] According to the embodiments of the present disclosure, since the structure, annotations and requirement specifications of the source code are parsed, test cases covering normal flows, abnormal flows and boundary conditions can be generated, thereby improving test coverage. In addition, test cases are automatically generated, reducing the workload of manually writing test cases and improving test coverage and efficiency. The method provided by the present disclosure can ensure that changes are fully tested and reduce the risk of software product defects.

[0058] According to the embodiments of the present disclosure, for the above Figure 2The operation S220 shown, screening M target test cases that meet preset conditions from N initial test cases, may include the operations of: performing vector conversion on each of the N initial test cases to obtain N vectors, wherein the initial test cases correspond one-to-one to the vectors; and screening M target test cases that meet the preset conditions from the N initial test cases based on the similarity between any two vectors in the N vectors.

[0059] According to an embodiment of the present disclosure, for each initial test case: the text description in the initial test case can be converted into a numerical vector. Whether the two vectors are similar can be determined by determining the similarity between any two vectors. If the similarity between any two vectors is greater than a threshold, the two vectors can be considered similar.

[0060] According to an embodiment of the present disclosure, the preset condition may be used to indicate that two vectors corresponding to any two initial test cases are not similar, that is, among the M target test cases, two vectors corresponding to any two target test cases are not similar.

[0061] According to an embodiment of the present disclosure, M target vectors that are dissimilar between any two vectors can be screened from N vectors according to the similarity between any two vectors, and an initial test case corresponding to each vector in the M target vectors is determined as a target test case.

[0062] According to the embodiments of the present disclosure, due to the vector conversion, the target test cases are screened based on the vector similarity, and similar test cases can be quickly identified by vector similarity, thereby reducing repeated tests and improving test efficiency. In addition, for target test cases with large differences, it helps to improve the test coverage and ensure that the test cases can cover more code paths.

[0063] In the process of implementing the embodiments of the present disclosure, it is found that if the test cases are directly vectorized, when the test cases contain complex business logic and conditions, the rich semantic information and contextual relationships in the test cases cannot be fully captured. In addition, if in-depth analysis or debugging of the test cases is required, the interpretability is poor.

[0064] Based on this, in an embodiment of the present disclosure, each of the N initial test cases is respectively converted into a vector to obtain N vectors, which may include the following operations: for each of the N initial test cases: converting the initial test case into an image in a structured form; and converting the image into a vector based on graph embedding technology.

[0065] Figure 3 A schematic diagram of screening target test cases according to an embodiment of the present disclosure is schematically shown.

[0066] like Figure 3 As shown, the initial test case 1, the initial test case 2, ..., and the initial test case N can be subjected to structured image transformation to obtain image 1, image 2, ..., and image N, respectively. Based on the graph embedding technology, the images 1, image 2, ..., and image N are respectively transformed into vectors to obtain vector 1, vector 2, ..., and vector N. The initial test case 1, image 1, and vector 1 have a mapping relationship, and similarly, the initial test case N, image N, and vector N have a mapping relationship. The similarity between any two vectors can be calculated, and M target vectors that are dissimilar between any two vectors can be screened from the N vectors based on the similarity. The initial test case corresponding to each vector in the M target vectors is determined as a target test case to obtain M target test cases.

[0067] According to an embodiment of the present disclosure, performing structured image conversion on initial test case 1, initial test case 2, ..., initial test case N respectively may include the following operations: For each initial test case: the data in the initial test case may be represented in the form of a graph, such as a flow chart, a state chart, a control flow graph (CFG graph), etc., so that the structure and flow of the test case may be intuitively displayed.

[0068] According to an embodiment of the present disclosure, based on graph embedding technology, image 1, image 2, ..., image N are respectively converted into vectors to obtain vector 1, vector 2, ..., vector N, which may include the following operations: For each image: a convolutional neural network may be used to encode the image to obtain a corresponding vector.

[0069] According to an embodiment of the present disclosure, based on the graph embedding technology, image 1, image 2, ..., image N are respectively vectorized to obtain vector 1, vector 2, ..., vector N. The following operations may also be included: For each image: dimensionality reduction technology (such as PCA) may be applied to map the image data to a low-dimensional space to obtain a reduced-dimensional image, which helps to reduce the complexity of the data and extract the most important features. Image features are extracted from the reduced-dimensional image, and the image features are vectorized to obtain the corresponding vector.

[0070] According to the embodiments of the present disclosure, abstract test cases can be represented as intuitive structured images through graphics, which enhances the operability of the test cases and facilitates in-depth analysis or debugging of the test cases. By using graph embedding technology to convert images into vectors, the key information and structural features of the images are retained, which is conducive to accurately determining the similarities between test cases. Compared with directly vectorizing the test cases, when the test cases contain complex business logic and conditions, rich semantic information and contextual relationships in the test cases can be captured.

[0071] According to the embodiments of the present disclosure, the present disclosure performs similarity detection and deduplication processing on the generated initial test cases through basic graph theory and graph embedding technology. In addition, a collaborative learning mechanism can be introduced to continuously learn and optimize the generation of initial test cases during the execution of target test cases, reduce invalid and redundant tests, and improve the utilization rate of test resources.

[0072] According to an embodiment of the present disclosure, based on the similarity between any two vectors in N vectors, M target test cases that meet preset conditions are screened from N initial test cases, which may include the following operations: in a case where it is determined that the similarity between any two vectors in the N vectors is greater than a threshold, determining a first vector pair whose similarity is greater than the threshold and a second vector pair whose similarity is less than or equal to the threshold; in a case where it is determined that there is no common vector between the first vector pair and the second vector pair, determining the initial test case corresponding to any one vector in the first vector pair and the initial test case corresponding to the vector in the second vector pair as target test cases; and in a case where it is determined that there is a common vector between the first vector pair and the second vector pair, determining the initial test case corresponding to the vector in the second vector pair as the target test case.

[0073] According to an embodiment of the present disclosure, the first vector pair is used to indicate that the vectors have similarity, and the second vector pair is used to indicate that the vectors do not have similarity.

[0074] For example, in the first vector pair, vector 1 and vector 2 are similar, and in the second vector pair, vector 2 and vector 3 are not similar. It can be determined that there is a common vector 2 between the first vector pair and the second vector pair.

[0075] According to the embodiments of the present disclosure, redundant test cases are determined through vector similarity, and then the initial test cases are accurately screened, the redundant test cases are removed, and the target test cases are obtained.

[0076] According to the embodiments of the present disclosure, for the above Figure 2 The operation S230 shown, when it is determined that M≥2, prioritizes the M target test cases based on the code quality indicators, and may include the following operations: for each of the M target test cases: based on the code quality indicators, perform feature extraction on the target test case to obtain initial features; screen the initial features to obtain target features; determine a risk assessment value for the target test case based on a feature value corresponding to the target feature and a weight value corresponding to the target feature; and prioritize the M target test cases based on the risk assessment value of each target test case.

[0077] According to the embodiments of the present disclosure, a suitable machine learning algorithm, such as decision tree, random forest, neural network, etc., can be selected to extract features of the target test case to obtain initial features. The most relevant features are selected using correlation analysis, mutual information, recursive feature elimination (RFE), etc., and feature importance evaluation, such as the feature importance score of random forest, is further used to screen features to obtain target features.

[0078] According to an embodiment of the present disclosure, target features may be input into a risk assessment model to output a risk assessment value, which is a numerical value between 0 and 1, where 1 represents the highest risk.

[0079] According to the embodiments of the present disclosure, data such as historical change records, defect reports, code complexity, and coupling between historical test cases of historical production cases can be collected and organized. Useful features can be extracted from the data to remove missing values ​​and outliers. For example, code complexity can be measured by indicators such as cyclomatic complexity, number of lines of code, and method length. The change frequency can count the number of changes in the past period of time. The defect density can calculate the ratio of the number of defects to the number of lines of code for each historical test case, analyze the dependencies between historical test cases, and calculate the coupling of historical test cases. The extracted historical features are divided into training sets and test sets, and the performance of the risk assessment model is evaluated using methods such as cross-validation to ensure the generalization ability of the model.

[0080] According to an embodiment of the present disclosure, a risk threshold may be set, and test cases with risk assessment values ​​higher than the risk threshold may be marked as high priority to ensure that these cases are executed first.

[0081] According to an embodiment of the present disclosure, when new test cases are generated, they can be prioritized based on risk assessment; and the prioritized test cases are sequentially allocated to the test environment for execution.

[0082] According to the embodiments of the present disclosure, since the target test cases are subjected to feature extraction and then screened again based on code quality indicators, the target features obtained can be important features for the target test cases. The risk assessment values ​​are determined based on this, which is conducive to identifying domain risks and quality characteristic risks, and testing those with high risks first, thereby discovering deficiencies in testing and improving the quality and stability of software products.

[0083] According to an embodiment of the present disclosure, the code quality index may include at least one of the following: code complexity, code change frequency, and defect density.

[0084] According to an embodiment of the present disclosure, feature extraction is performed on a target test case based on code quality indicators to obtain initial features, which may include the following operations: based on code complexity, extracting cyclomatic complexity, number of lines of code, and method length features from the target test case to obtain initial features; and / or based on code change frequency, extracting code change count features from the target test case to obtain initial features; and / or based on defect density, extracting features of the ratio of the number of defects to the number of lines of code from the target test case to obtain initial features.

[0085] Figure 4 A schematic diagram of determining a risk assessment value for a target test case according to an embodiment of the present disclosure is schematically shown.

[0086] like Figure 4 As shown, for each target test case 401, cyclomatic complexity, number of lines of code, and method length features 402 can be extracted from the target test case 401 based on code complexity. Code change times feature 403 can be extracted from the target test case 401 based on code change frequency. Based on defect density, a ratio feature 404 of the number of defects to the number of lines of code is extracted from the target test case 401. Cyclomatic complexity, number of lines of code, and method length features 402, code change times feature 403, and ratio feature 404 of the number of defects to the number of lines of code can be determined as initial features 405.

[0087] The initial features 405 are screened for feature importance to obtain target features 406. Based on the feature value corresponding to the target feature 406 and the weight value corresponding to the target feature 406, a risk assessment value 407 for the target test case 401 is determined.

[0088] According to the embodiments of the present disclosure, by characterizing code complexity by cyclomatic complexity, number of lines of code, and method length, the code logic of the test case can be predicted, which is beneficial for testing and maintenance. Characterizing the frequency of code changes by the number of code changes is beneficial for improving test efficiency. Characterizing defect density by the ratio of the number of defects to the number of lines of code is beneficial for reducing the defect rate. Combining the three is beneficial for accurately determining the risk situation of the target test case.

[0089] Figure 5 The flowchart of a case processing method according to another embodiment of the present disclosure is schematically shown.

[0090] like Figure 5As shown, a case generation model M can be obtained by training based on the test case library 501. The requirement text 502 and the production case 503 are input into the case generation model M, and N initial test cases 504 are output. The N initial test cases 504 are deduplicated to obtain M target test cases 505. The M target test cases 505 are prioritized based on the code quality index. The sorted M target test cases 505 are sent to the test environment in order of priority, so that the target test cases 505 are executed in sequence in the test environment. The execution status 506 of the target test case 505 and the performance index 507 related to the target test case are obtained in sequence. The real problem 508 in the production environment is associated with the execution status 506 of the target test case 505 and the performance index 507 related to the target test case 505, and the defect problem 509 is identified. According to the defect problem 509, the defect analysis result 510 is determined. According to the defect analysis result 510, the test case library 501 is updated.

[0091] According to an embodiment of the present disclosure, defect problems 509 may include, but are not limited to, problems such as missing functional points or abnormal situations. Execution status 506 includes execution success status and execution failure status. Performance indicators 507 related to target test cases may include, but are not limited to, test coverage, execution time, resource utilization, etc.

[0092] According to the embodiments of the present disclosure, a case generation model can be constructed based on a sequence model of deep learning, using a bidirectional long short-term memory network (Bi-LSTM), a self-attention mechanism (Self-Attention) or a Transformer, etc. The key information in the test case library 501 is extracted using an NLP tool, such as function definitions, class structures, and business logic descriptions in comments, etc. Based on the correspondence between the key information and the source code, the case generation model is trained.

[0093] According to the embodiments of the present disclosure, the test case library can be updated in real time using historical test data and feedback on the execution of newly generated target test cases, thereby updating the case generation model to more accurately generate high-quality test cases.

[0094] According to the embodiments of the present disclosure, the case processing method provided by the present disclosure constructs a complete feedback mechanism, uses the defect analysis results to update the test case library, and then feeds back the case generation model, continuously improves the accuracy of the model for generating effective cases, forms a virtuous circle, and can realize automated and intelligent test case generation, management and execution, and has good compatibility and closed-loop feedback and continuous optimization capabilities, effectively improving the quality and efficiency of production verification.

[0095] Based on the above case handling method, the present disclosure also provides a case handling device. Figure 6 Describe the device in detail.

[0096] Figure 6 The structural block diagram of a case processing device according to an embodiment of the present disclosure is schematically shown.

[0097] As Figure 6 shown, the case processing device 600 of this embodiment includes a generation module 610, a screening module 620, a sorting module 630, and a sending module 640.

[0098] The generation module 610 is used to generate N initial test cases based on production cases and requirement texts, where the requirement text is used to indicate the change information for the source code of the production case, and N is an integer greater than or equal to 2. In one embodiment, the generation module 610 can be used to perform the operation S210 described above, which will not be elaborated here.

[0099] The screening module 620 is used to screen M target test cases that meet preset conditions from the N initial test cases, where 0 < M ≤ N and M is an integer. In one embodiment, the screening module 620 can be used to perform the operation S220 described above, which will not be elaborated here.

[0100] The sorting module 630 is used to perform priority sorting on the M target test cases based on code quality metrics when it is determined that M ≥ 2, where the code quality metrics are used to indicate the risk situation of the target test cases. In one embodiment, the sorting module 630 can be used to perform the operation S230 described above, which will not be elaborated here.

[0101] The sending module 640 is used to sequentially send the sorted M target test cases to the test environment in the order of priority, so as to sequentially execute the target test cases in the test environment. In one embodiment, the sending module 640 can be used to perform the operation S240 described above, which will not be elaborated here.

[0102] According to the embodiment of the present disclosure, through the linkage of the above four modules, the entire case processing device for production verification realizes automated and intelligent full - life - cycle management, improving the test efficiency and quality level of software products.

[0103] According to the embodiment of the present disclosure, the sorting module 630 may include an extraction unit, a first sub - screening unit, a determination unit, and a sub - sorting unit.

[0104] For each target test case in the M target test cases: the extraction unit is used to extract features of the target test case based on the code quality index to obtain initial features. The first sub-screening unit is used to screen the initial features to obtain target features. The determination unit is used to determine the risk assessment value for the target test case based on the feature value corresponding to the target feature and the weight value corresponding to the target feature. The sub-sorting unit is used to prioritize the M target test cases based on the risk assessment value of each target test case.

[0105] According to an embodiment of the present disclosure, code quality indicators include at least one of the following: code complexity, code change frequency, and defect density; based on the code quality indicators, feature extraction is performed on the target test case to obtain initial features, including: based on code complexity, extracting cyclomatic complexity, number of lines of code, and method length features from the target test case to obtain initial features; and / or based on code change frequency, extracting code change count features from the target test case to obtain initial features; and / or based on defect density, extracting features of the ratio of the number of defects to the number of lines of code from the target test case to obtain initial features.

[0106] According to an embodiment of the present disclosure, the screening module 620 includes: a vector conversion unit and a second sub-screening unit. The vector conversion unit is used to perform vector conversion on each of the N initial test cases to obtain N vectors, wherein the initial test cases correspond to the vectors one by one. The second sub-screening unit is used to screen M target test cases that meet preset conditions from the N initial test cases based on the similarity between any two vectors in the N vectors.

[0107] According to an embodiment of the present disclosure, vector conversion is performed on each of N initial test cases to obtain N vectors, including: for each of the N initial test cases: converting the initial test case into an image in a structured form; and converting the image into a vector based on graph embedding technology.

[0108] According to an embodiment of the present disclosure, based on the similarity between any two vectors among N vectors, M target test cases that meet preset conditions are screened from N initial test cases, including: in the case where it is determined that the similarity between any two vectors among the N vectors is greater than a threshold, a first vector pair whose similarity is greater than the threshold and a second vector pair whose similarity is less than or equal to the threshold are determined; in the case where it is determined that there is no common vector between the first vector pair and the second vector pair, an initial test case corresponding to any one vector in the first vector pair and an initial test case corresponding to a vector in the second vector pair are determined as target test cases; and in the case where it is determined that there is a common vector between the first vector pair and the second vector pair, an initial test case corresponding to a vector in the second vector pair is determined as a target test case.

[0109] According to an embodiment of the present disclosure, the change information includes a change code snippet; the generation module 610 may include: a parsing unit and a derivation unit. The parsing unit is used to parse the production case based on the structure, annotations and requirement specification of the source code to obtain project information. The derivation unit is used to derive and generate N initial test cases based on the change code snippet and the project information.

[0110] According to an embodiment of the present disclosure, any multiple modules of the generation module 610, the screening module 620, the sorting module 630 and the sending module 640 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the generation module 610, the screening module 620, the sorting module 630 and the sending module 640 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, at least one of the generation module 610, the screening module 620, the sorting module 630 and the sending module 640 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

[0111] Figure 7 A block diagram of an electronic device suitable for implementing a case handling method according to an embodiment of the present disclosure is schematically shown.

[0112] like Figure 7 As shown, the electronic device 700 according to an embodiment of the present disclosure includes a processor 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 to a random access memory (RAM) 703. The processor 701 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 701 may also include an onboard memory for caching purposes. The processor 701 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0113] In RAM 703, various programs and data required for the operation of electronic device 700 are stored. Processor 701, ROM 702 and RAM 703 are connected to each other via bus 704. Processor 701 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 702 and / or RAM 703. It should be noted that the program can also be stored in one or more memories other than ROM 702 and RAM 703. Processor 701 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in one or more memories.

[0114] According to an embodiment of the present disclosure, the electronic device 700 may further include an input / output (I / O) interface 705, which is also connected to the bus 704. The electronic device 700 may further include one or more of the following components connected to the input / output (I / O) interface 705: an input portion 706 including a keyboard, a mouse, etc.; an output portion 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 708 including a hard disk, etc.; and a communication portion 709 including a network interface card such as a LAN card, a modem, etc. The communication portion 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the input / output (I / O) interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage portion 708 as needed.

[0115] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0116] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 702 and / or RAM 703 described above and / or one or more memories other than ROM 702 and RAM 703.

[0117] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided by the embodiment of the present disclosure.

[0118] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 701. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0119] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 709, and / or installed from the removable medium 711. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0120] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the processor 701, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.

[0121] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).

[0122] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0123] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0124] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A case handling method, characterized in that: The method includes: Generating N initial test cases based on production cases and requirement texts, where the requirement texts are used to indicate change information for the source code of the production cases, and N is an integer greater than or equal to 2; Selecting M target test cases that meet preset conditions from the N initial test cases, where 0 < M ≤ N and M is an integer; When it is determined that M ≥ 2, performing priority ranking on the M target test cases based on code quality metrics, where the code quality metrics are used to indicate the risk situation of the target test cases; and Sending the sorted M target test cases to the test environment in the order of priority, so as to sequentially execute the target test cases in the test environment.

2. The method according to claim 1, characterized in that The performing priority ranking on the M target test cases based on code quality metrics when it is determined that M ≥ 2 includes: For each target test case among the M target test cases: Performing feature extraction on the target test case based on the code quality metrics to obtain initial features; Filtering the initial features to obtain target features; Determining a risk assessment value for the target test case based on the feature value corresponding to the target feature and the weight value corresponding to the target feature; Performing priority ranking on the M target test cases based on the risk assessment value of each target test case.

3. The method according to claim 2, characterized in that The code quality metrics include at least one of the following: code complexity, code change frequency, defect density; The performing feature extraction on the target test case based on the code quality metrics to obtain initial features includes: Extracting cyclomatic complexity, lines of code, and method length features from the target test case based on the code complexity to obtain the initial features; and / or Extracting the code change count feature from the target test case based on the code change frequency to obtain the initial features; and / or Extracting the ratio feature of the number of defects to the lines of code from the target test case based on the defect density to obtain the initial features.

4. The method according to claim 1, characterized in that The selecting M target test cases that meet preset conditions from the N initial test cases includes: Performing vector conversion on each of the N initial test cases respectively to obtain N vectors, where the initial test cases and the vectors are in one-to-one correspondence; and Selecting M target test cases that meet preset conditions from the N initial test cases based on the similarity between any two of the N vectors.

5. The method according to claim 4, characterized in that The performing vector conversion on each of the N initial test cases respectively to obtain N vectors includes: For each of the N initial test cases: Converting the initial test case into a structured form of an image; and Converting the image into the vector based on graph embedding technology.

6. The method according to claim 4, characterized in that The selecting M target test cases that meet preset conditions from the N initial test cases based on the similarity between any two of the N vectors includes: When it is determined that the similarity between any two of the N vectors is greater than a threshold, determine the first vector pairs with similarity greater than the threshold and the second vector pairs with similarity less than or equal to the threshold; When it is determined that there is no common vector between the first vector pairs and the second vector pairs, determine the initial test cases corresponding to any one vector in the first vector pairs and the initial test cases corresponding to the vectors in the second vector pairs as the target test cases; and When it is determined that there is a common vector between the first vector pairs and the second vector pairs, determine the initial test cases corresponding to the vectors in the second vector pairs as the target test cases.

7. The method according to any one of claims 1 to 6, characterized in that: The change information includes change code snippets; Generating N initial test cases based on the production cases and the requirement texts includes: Analyzing the production cases based on the structure, comments of the source code and the requirement specification to obtain project information; And Deriving and generating N of the initial test cases based on the change code snippets and the project information.

8. A case processing device, characterized in that: The apparatus includes: A generating module, configured to generate N initial test cases based on production cases and requirement texts, where the requirement texts are used to indicate change information of the source code for the production cases, and N is an integer greater than or equal to 2; A screening module, configured to screen M target test cases that meet preset conditions from the N initial test cases, where 0 < M ≤ N and M is an integer; A sorting module, configured to, when it is determined that M ≥ 2, perform priority sorting on the M target test cases based on code quality metrics, where the code quality metrics are used to indicate the risk situation of the target test cases; and A sending module, configured to sequentially send the sorted M target test cases to a test environment in the order of priority, so as to sequentially execute the target test cases in the test environment.

9. An electronic device, comprising: One or more processors; A memory, configured to store one or more computer programs, Characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: The computer program or instruction, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.

11. A computer program product comprising a computer program or instructions, characterized in that The computer program or instruction, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Software test case test method and system

    CN120336195A