Test case screening method, device, computer equipment and storage medium

By identifying code modification tags and calculating the number of failures, target test cases are screened, which solves the problems of long test cycles and poor coverage in traditional testing methods, and achieves fast and efficient test case screening and regression testing.

CN110489321BActive Publication Date: 2024-09-13PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910610425.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-07-08
Publication Date
2024-09-13
Estimated Expiration
2039-07-08

AI Technical Summary

Technical Problem

After the business system code is modified, traditional testing methods need to execute all test cases, resulting in a long test cycle and poor coverage, making it impossible to quickly and accurately modify part of the code.

Method used

By identifying code modification tags, recording test results, calculating the number of failures, filtering out test cases whose failure times reach a preset value as target use cases, and generating a mapping table for regression testing to improve the pertinence of test cases.

Benefits of technology

It is possible to quickly and efficiently screen out key test cases after code modification, improve test coverage, shorten the test cycle, and ensure the pertinence and accuracy of the test.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110489321B
    Figure CN110489321B
Patent Text Reader

Abstract

The present application relates to a test case screening method, device, computer equipment and storage medium. The method includes: when a code file to be tested is detected each time, the code modification label of the code file to be tested is identified, and the code modification label is stored in a history table; multiple test cases are obtained, and multiple test cases are executed based on each code file to be tested; the test cases with test results of test failure are associated with the corresponding code modification labels, and the corresponding association relationship is recorded in the history table; the number of failures of each test case associated with each code modification label is calculated based on the history table; according to the number of failures of each code modification label and each associated test case, the target test case corresponding to each code modification label is determined. The use of this method can improve the pertinence of test cases when testing business systems after code modification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a test case screening method, apparatus, computer equipment and storage medium. Background Art

[0002] With the development of computer technology, the business areas involved in business systems have become increasingly large and complex. As the demand for business systems continues to update, the development code of business systems will also be continuously improved and optimized. In order to ensure the normal operation of the business system, regression testing of the business system is required after each code file is modified and updated. In the traditional way, all test cases need to be executed to test the business system. However, the number of test cases is large, and it is difficult to quickly and accurately complete all test cases for the modified part of the code, resulting in a long test cycle. If only some test cases are executed for the modified part of the code, it is easy to lead to poor coverage of the test cases and the system is not comprehensive enough. As a result, when testing the business system after the code is modified, the test cases are less targeted. Summary of the invention

[0003] Based on this, it is necessary to provide a test case screening method, device, computer equipment and storage medium that can improve the pertinence of test cases when testing a business system after code modification in response to the above technical problems.

[0004] A test case screening method, the method comprising: when a code file to be tested is detected each time, identifying the code modification tag of the code file to be tested, and storing the code modification tag in a history table; obtaining multiple test cases, executing the multiple test cases based on each code file to be tested, and obtaining test results; the test results include test failures; associating the test cases with test results of test failure with the corresponding code modification tags, and recording the corresponding association relationship in the history table; calculating the number of failures of each test case associated with each code modification tag based on the history table; determining the test case whose failure number reaches a preset value as the target test case corresponding to the corresponding code modification tag.

[0005] In one of the embodiments, the method also includes: generating a mapping table based on multiple code modification tags and screened target test cases corresponding to each code modification tag; when a newly uploaded code file to be tested is detected again, identifying the tag to be matched of the code file to be tested; searching the mapping table for a code modification tag that matches the tag to be matched; and performing regression testing on the code file to be tested based on the target test cases corresponding to the matched code modification tags.

[0006] In one of the embodiments, the code file to be tested carries version information, and identifying the code modification tag of the code file to be tested includes: searching for a historical code file of a previous version corresponding to the version information; comparing the code file to be tested and the historical code file to obtain a difference code fragment; and generating a corresponding code modification tag based on the difference code fragment.

[0007] In one of the embodiments, generating a corresponding code modification tag according to the difference code fragment includes: identifying multiple modification information of the difference code fragment; creating corresponding modification sub-tags according to each modification information; and splicing multiple modification sub-tags to generate a code modification tag.

