Test case screening method and device, equipment, storage medium and program product
By obtaining the variable code line information of the software to be tested and obtaining alternative test cases in the test case library, the target test cases are determined based on the quality score, and the problems of low precision and poor quality of test case screening in the existing technology are solved, and efficient and automated test case screening is achieved.
Patent Information
- Application Number
- CN202411954474.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-03-28
AI Technical Summary
In the prior art, the screening accuracy and poor quality of test cases have resulted in the need of manual further screening, which increases the workload and time cost.
By obtaining the changing line of code information of the software to be tested, an alternative test case is obtained in the test case library, and the target test case is determined from it based on the quality score. The quality score is calculated based on the operation dimension indicators, the code-related dimension indicators and the coverage indicators.
It improves the accuracy and quality of test case screening, reduces labor investment costs, and improves testing efficiency.
Smart Images

Figure CN119718958A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a test case screening method, device, equipment, storage medium and program product. Background Art
[0002] After the software development is completed, corresponding test cases need to be written to test whether the corresponding functions of the software can be realized. With the popularization of automated testing, the number of test case scripts is also increasing. For specific testing needs, how to effectively screen out suitable and high-quality test cases is an important challenge.
[0003] In the existing technology, text similarity algorithms (such as TF-IDF, cosine similarity, Word2Vec, etc.) are used to match and filter test case scripts. The filtering effect is highly dependent on the structural design of the test case text. If the text design is not standardized or consistent, the matching effect will be unsatisfactory, and a large matching result set will be output, which requires further manual screening, increasing the workload and time cost.
[0004] This section is intended to provide a background or context to the embodiments of the invention recited in the claims. No admission is made that the description herein is prior art by inclusion in this section. Summary of the invention
[0005] The present application provides a test case screening method, device, equipment, storage medium and product to solve the problems of low accuracy and poor quality in test case screening.
[0006] In a first aspect, the present application provides a test case screening method, the test case screening method comprising:
[0007] Get the changed code line information of the software to be tested;
[0008] Obtaining alternative test cases in a test case library according to the changed code line information; the alternative test cases include test cases covering the changed code line information;
[0009] Query the quality score of the candidate test case. The quality score of the candidate test case is calculated based on the running dimension index, code involvement dimension index and coverage index of the candidate test case.
[0010] Based on the quality scores of the candidate test cases, target test cases are determined from the candidate test cases.
[0011] In one embodiment, obtaining the changed code line information of the software to be tested specifically includes:
[0012] Obtain and parse the current code information of the target branch of the software to be tested and the original code information of the previous version;
[0013] The changed code line information is generated according to the code difference between the current code information and the original code information; the changed code line information includes the changed file, the changed method, the changed line and the changed type information.
[0014] In one embodiment, alternative test cases are obtained in a test case library according to the changed code line information; the alternative test cases include test cases covering the changed code line information, specifically including:
[0015] If the change type in the changed code line information is addition and / or modification, obtain the change method in the changed code line information;
[0016] Based on the change method, all test cases that cover the change method are filtered out in the test case library.
[0017] In one embodiment, determining a target test case from the candidate test cases based on the quality scores of the candidate test cases includes:
[0018] In descending order of quality scores, the candidate test cases that meet the preset threshold number are selected as target test cases.
[0019] In one embodiment, before querying the quality scores of the candidate test cases, the method further includes:
[0020] Based on the historical running data of the test cases in the test case library, obtain the indicator information of the test cases in the test case library;
[0021] The quality score of the test case is calculated based on the indicator information of the test case.
[0022] In one embodiment, calculating the quality score of the test case based on the indicator information of the test case specifically includes:
[0023] Preprocess the indicator information, including data cleaning, null value processing and correlation analysis;
[0024] The different characteristic indicators in the preprocessed indicator information are binned, and the evidence weight and the logistic regression coefficient of different characteristic indicators are calculated for each binned data;
[0025] The quality scores of the test cases were determined based on the weight of evidence and the logistic regression coefficients of different feature indicators.
[0026] In one embodiment, calculating the quality score of the test case based on the indicator information of the test case includes:
[0027] The indicator information is input into a pre-trained scoring model to obtain a quality score of the test case. The scoring model is specifically used to generate a quality score of the test case based on the indicator information of the test case.
[0028] In one embodiment, the operation dimension indicators include long-term execution times, long-term success rates, recent execution times, and recent success rates;
[0029] The dimensional indicators involved in the code include the number of assertions and automation indicators. The number of assertions is used to characterize the error detection capability of the test case; the automation indicator is used to characterize the degree of automation of the test case.
[0030] Coverage indicators include case coverage, which is used to characterize the coverage of test cases for changed code line information.
[0031] In a second aspect, an embodiment of the present application provides a test case screening device, comprising:
[0032] The acquisition module is used to obtain the changed code line information of the software to be tested, and obtain the candidate test cases in the test case library according to the changed code line information;
[0033] A determination module is used to query the quality scores of alternative test cases. The quality scores of alternative test cases are calculated based on the running dimension indicators, code involvement dimension indicators and coverage indicators of the alternative test cases. Based on the quality scores of the alternative test cases, target test cases are determined from the alternative test cases.
[0034] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0035] Memory stores computer-executable instructions;
[0036] The processor executes the computer-executable instructions stored in the memory to implement any of the above methods.
[0037] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement any of the above methods.
[0038] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements any of the above methods when executed by a processor.
[0039] The present application provides a test case screening method, including: obtaining the changed code line information of the software to be tested; obtaining alternative test cases in the test case library according to the changed code line information; the alternative test cases include test cases that cover the changed code line information; querying the quality score of the alternative test case, the quality score of the alternative test case is calculated based on the running dimension index, code involved dimension index and coverage index of the alternative test case in advance; based on the quality score of the alternative test case, determining the target test case from the alternative test case. The present application preliminarily screens out the alternative test cases by parsing the changed code line information of the software to be tested, and determines the target test case after querying the quality score of the alternative test case. After double screening, the screening accuracy and quality are high, and the testing efficiency is improved; secondly, the labor input cost is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0041] Figure 1 A flowchart of a test case screening method provided in an embodiment of the present application;
[0042] Figure 2 A flowchart of a test case screening method provided in an embodiment of the present application;
[0043] Figure 3 A schematic diagram of the structure of a test case screening device provided in one embodiment of the present application.
[0044] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0045] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0046] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application 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 the relevant laws, regulations and standards of the relevant countries and regions, 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.
[0047] In addition, this application involves conducting big data analysis of user information (including but not limited to personal biometrics, identity data, consumption data, asset data, electronic terminal operation data, etc.), and using artificial intelligence technology to make automated decisions, and making technical solutions that have a significant impact on personal rights and interests based on the results of automated decisions. The application provides users with corresponding operation entrances for them to choose to agree or reject the results of automated decisions; if the user chooses to reject, the expert decision-making process will be entered.
[0048] It should be noted that the test case screening method, device, equipment, storage medium and product provided in this application can be used in the field of big data, and can also be used in any field other than the field of big data. The application field of the test case screening method, device, equipment, storage medium and product in this application is not limited.
[0049] After the software is developed, it is necessary to write corresponding test cases to test whether the corresponding functions of the software can be realized. With the popularization of automated testing, the number of test case scripts is also increasing. According to specific test requirements, the existing technology uses text similarity algorithms (such as TF-IDF, cosine similarity, Word2Vec, etc.) to match and filter test case scripts. The screening effect is highly dependent on the structural design of the test case text. If the text design is not standardized or consistent, the matching effect will be unsatisfactory, and a large matching result set will be output, which requires further manual screening, increasing the workload and time cost.
[0050] The test case screening method provided by the present application includes: obtaining the changed code line information of the software to be tested; obtaining alternative test cases in the test case library according to the changed code line information; the alternative test cases include test cases that cover the changed code line information; querying the quality score of the alternative test case, the quality score of the alternative test case is calculated based on the running dimension index, code involved dimension index and coverage index of the alternative test case in advance; based on the quality score of the alternative test case, determining the target test case from the alternative test case. The present application preliminarily screens out the alternative test cases by parsing the changed code line information of the software to be tested, and determines the target test case after querying the quality score of the alternative test case. After double screening, the screening accuracy and quality are high, and the testing efficiency is improved; secondly, the labor input cost is reduced.
[0051] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0052] like Figure 1 As shown, Figure 1 This is a flowchart of a test case screening method provided in an embodiment of the present application. The test case screening method includes the following steps:
[0053] Step S102: Obtain the changed code line information of the software to be tested.
[0054] Specifically, the specific code lines involved in the update or modification in the software to be tested are identified so as to perform targeted screening in the test case library, and the changed code line information can be obtained through a version control system (such as Git).
[0055] Step S104: Obtain candidate test cases in the test case library according to the changed code line information; the candidate test cases include test cases covering the changed code line information.
[0056] Specifically, test cases that can cover the changed code line information are screened out from the test case library, and code coverage tools or historical coverage data are used to identify which test cases have covered these changed code lines, thereby forming a set of candidate test cases. Optionally, candidate test cases can be screened out based on the change methods in the changed code line information that can be covered. The number of candidate test cases is not limited in this application.
[0057] Step S106: query the quality score of the candidate test case, where the quality score of the candidate test case is calculated based on the pre-estimated running dimension index, code involvement dimension index and coverage index of the candidate test case.
[0058] Specifically, the quality score of each candidate test case is calculated, and the score is obtained by combining the following dimensional indicators: among them, the running dimensional indicator is used to reflect the execution success rate, stability, execution time and other capabilities of the test case; the code involvement dimensional indicator is used to reflect the code complexity, module importance and other capabilities involved in the test case; the coverage indicator is used to analyze the coverage of the test case for code lines, branches, paths, etc.
[0059] Step S108: Determine a target test case from the candidate test cases based on the quality scores of the candidate test cases.
[0060] Specifically, target test cases are determined from candidate test cases according to their quality scores to ensure the effectiveness and efficiency of the test, and candidate test cases are sorted according to their quality scores, and the test cases with the highest scores are selected as target test cases. These target test cases should be able to cover the changed code to the greatest extent while ensuring quality, so as to improve the test efficiency.
[0061] This application analyzes the code line information of the tested software to effectively select the most relevant and high-quality test cases from a large number of test cases. This method not only takes code coverage into consideration, but also comprehensively evaluates the execution effect of the test cases and the code involvement, thereby improving the accuracy and efficiency of the test.
[0062] In one embodiment, step S102 specifically includes the following steps:
[0063] Obtain and parse the current code information of the target branch of the software to be tested and the original code information of the previous version.
[0064] The changed code line information is generated according to the code difference between the current code information and the original code information; the changed code line information includes the changed file, the changed method, the changed line and the changed type information.
[0065] Specifically, the current code information of the target branch of the software to be tested is obtained, and the latest baseline under the target branch and the last baseline of the previous version are parsed to obtain two baseline codes respectively. The last baseline of the previous version, i.e., the original code information, is used as the starting baseline, and the latest baseline under the target branch is used as the ending baseline. The syntax tree technology is used to compare and generate the changed files, changed methods, changed lines, change types (new additions, modifications, deletions), and other information of the ending baseline and the starting baseline.
[0066] In one embodiment, step S104 specifically includes the following steps:
[0067] If the change type in the changed code line information is addition and / or modification, the change method in the changed code line information is obtained.
[0068] Based on the change method, all test cases that cover the change method are filtered out in the test case library.
[0069] Specifically, obtain the changed code line information, obtain the changed file from it, find the changed method and changed line in the changed file, and filter out the test cases that cover the changed lines in the changed method in the test case library according to the changed method. If the code change type is deleted, the code under the target branch no longer exists and cannot be tested after deletion, so it is impossible to filter the candidate test cases according to the changed method with the change type of deletion.
[0070] In one embodiment, step S108 includes the following steps:
[0071] In descending order of quality scores, the candidate test cases that meet the preset threshold number are selected as target test cases.
[0072] Specifically, the number of target preset cases can be output according to a set preset threshold value, and the operator can set the preset threshold value according to actual conditions, which is not limited in this application.
[0073] In one embodiment, before step S106, the following steps are specifically included: Figure 2 As shown, Figure 2 A flowchart of a test case screening method provided in an embodiment of the present application:
[0074] Step S202: Based on the historical running data of the test cases in the test case library, obtain the indicator information of the test cases in the test case library.
[0075] Step S204: Calculate the quality score of the test case based on the indicator information of the test case.
[0076] Specifically, the scoring model analyzes the indicator information of all test cases in the test case library, and obtains the quality score of each test case based on the indicator information. According to the scoring model, the quality score of each test case can also be accurately known, which is convenient for subsequent search and screening.
[0077] In one embodiment, the operation dimension indicators include long-term execution times, long-term success rate, recent execution times and recent success rate.
[0078] The dimensional indicators involved in the code include the number of assertions and automation indicators; among them, the number of assertions is used to characterize the error detection capability of the test case; the automation indicator is used to characterize the degree of automation of the test case.
[0079] Coverage indicators include case coverage, which is used to characterize the coverage of test cases for changed code line information.
[0080] Specifically, the operation dimension indicators include the long-term execution times, the long-term success rate, the recent execution times and the recent success rate. The operation dimension indicators are used to characterize the historical execution of the test case; among them, the long-term execution times and the long-term success rate are used to characterize the execution times of the test case in the past month and the successful execution times in the past month respectively; the recent execution times and the recent success rate are used to characterize the execution times of the test case in the past three days or the successful execution times in the past three days respectively. In this application, the long-term execution times and the long-term success rate are used to characterize the execution times of the test case in the past month and the successful execution times of the test case in the past month respectively, which is just one example. In other examples, the long-term execution times and the long-term success rate can also be used to characterize the execution times of the test case in the past week and the successful execution times in the past week. The specific characterization needs to be determined according to the actual situation, and this application does not limit it.
[0081] The code-involved dimension indicators include the number of assertions and automation; the code-involved dimension indicators are used to characterize whether the design and configuration of the test case are reasonable; among them, the number of assertions is used to characterize the error detection capability of the test case; automation is used to characterize the functional value of the test case. In the example of this application, the code-involved dimension also includes whether it involves account processing (key information in the financial field), whether it is an important branch for customers, and whether it is a core processing branch, reflecting the importance of the code involved.
[0082] Coverage indicators include case coverage, which is used to characterize the coverage of test cases for changed code line information; case coverage is used to characterize the line coverage of each test case for specific code.
[0083] Specifically, as shown in Table 1 below, Table 1 is the indicator information of the test case. The running dimension indicator is used to characterize the execution success rate, execution time and stability of the test case, that is, the historical execution situation. For example, the larger the "long-term execution times" of the test case, the higher the "long-term success rate", indicating that it has "long-term stability", and similarly, "short-term stability" can be inferred. The code involvement dimension also includes whether it involves account processing (key information in the financial field), whether it is an important branch for customers, and whether it is a core processing branch, reflecting the importance of the code involved. Among them, the more assertions, the higher the error detection ability of the test case, and the automated case has more functional value than the manual execution case. The coverage index includes the name of the covered method and the corresponding number of lines of the covered method. For example, the more lines of changed code that can be covered, the higher the value of its coverage index. By comprehensively analyzing the indicator information of the test case, it is beneficial to the quality scoring of the subsequent scoring model; secondly, this solution provides a more comprehensive and unified quality evaluation standard.
[0084] Table 1 Index information of test cases
[0085]
[0086] In one embodiment, step S204 specifically includes:
[0087] Preprocess the indicator information, including data cleaning, null value processing and correlation analysis;
[0088] Specifically, the metric information of the test cases is cleaned and prepared so that it can be input into the model for training and evaluation.
[0089] The different characteristic indicators in the preprocessed indicator information are binned, and the evidence weight and the logistic regression coefficient of different characteristic indicators are calculated for each binned data;
[0090] The quality score of the test case is determined based on the weight of evidence and the logistic regression coefficients of different feature indicators.
[0091] In one embodiment, calculating the quality score of the test case based on the indicator information of the test case includes:
[0092] The indicator information is input into a pre-trained scoring model to obtain a quality score of the test case. The scoring model is specifically used to generate a quality score of the test case based on the indicator information of the test case.
[0093] Specifically, the preprocessed data is used to train the scoring model so that it can accurately evaluate the quality of the test cases; the performance of the model on unseen data is evaluated to ensure its accuracy and reliability; and each test case is scored for the variation method using the trained scoring model. The quality score reflects the overall quality of the test case and its coverage of the variation method.
[0094] This solution can effectively evaluate the quality of test cases. Data preprocessing ensures the quality of input data, model training and evaluation ensure the accuracy and reliability of the scoring model, and the final quality score provides an objective basis for selecting appropriate test cases. This method not only improves the efficiency of test case selection, but also enhances the automation and intelligence of the test process.
[0095] Specifically, the indicator information of the test case (including the relevant indicators in Table 1) is input into the database, and the required data is accessed through the API service; the scoring model is trained, and the training data is shown in Table 2. Table 2 is only an example, and the actual training data is huge, so it is inconvenient to list them one by one in this application.
[0096] Table 2: Training data for model training of scoring model
[0097]
[0098] Clean the training data: convert the typical data into numerical values: "yes" is converted to 1, and "no" is converted to 0. Process the null values of the training data: for numerical indicators, the null values are filled with the default value 0; for typical indicators, the null values are filled with the default value 0 (that is, "no"); for character indicators, if there is a null value, the data is deleted. Perform correlation analysis on the data in the training data: calculate the Pearson correlation coefficient. If the correlation coefficient of two indicators is greater than 0.5, only one of the data is retained. Bin the training data: bin the data for different feature indicators. After binning, the data are converted into discrete indicators. Convert continuous variables into discrete variables to better handle nonlinear relationships.
[0099] Calculate the evidence weight of the training data, where the evidence weight of the training data is shown in formula (1):
[0100] Formula (1)
[0101] Among them, p y0 It refers to the ratio of the number of bad samples Badi in the i-th group to the number of bad samples BadT, p y1 It refers to the ratio of the number of good samples Goodi in the i-th group to the number of all good samples GoodT. WOE i The value actually represents the difference in the ratio of bad samples and good samples in the current i-th group to all bad samples and all good samples.
[0102] Calculate the information value of each binned data, where the information value is calculated as shown in formula (2):
[0103] Formula (2)
[0104] The IV value of each indicator is the sum of the IV values of each bin in the indicator: , delete indicators with IV values less than 0.03.
[0105] The training data is replaced with discrete values after binning, and divided into a training set (70%) and a test set (30%). The scoring model is used for model training, and the logistic regression model is used for training to obtain the logistic regression coefficients. , the larger the absolute value of a variable's coefficient, the greater its impact on the prediction result. A positive number indicates a positive correlation, and a negative number indicates a negative correlation. Model evaluation: Use the ROC curve and AUC value to evaluate the model. Evaluate the performance of the model on unseen data to ensure its accuracy and reliability. Among them, the ROC curve is a curve that plots the relationship between the true positive rate (TPR) and the false positive rate (FPR). Calculate the area under the ROC curve. The closer the AUC value is to 1, the better the model performance.
[0106] The quality score of a test case is calculated as follows:
[0107]
[0108]
[0109] in, is the logistic regression coefficient corresponding to each item, score is the calculated quality score of each test case for each change method, and B is a constant value, which is generally set to : The larger the odds value, the larger the calculated score value.
[0110] The present application inputs the candidate test cases into the scoring model to obtain the quality scores of the candidate test cases, sorts the candidate test cases according to the quality scores, and outputs the target test cases according to the preset threshold.
[0111] like Figure 3 As shown, Figure 3 A structural schematic diagram of a test case screening device provided for an embodiment of the present application, the test case screening device comprising: an acquisition module, used to obtain the changed code line information of the software to be tested, and to obtain alternative test cases in the test case library according to the changed code line information; a determination module, used to query the quality score of the alternative test case, the quality score of the alternative test case being calculated based on the running dimension index, the code involvement dimension index and the coverage index of the alternative test case in advance; based on the quality score of the alternative test case, determining the target test case from the alternative test case.
[0112] An embodiment of the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement any of the above methods.
[0113] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement any of the above methods.
[0114] An embodiment of the present application provides a computer program product, including a computer program, which implements any of the above methods when executed by a processor.
[0115] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0116] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0117] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0118] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0119] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory (RRAM), a dynamic random access memory (DRAM), a static random access memory (SRAM), an enhanced dynamic random access memory (EDRAM), a high-bandwidth memory (HBM), a hybrid memory cube (HMC), etc.
[0120] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, 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. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory 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.
[0121] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0122] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0123] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A test case screening method, characterized in that: The test case screening method comprises: Get the changed code line information of the software to be tested; Acquire alternative test cases in a test case library according to the changed code line information; the alternative test cases include test cases covering the changed code line information; Querying the quality score of the candidate test case, where the quality score of the candidate test case is calculated by pre-estimating the running dimension index, code involvement dimension index and coverage index of the candidate test case; Based on the quality scores of the candidate test cases, a target test case is determined from the candidate test cases.
2. The test case screening method according to claim 1, characterized in that: Get the changed code line information of the software to be tested, including: Obtain and parse the current code information of the target branch of the software to be tested and the original code information of the previous version; The changed code line information is generated according to the code difference between the current code information and the original code information; the changed code line information includes changed files, changed methods, changed lines and changed type information.
3. The test case screening method according to claim 2, characterized in that: Acquire alternative test cases in a test case library according to the changed code line information; the alternative test cases include test cases covering the changed code line information, specifically including: If the change type in the changed code line information is addition and / or modification, obtaining the change method in the changed code line information; Based on the change method, test cases that completely cover the change method are screened out from the test case library.
4. The test case screening method according to claim 1, characterized in that: Determining a target test case from the candidate test cases based on the quality scores of the candidate test cases includes: According to the order of quality scores from high to low, the candidate test cases that meet the preset threshold quantity are used as the target test cases.
5. The test case screening method according to claim 1, characterized in that: Before querying the quality score of the candidate test case, the method further includes: Based on the historical running data of the test cases in the test case library, obtaining the indicator information of the test cases in the test case library; A quality score of the test case is calculated based on the indicator information of the test case.
6. The test case screening method according to claim 5, characterized in that: The calculating the quality score of the test case based on the indicator information of the test case specifically includes: Preprocessing the indicator information, the preprocessing including: data cleaning, null value processing and correlation analysis; Binning the different characteristic indicators in the preprocessed indicator information, and calculating the weight of evidence and the logistic regression coefficients of different characteristic indicators for each binned data; The quality score of the test case is determined according to the evidence weight and the logistic regression coefficients of different feature indicators.
7. The test case screening method according to claim 5, characterized in that: The calculating the quality score of the test case based on the indicator information of the test case includes: The indicator information is input into a pre-trained scoring model to obtain a quality score of the test case, wherein the scoring model is specifically used to generate a quality score of the test case according to the indicator information of the test case.
8. The test case screening method according to claim 5, characterized in that: The operation dimension indicators include long-term execution times, long-term success rate, recent execution times and recent success rate; The dimensional indicators involved in the code include the number of assertions and the automation index; wherein the number of assertions is used to characterize the error detection capability of the test case; the automation index is used to characterize the degree of automation of the test case; The coverage index includes case coverage, and the coverage index is used to characterize the coverage of the changed code line information by the test case.
9. A test case screening device, characterized in that: include: An acquisition module is used to acquire the changed code line information of the software to be tested, and acquire alternative test cases in the test case library according to the changed code line information; A determination module is used to query the quality score of the candidate test case, where the quality score of the candidate test case is calculated by pre-estimating the running dimension index, code involvement dimension index and coverage index of the candidate test case; Based on the quality scores of the candidate test cases, a target test case is determined from the candidate test cases.
10. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.
12. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 8 when being executed by a processor.