[0008] In one of the embodiments, associating the test cases whose test results are test failures with corresponding code modification tags, and recording the corresponding association relationships in the history table, includes: associating each modification sub-tag with multiple test failure cases corresponding to the corresponding modification sub-tag and recording them in the history table; and calculating the number of failures of each test case associated with each code modification tag based on the history table, includes: calculating the number of failures of each test case associated with each modification sub-tag based on the history table.

[0009] In one of the embodiments, the test case whose failure times reach a preset value is determined as the target test case corresponding to the corresponding code modification tag, including: calculating the sub-failure rate of each test case corresponding to each modification sub-tag according to the failure times of each test case associated with each modification sub-tag; calculating the comprehensive failure rate of each test case corresponding to the code modification tag according to the sub-failure rates corresponding to multiple modification sub-tags corresponding to the code modification tag; and determining the test case whose comprehensive failure rate is greater than a preset threshold as the target test case of the corresponding code modification tag.

[0010] A test case screening device, the device comprising: an identification module, used to identify the code modification tag of the code file to be tested each time a code file to be tested is detected, and store the code modification tag in a history table; an execution module, used to obtain multiple test cases, execute the multiple test cases based on each code file to be tested, and obtain test results; the test results include test failures; an association module, used to associate the test cases with test results of test failure with the corresponding code modification tags, and record the corresponding association relationship in the history table; a statistical module, used to calculate the number of failures of each test case associated with each code modification tag based on the history table; a screening module, used to determine the test cases whose failure times reach a preset value as target test cases corresponding to the corresponding code modification tags.

[0011] In one of the embodiments, the identification module is further used to find the historical code file of the previous version corresponding to the version information; compare the code file to be tested with the historical code file to obtain a difference code fragment; and generate a corresponding code modification tag according to the difference code fragment.

[0012] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the test case screening method described in the above embodiments when executing the computer program.

[0013] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the test case screening method described in each of the above embodiments.

[0014] The above-mentioned test case screening method, device, computer equipment and storage medium, when the server detects the code file to be tested each time, the code modification label of the code file to be tested is identified, and the code modification label is stored in the history label. The server can obtain multiple test cases, and execute multiple test cases to be screened based on the newly uploaded modified code. The server can associate the test cases that failed the test with the corresponding code modification labels and record them in the history table. After the server detects the code file to be tested a sufficient number of times, the number of failures of each test case associated with each code modification label can be classified and counted based on the history table, so that the number of failures of each code modification label and each associated test case can be screened out to find the target test cases corresponding to each code modification label. By quantifying the characteristics of each code modification according to the code modification label, and the test results of different test cases for different code modification characteristics, the target test cases with a higher probability of failure can be accurately screened out, so that when testing the code files to be tested of the business system, the pertinence of the test cases can be improved, and the code files to be tested can be tested accurately and efficiently. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 An application scenario diagram of a test case screening method in an embodiment;

[0016] Figure 2 A schematic diagram of a flow chart of a test case screening method in an embodiment;

[0017] Figure 3 A schematic diagram of a flow chart of a test case screening method in another embodiment;

[0018] Figure 4 A structural block diagram of a test case screening device in one embodiment;

[0019] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0020] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0021] The test case screening method provided in this application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. Among them, the terminal 102 can be but not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented with an independent server or a server cluster composed of multiple servers. When the server 104 detects the code file to be tested newly uploaded by the terminal 102 each time, the code modification label of the code file to be tested is identified, and the code modification label is stored in the history label. The server 104 can obtain multiple test cases and execute multiple test cases to be screened based on the newly uploaded modified code. The server 104 can record the test cases that failed the test in the history table in association with the corresponding code modification label. When the server 104 detects enough newly uploaded code files to be tested, the number of failures of each test case associated with each code modification label can be classified and counted based on the history table, so that each code modification label and the number of failures of each associated test case can be input into the machine learning model as input data to screen out the target test cases corresponding to each code modification label.

[0022] In one embodiment, Figure 2 As shown, a test case screening method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0023] Step 202: each time a code file to be tested is detected, a code modification tag of the code file to be tested is identified, and the code modification tag is stored in a history table.

[0024] The code file to be tested refers to the code file obtained after the developer modifies the historical code file of the business system. A code file refers to an uncompiled text file written in accordance with certain programming language specifications. As the needs of the business system are constantly updated, the code files of the business system also need to be continuously updated. The code modification tag can be a tag carried by the code file to be tested, or it can be a tag automatically generated by parsing the code file to be tested. The code modification tag can reflect the relevant modification information of the code file to be tested, including but not limited to the modification type, modification content, modification location and other information.

[0025] In one embodiment, after the developer has modified the historical code file on the terminal, the developer can mark the code file to be tested with a code modification label based on the modification type, modification content, modification location and other information. Modification types include but are not limited to deletion, addition, and modification. Modification content includes but is not limited to Java classes, Java functions, corresponding business logic, etc. The modification location includes but is not limited to the starting position and the ending position of the code modification part. Through the code modification label, the actual modification of each time can be quantified, so that the developer can clearly trace the modification history of the code file of the business system based on the history table.

[0026] Step 204, obtain multiple test cases, execute the multiple test cases based on each code file to be tested, and obtain test results; the test results include test failures.

[0027] A test case is a set of input data and the corresponding expected response results used to test whether a business system can normally implement the required functions. Input data refers to data composed of multiple input parameters used to implement system functions. Expected results refer to the results that can be inferred based on the input data as defined in the interface definition document. Expected results may also include multiple output parameters. Test cases can be used to perform logic tests on business systems after code modification, such as testing whether the business system can produce correct response results under normal input conditions. For example, error tests can also be performed on business systems, such as testing whether the business system can report errors normally when abnormal input or abnormal scenario input is input.

[0028] In one embodiment, when the number of modifications is less than a preset threshold, multiple test cases to be screened need to be executed for each newly uploaded modified code. Only after obtaining sufficient test data can machine learning be performed based on the test results to analyze the test cases.

[0029] In one embodiment, a test case includes input data and multiple expected output parameters. After obtaining multiple actual output parameters by executing the test case, when any actual output parameter is inconsistent with the corresponding expected output parameter, the test case is determined to have failed; when each actual output parameter is consistent with the corresponding expected output parameter, the test case is determined to have passed.

[0030] Step 206: associate the test case with a test failure result with the corresponding code modification tag, and record the corresponding association relationship in a history table.

[0031] After executing the test case for each code file to be tested, the test result of each test case can be determined. After filtering out the test cases that failed the test, the identifiers of the test cases that failed the test can be associated with the corresponding code modification tags in the history table. As shown in the following history table 1, the history table may contain one or more of the modification version information, code modification tags, code file path, code before modification, code after modification, and associated test cases. For the code file to be tested with the modification version V1.0, the code modification tag is "Modify-ETF Fund Product-XX Type-Subscription Transaction Function", and the associated test cases are Case 1, Case 2, and Case 3; for the code file to be tested with the modification version V2.0, the code modification tag is "Modify-ETF Fund Product-XX Type-Order Payment Function", and the associated test cases are Case 2, Case 4, and Case 5.

[0032] History Table 1

[0033]

[0034] Step 208: Calculate the number of failures of each test case associated with each code modification tag based on the history table.

[0035] When the code file of the business system has been modified many times, there may be multiple code modification tags in the history table, and each code modification tag may be associated with one or more test cases that failed. The same code modification tag can be classified as a category, and the number of failures of each test case in all corresponding test cases can be counted. The higher the number of test case failures counted, the higher the probability of failure of executing the test case for the code file to be tested corresponding to the code modification tag.

[0036] Step 210: determine the test cases whose failure times reach a preset value as target test cases corresponding to the corresponding code modification tags.

[0037] The number of failures refers to the number of times the test result is a test failure. The server can determine the test cases whose failure times reach a preset value as the target test cases corresponding to the corresponding code modification labels. The server can also determine the target test cases corresponding to each code modification label based on the number of failures based on a pre-trained machine learning model. Among them, the machine learning model refers to a model that has the ability to recognize code modification labels after training. The machine learning model can adopt a neural network model, a support vector machine or a logistic regression model, etc. After a large number of code modification labels and each associated test case are input into the machine learning model, it can be used to identify test cases with a higher probability of failure corresponding to each code modification label. The trained machine learning model can be used to filter out the corresponding target test cases, that is, test cases with a higher probability of failure, according to the input code modification labels. It is easy to understand that the server can also use other methods to determine the target test cases corresponding to each code modification label according to the number of failures, and there is no limitation on this.

[0038] In the above test case screening method, when the server detects the code file to be tested each time, the code modification tag of the code file to be tested is identified, and the code modification tag is stored in the history tag. The server can obtain multiple test cases and execute multiple test cases to be screened based on the newly uploaded modified code. The server can associate the test cases that failed the test with the corresponding code modification tags and record them in the history table. After the server detects the code file to be tested enough times, the number of failures of each test case associated with each code modification tag can be classified and counted based on the history table, so that the number of failures of each code modification tag and each associated test case can be filtered out to find the target test cases corresponding to each code modification tag. By quantifying the characteristics of each code modification according to the code modification tag, and the test results of different test cases for different code modification characteristics, the target test cases with a higher probability of failure can be accurately screened out, so that when testing the code files to be tested of the business system, the pertinence of the test cases can be improved, and the code files to be tested can be tested accurately and efficiently.

[0039] In one embodiment, the method also includes: generating a mapping table based on multiple code modification tags and the screened target test cases corresponding to each code modification tag; when a newly uploaded code file to be tested is detected again, identifying the tag to be matched of the code file to be tested; searching the mapping table for a code modification tag that matches the tag to be matched; and performing regression testing on the code file to be tested based on the target test cases corresponding to the matched code modification tags.

[0040] After the target test cases corresponding to each code modification label are screened out through the machine learning model, a mapping relationship between each code modification label and the corresponding target test case can be created, and a mapping table that can be used for indexing can be generated. When it is necessary to test the newly uploaded code file to be tested, the target test case corresponding to the corresponding label to be matched can be found through the mapping table. Targeted regression testing of the code file to be tested based on some of the screened test cases can shorten the test cycle and achieve efficient testing while ensuring the coverage of the modified part of the code. Regression testing refers to retesting after modifying the historical code file to confirm that the modification has not introduced new errors or caused errors in other codes. Automatic regression testing will greatly reduce the cost of system testing, maintenance and upgrades.

[0041] In one embodiment, the code file to be tested carries version information, and identifying the code modification tag of the code file to be tested includes: searching for a historical code file of a previous version corresponding to the version information; comparing the code file to be tested with the historical code file to obtain a differential code fragment; and generating a corresponding code modification tag according to the differential code fragment.

[0042] Each time the code file to be tested is tested again on the basis of the previous version of the historical code file that has passed the test. Therefore, by comparing the difference code snippets between the code file to be tested and the previous version of the historical code file, the code difference snippets can be automatically analyzed to generate corresponding code modification tags. These difference code snippets are the code parts that were modified most recently. By automatically generating code modification tags, it is possible to avoid test case search anomalies caused by developers omitting to mark code modification tags when editing the code file to be tested.

[0043] In one embodiment, generating corresponding code modification tags according to difference code fragments includes: identifying multiple modification information of the difference code fragments; creating corresponding modification sub-tags according to each modification information; and splicing multiple modification sub-tags to generate a code modification tag.

[0044] Modification types include but are not limited to deletion, addition, and modification. Modification content includes but is not limited to Java classes, Java functions, corresponding business logic, etc. The modification location includes but is not limited to the start and end locations of the code modification portion. A code modification tag may contain modification sub-tags of multiple dimensions. For example, the code modification tag may be "Modification-ETF Fund Product-XX Type-Subscription Transaction Function", then the modification sub-tag includes the modification type "Modification", the code source "ETF Fund Product", the modification content "XX Type" and "Subscription Transaction Function". By splicing multi-dimensional modification sub-tags to generate a code modification tag, the amount of information contained in the code modification tag can be increased, thereby refining the positioning of each code file to be tested.

[0045] In one embodiment, test cases that fail the test are associated with corresponding code modification tags and recorded in a history table, including: each modification sub-tag is associated with multiple test failure cases corresponding to the corresponding modification sub-tag and recorded in the history table; the number of failures of each test case associated with each code modification tag is calculated based on the history table, including: the number of failures of each test case associated with each modification sub-tag is calculated based on the history table.

[0046] After dividing the code modification label into multiple dimensions of code modification sub-labels, an association relationship between each modification sub-label and the corresponding test case with failed tests can be created. Thus, statistics are performed based on the test cases associated with each modification sub-label to obtain the number of failures of each test case for each modification sub-label, so that the machine learning model can be trained based on these more refined data inputs.

[0047] In one embodiment, a test case whose number of failures reaches a preset value is determined as a target test case corresponding to the corresponding code modification tag, including: calculating the sub-failure rate of each test case corresponding to each modification sub-tag according to the number of failures of each test case associated with each modification sub-tag; calculating the comprehensive failure rate of each test case corresponding to the code modification tag according to the sub-failure rates corresponding to multiple modification sub-tags corresponding to the code modification tag; and determining the test case whose comprehensive failure rate is greater than a preset threshold as the target test case of the corresponding code modification tag.

[0048] After associating the failed test cases corresponding to each modification sub-label, the number of test failures and the number of tests associated with each modification sub-label can be counted; the machine learning model can first calculate the failure rate of each test case corresponding to each modification sub-label, and then calculate the failure rate of each test case corresponding to each modification sub-label through the formula Calculate the sub-failure rate Q of modifying sub-label i i , where S i is the number of test failures, C i is the number of tests; according to the sub-failure rates of a test case corresponding to the multiple modification sub-tags in the code modification tag, the test case is comprehensively scored to obtain the comprehensive failure rate. For example, the average, maximum, and median values ​​of multiple sub-failure rates can be used as the comprehensive failure rate. The variance of multiple sub-failure rates can also be used as the comprehensive failure rate, and the variance of the sub-failure rate of each test case can be calculated using the variance calculation formula. Among them, q is the average of multiple sub-failure rates, and k is the number of modified sub-labels; all test cases are sorted according to the variance of the sub-failure rates, and the preset number of associated test cases are selected as target test cases, and the target test cases are used for priority testing. By giving priority to testing the code files to be tested according to the target test cases with high failure rates, the test coverage can be guaranteed with fewer test cases.

[0049] In one embodiment, Figure 3 As shown in the figure, another test case screening method is provided, which is applied to Figure 1 The server 104 in the example is used as an example to illustrate, and the following steps are included:

[0050] Step 302: each time a code file to be tested is detected, version information of the code file to be tested is identified.

[0051] Step 304, searching for the historical code file of the previous version corresponding to the version information.

[0052] Step 306: compare the code file to be tested with the historical code file to obtain differential code segments.

[0053] Step 308: Generate corresponding code modification tags according to the difference code snippets.

[0054] Step 310: Store the code modification tag and version information in a history table accordingly.

[0055] Step 312, obtain multiple test cases, execute the multiple test cases based on each code file to be tested, and obtain test results; the test results include test failures.

[0056] Step 314, associate the test case with a test result of test failure with the corresponding code modification tag, and record the corresponding association relationship in the history table.

[0057] Step 316: Calculate the number of failures of each test case associated with each code modification tag based on the history table.

[0058] Step 318: determine the test cases whose failure times reach a preset value as target test cases corresponding to the corresponding code modification tags.

[0059] Step 320 : Generate a mapping table according to the multiple code modification tags and the screened target test cases corresponding to each code modification tag.

[0060] Step 322: When a newly uploaded code file to be tested is detected again, a tag to be matched of the code file to be tested is identified.

[0061] Step 324: search the mapping table for a code modification tag that matches the tag to be matched.

[0062] Step 326 , performing regression testing on the code file to be tested based on the target test case corresponding to the matched code modification tag.

[0063] In the above test case screening method, when the server detects the code file to be tested each time, the code modification label of the code file to be tested is automatically generated, and the code modification label is stored in the history label. The server can obtain multiple test cases and execute multiple test cases to be screened based on the newly uploaded modified code. The server can associate the test cases that failed the test with the corresponding code modification labels and record them in the history table. After the server detects the code file to be tested enough times, the number of failures of each test case associated with each code modification label can be classified and counted based on the history table, so that the target test case corresponding to each code modification label can be determined according to the number of failures of each code modification label and each associated test case. By quantifying the characteristics of each code modification according to the code modification label, and the test results of different test cases for different code modification characteristics, the target test cases with a higher probability of failure can be accurately screened out, so that when testing the code files to be tested of the business system, the pertinence of the test cases can be improved, and the code files to be tested can be tested accurately and efficiently.

[0064] It should be understood that although Figure 2 and 3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 and 3 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0065] In one embodiment, Figure 4 As shown, a test case screening device 400 is provided, including: an identification module 402, which is used to identify the code modification label of the code file to be tested each time a code file to be tested is detected, and store the code modification label in a history table; an execution module 404, which is used to obtain multiple test cases, execute multiple test cases based on each code file to be tested, and obtain test results; the test results include test failures; an association module 406, which is used to associate the test cases with test results of test failure with the corresponding code modification labels, and record the corresponding association relationship in the history table; a statistical module 408, which is used to calculate the number of failures of each test case associated with each code modification label based on the history table; a screening module 410, which is used to determine the test cases whose failure times reach a preset value as the target test cases corresponding to the corresponding code modification labels.

[0066] In one embodiment, the device also includes a testing module, which is used to generate a mapping table based on multiple code modification tags and the screened target test cases corresponding to each code modification tag; when a newly uploaded code file to be tested is detected again, the tag to be matched of the code file to be tested is identified; the code modification tag matching the tag to be matched is searched in the mapping table; and regression testing is performed on the code file to be tested based on the target test cases corresponding to the matching code modification tags.

[0067] In one embodiment, the code file to be tested carries version information, and the identification module 402 is also used to find the historical code file of the previous version corresponding to the version information; compare the code file to be tested and the historical code file to obtain the difference code fragment; and generate the corresponding code modification tag according to the difference code fragment.

[0068] In one embodiment, the identification module 402 is further used to identify multiple types of modification information of the difference code fragments; create corresponding modification sub-tags according to each type of modification information; and concatenate multiple modification sub-tags to generate a code modification tag.

[0069] In one embodiment, the association module 406 is also used to associate each modification sub-tag with multiple test failure cases corresponding to the corresponding modification sub-tag and record them in the history table; the statistical module 408 is also used to classify and count the number of failures of each test case associated with each modification sub-tag based on the history table.

[0070] In one embodiment, the screening module 410 is also used to calculate the sub-failure rate of each test case corresponding to each modification sub-tag based on the number of failures of each test case associated with each modification sub-tag; calculate the comprehensive failure rate of each test case corresponding to the code modification tag based on the sub-failure rates corresponding to the multiple modification sub-tags corresponding to the code modification tag; and determine the test case whose comprehensive failure rate is greater than a preset threshold as the target test case of the corresponding code modification tag.

[0071] For the specific definition of the test case screening device, please refer to the definition of the test case screening method above, which will not be repeated here. Each module in the above-mentioned test case screening device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0072] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as historical tables. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a test case screening method is implemented.

[0073] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0074] In one embodiment, another computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the test case screening method in each of the above embodiments when executing the computer program.

[0075] In one embodiment, another computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the test case screening method in the above-mentioned various embodiments are implemented.

[0076] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0077] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are 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.

[0078] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A test case screening method, the method comprising: When a code file to be tested is detected each time, a code modification tag of the code file to be tested is identified, and the code modification tag is stored in a history table; The code modification tag is used to identify multiple modification information of different code fragments, and a corresponding modification sub-tag is created according to each modification information, and multiple modification sub-tags are spliced ​​to generate; The difference code fragment is the most recently modified code portion corresponding to the code file to be tested; Acquire multiple test cases, execute the multiple test cases based on each code file to be tested, and obtain test results, wherein the test results include test failures; Associating the test case whose test result is a test failure with the corresponding code modification tag, and recording the corresponding association relationship in the history table; Calculate the number of failures of each test case associated with each code modification tag based on the history table; According to the number of failures of each test case associated with each modification sub-tag, the sub-failure rate of each test case corresponding to each modification sub-tag is calculated; according to the sub-failure rates corresponding to the multiple modification sub-tags corresponding to the code modification tag, the comprehensive failure rate of each test case corresponding to the code modification tag is calculated; Determine the test cases whose comprehensive failure rate is greater than a preset threshold as target test cases of corresponding code modification tags; Generate a mapping table according to multiple code modification tags and the screened target test cases corresponding to each code modification tag; When a newly uploaded code file to be tested is detected again, a tag to be matched of the code file to be tested is identified; Searching the mapping table for a code modification tag that matches the tag to be matched; and performing regression testing on the code file to be tested based on a target test case corresponding to the matched code modification tag.

2. The method according to claim 1, characterized in that The test cases each include a plurality of expected output data; the method further includes: Execute the test case to obtain multiple actual output parameters, and when any actual output parameter is inconsistent with the corresponding expected output parameter, determine that the test case fails; When each actual output parameter is consistent with the corresponding expected output parameter, it is determined that the test case has passed the test.

3. The method according to claim 1, characterized in that The code file to be tested carries version information, and the step of identifying a code modification tag of the code file to be tested includes: Searching for a historical code file of a previous version corresponding to the version information; Comparing the code file to be tested with the historical code file to obtain differential code fragments; Generate corresponding code modification tags according to the difference code snippets.

4. The method according to claim 1, characterized in that: The step of associating the test case with the test result of test failure with the corresponding code modification tag and recording the corresponding association relationship in the history table includes: Associating each modification sub-tag with a plurality of test failure cases corresponding to the corresponding modification sub-tag and recording them in the history table; The calculating, based on the history table, the number of failures of each test case associated with each code modification tag comprises: The number of failures of each test case associated with each modification sub-tag is calculated based on the history table.

5. The method according to claim 1, characterized in that The method further comprises: The code modification label and each associated test case are input into the machine learning model to filter out the target test case corresponding to the code modification label.

6. A test case screening device, characterized in that: The device comprises: An identification module is used to identify the code modification tag of the code file to be tested each time the code file to be tested is detected, and store the code modification tag in a history table; the code modification tag is a plurality of modification information for identifying the difference code fragment, and a corresponding modification sub-tag is created according to each modification information, and a plurality of modification sub-tags are spliced ​​and generated; the difference code fragment is the code part of the most recently modified code file corresponding to the code file to be tested; An execution module, used to obtain multiple test cases, execute the multiple test cases based on each code file to be tested, and obtain test results; the test results include test failures; An association module, used to associate the test case whose test result is a test failure with the corresponding code modification tag, and record the corresponding association relationship in the history table; A statistics module, used for calculating the number of failures of each test case associated with each code modification tag based on the history table; A screening module is used to calculate the sub-failure rate of each test case corresponding to each modification sub-tag according to the number of failures of each test case associated with each modification sub-tag; calculate the comprehensive failure rate of each test case corresponding to the code modification tag according to the sub-failure rates corresponding to the multiple modification sub-tags corresponding to the code modification tag; and determine the test case with the comprehensive failure rate greater than a preset threshold as the target test case of the corresponding code modification tag; The test module is used to generate a mapping table based on multiple code modification tags and the target test cases corresponding to each code modification tag screened out; when a newly uploaded code file to be tested is detected again, the tag to be matched of the code file to be tested is identified; the code modification tag matching the tag to be matched is searched in the mapping table; and the code file to be tested is regression tested based on the target test cases corresponding to the matched code modification tags.

7. The device according to claim 6, characterized in that The code file to be tested carries version information; the identification module is also used to find the historical code file of the previous version corresponding to the version information; Comparing the code file to be tested with the historical code file to obtain differential code fragments; Generate corresponding code modification tags according to the difference code snippets.

8. The device according to claim 6, characterized in that The association module is also used to associate each modification sub-tag with multiple test failure cases corresponding to the corresponding modification sub-tag and record them in the history table; the statistical module is also used to calculate the number of failures of each test case associated with each modification sub-tag based on the history table.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.