A test case generation method, device, computer equipment and storage medium

By obtaining the interface parameter information of the target service, using machine learning to generate test cases, and combining equivalence class division and boundary value method, the existing problems of low efficiency and poor accuracy of automated testing are solved, and test case generation close to actual traffic is achieved. , improving testing efficiency and accuracy.

CN112559364BActive Publication Date: 2024-09-06SHANGHAI PINWEI INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011537948.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-23
Publication Date
2024-09-06
Estimated Expiration
2040-12-23

AI Technical Summary

Technical Problem

Existing automated testing requires a lot of manpower to write use cases, resulting in low generation efficiency and affected accuracy. There is a deviation between manually written data and actual traffic.

Method used

By obtaining the interface parameter information of the target service, machine learning is used to generate test cases, combined with equivalence class division and boundary value method, to generate test cases close to actual traffic, and the code coverage data is obtained through the test case execution engine for screening and classification, improving Test case accuracy and efficiency.

Benefits of technology

It improves the accuracy and generation efficiency of test cases, reduces the workload of testers, and ensures that test cases are closer to the actual traffic in the production environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112559364B
    Figure CN112559364B
Patent Text Reader

Abstract

The present application relates to a test case generation method, device, computer equipment and storage medium, and belongs to the field of software testing technology. The method comprises: obtaining interface parameter information of a target service, the interface parameter information comprising actual parameter values ​​of all interface parameters obtained by parsing actual traffic data of the target service; performing machine learning on all interface parameters according to the actual parameter values ​​of each interface parameter and characteristic information of the target service to obtain parameter value rules of each interface parameter; assigning values ​​to each interface parameter according to the parameter value rules of each interface parameter, and generating multiple test cases for the target service. The present invention can quickly and efficiently generate test cases for the target service, improve the generation efficiency of test cases, and ensure the accuracy of test cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the development of software testing technology, in order to measure a special goal during the testing process, test cases are usually written for the special goal to perform automated testing.

[0003] At present, automated testing requires a large amount of manpower to write the input and output data of use cases, which not only requires testers to have strong coding skills, but also has low efficiency in generating test cases. In addition, since manually written data has a certain deviation from online traffic, it will also affect the accuracy of test cases. Summary of the invention

[0004] In order to solve at least one of the problems mentioned in the above background technology, the present invention provides a test case generation method, apparatus, computer equipment and storage medium.

[0005] In a first aspect, a test case generation method is provided, the method comprising:

[0006] Acquire interface parameter information of a target service, the interface parameter information including actual parameter values ​​of respective multiple interface parameters obtained by parsing actual traffic data of the target service;

[0007] Perform machine learning on all the interface parameters according to the actual values ​​of the parameters of each interface parameter and the characteristic information of the target service to obtain parameter value rules of each interface parameter;

[0008] According to the parameter value rules of each of the interface parameters, each of the interface parameters is assigned a value to generate multiple test cases for the target service.

[0009] Furthermore, before the step of assigning values ​​to the interface parameters according to the parameter value rules of the interface parameters to generate a plurality of test cases for the target service, the method further includes:

[0010] For each of the interface parameters, determine whether the interface parameter has a preset parameter value rule, and if so, push the preset parameter value rule of the interface parameter and the parameter value rule obtained by machine learning to the user end for the user to select;

[0011] The method further comprises receiving selection information of a parameter value rule for the interface parameter from the user terminal, and determining the parameter value rule indicated by the selection information as the parameter value rule for the interface parameter.

[0012] Furthermore, assigning values ​​to the interface parameters according to the parameter value rules of the interface parameters to generate multiple test cases for the target service includes:

[0013] According to the parameter value rules of each of the interface parameters, and in combination with equivalence class division and / or boundary value method, each of the interface parameters is assigned a value to generate multiple test cases for the target service.

[0014] Furthermore, the method further comprises:

[0015] Execute the plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each of the test cases;

[0016] All the test cases are screened according to the code coverage data corresponding to each of the test cases.

[0017] Furthermore, screening all the test cases according to the code coverage data corresponding to each of the test cases includes:

[0018] Obtaining similarities between the code coverage data corresponding to each of the test cases, and classifying each of the test cases according to the similarities to obtain a subset of multiple test cases;

[0019] Each of the test case subsets is screened according to the code coverage data corresponding to the test cases contained in the test case subset.

[0020] Furthermore, the obtaining of the similarity between the code coverage data corresponding to each of the test cases includes:

[0021] Binding each of the test cases to the program code segments covered by each of the test cases according to the code coverage data corresponding to each of the test cases;

[0022] For each target test case among all the test cases, calculate the degree of similarity between the program code segment bound to the target test case and the program code segments bound to other test cases among all the test cases, and obtain the similarity between the code coverage data corresponding to each of the test cases based on the calculation result;

[0023] The test cases are classified according to the similarities to obtain a subset of multiple test cases, including:

[0024] Determining mutually similar code coverage data according to the respective similarities and the preset similarity conditions;

[0025] The test cases corresponding to the mutually similar code coverage data are classified into the same test case set.

[0026] Further, the code coverage data includes code coverage rate, and the screening of each of the test case subsets according to the code coverage data corresponding to the test cases included in each of the test case subsets includes:

[0027] For each of the test case subsets, sort each test case in the test case subset in descending order of code coverage to obtain a sorting result; and

[0028] The test cases ranked in the top N positions in the sorting result are selected as the optimal test cases, where N is greater than or equal to 1.

[0029] In a second aspect, a test case generating device is provided, the device comprising:

[0030] A parameter acquisition module, used to acquire interface parameter information of a target service, wherein the interface parameter information includes actual parameter values ​​of all interface parameters obtained by parsing actual traffic data of the target service;

[0031] A machine learning module, used to perform machine learning on all the interface parameters according to the actual values ​​of the parameters of each of the interface parameters and the characteristic information of the target service, to obtain parameter value rules for each of the interface parameters;

[0032] The use case generation module is used to assign values ​​to each of the interface parameters according to the parameter value rules of each of the interface parameters, and generate multiple test cases for the target service.

[0033] Furthermore, the device further comprises a parameter rule processing module, and the parameter rule processing module is specifically used for:

[0034] For each of the interface parameters, determine whether the interface parameter has a preset parameter value rule, and if so, push the preset parameter value rule of the interface parameter and the parameter value rule obtained by machine learning to the user end for the user to select;

[0035] The method further comprises receiving selection information of a parameter value rule for the interface parameter from the user terminal, and determining the parameter value rule indicated by the selection information as the parameter value rule for the interface parameter.

[0036] Furthermore, the use case generation module is specifically used for:

[0037] According to the parameter value rules of each of the interface parameters, and in combination with equivalence class division and / or boundary value method, each of the interface parameters is assigned a value to generate multiple test cases for the target service.

[0038] Furthermore, the device further comprises a use case screening module, and the use case screening module comprises:

[0039] A test case execution unit, used to execute the plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each of the test cases;

[0040] The test case screening unit is used to screen all the test cases according to the code coverage data corresponding to each of the test cases.

[0041] Furthermore, the use case screening unit includes:

[0042] Obtain subunits to obtain similarities between code coverage data corresponding to each of the test cases;

[0043] A classification subunit, used for classifying each of the test cases according to each of the similarities to obtain a subset of multiple test cases;

[0044] The screening subunit is used to screen each of the test case subsets according to the code coverage data corresponding to the test cases contained in each of the test case subsets.

[0045] Furthermore, the acquisition subunit is specifically used for:

[0046] Binding each of the test cases to the program code segments covered by each of the test cases according to the code coverage data corresponding to each of the test cases;

[0047] For each target test case among all the test cases, calculate the degree of similarity between the program code segment bound to the target test case and the program code segments bound to other test cases among all the test cases, and obtain the similarity between the code coverage data corresponding to each of the test cases based on the calculation result;

[0048] The classification subunit is specifically used for:

[0049] Determining mutually similar code coverage data according to the respective similarities and the preset similarity conditions;

[0050] The test cases corresponding to the mutually similar code coverage data are classified into the same test case set.

[0051] Further, the code coverage data includes code coverage rate, and the screening subunit is specifically used for:

[0052] For each of the test case subsets, sort each test case in the test case subset in descending order of code coverage to obtain a sorting result; and

[0053] The test cases ranked in the top N positions in the sorting result are selected as the optimal test cases, where N is greater than or equal to 1.

[0054] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following operation steps when executing the computer program:

[0055] Acquire interface parameter information of the target service, the interface parameter information including actual parameter values ​​of all interface parameters obtained by parsing actual traffic data of the target service;

[0056] Perform machine learning on all the interface parameters according to the actual values ​​of the parameters of each interface parameter and the characteristic information of the target service to obtain parameter value rules of each interface parameter;

[0057] According to the parameter value rules of each of the interface parameters, each of the interface parameters is assigned a value to generate multiple test cases for the target service.

[0058] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following operation steps are implemented:

[0059] Acquire interface parameter information of the target service, the interface parameter information including actual parameter values ​​of all interface parameters obtained by parsing actual traffic data of the target service;

[0060] Perform machine learning on all the interface parameters according to the actual values ​​of the parameters of each interface parameter and the characteristic information of the target service to obtain parameter value rules of each interface parameter;

[0061] According to the parameter value rules of each of the interface parameters, each of the interface parameters is assigned a value to generate multiple test cases for the target service.

[0062] The test case generation method, device, computer equipment and storage medium provided by the present invention, because the interface parameter information of the target service includes the actual parameter values ​​of multiple interface parameters obtained by parsing the actual traffic data of the target service, all interface parameters are machine-learned according to the actual parameter values ​​of each interface parameter and the characteristic information of the target service, and the parameter value rules of each interface parameter are obtained, and according to the parameter value rules of each interface parameter, each interface parameter is assigned a value, and multiple test cases of the target service are generated, which can make the test case closer to the actual traffic in the production environment, thereby effectively improving the accuracy of the test case. In addition, the method can also quickly and efficiently generate test cases for the target service, improve the generation efficiency of test cases, and thus reduce the workload of testers in writing automated test cases. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Figure 1 A schematic diagram of a flow chart of a test case generation method in an embodiment;

[0064] Figure 2 A schematic diagram of a flow chart of a test case generation method in another embodiment;

[0065] Figure 3 for Figure 2 A schematic flow chart of step 207 in the method shown;

[0066] Figure 4 A structural block diagram of a test case generating device in an embodiment;

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

[0068] 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.

[0069] It should be noted that, unless the context clearly requires otherwise, words such as “include”, “including” and similar words throughout the specification and claims should be interpreted as including rather than exclusive or exhaustive; that is, the meaning is “including but not limited to”.

[0070] In addition, in the description of the present invention, it is to be understood that the terms "first", "second", etc. are used for descriptive purposes only and are not to be understood as indicating or implying relative importance. In addition, in the description of the present invention, unless otherwise specified, "plurality" means two or more.

[0071] As described in the above background technology, current automated testing requires a large amount of manpower to write test case input and output data, which not only requires testers to have strong coding skills, but also has a low test case generation efficiency; in addition, since the manually written data has a certain deviation from the online traffic, it will also affect the accuracy of the test case. To this end, the present application provides a test case generation method, which can quickly and efficiently generate test cases for target services, improve the test case generation efficiency, and ensure the accuracy of the test cases.

[0072] Embodiment 1

[0073] The embodiment of the present invention provides a test case generation method, which can be applied to a computer device. The computer device can be implemented by an independent server or a server cluster composed of multiple servers, such as Figure 1 As shown, the method may include the following steps:

[0074] 101. Obtain interface parameter information of a target service, where the interface parameter information includes actual values ​​of all interface parameters obtained by parsing actual traffic data of the target service.

[0075] The target service may be any type of service. The target service usually has one or more interfaces. The actual traffic data of the target service includes the actual traffic data of each interface of the target service. The actual traffic data includes request messages and response messages.

[0076] Specifically, the actual traffic data of the target service in the production environment can be pre-recorded and stored in the database. When the server receives a test case generation instruction, the selected target service is determined according to the test case generation instruction, and the actual traffic data of the target service is pulled from the database. After desensitizing the actual traffic data, the actual traffic data is parsed according to the interface input and output parameter structure corresponding to each interface of the target service to obtain information such as the interface name, interface parameter field name, and field attributes corresponding to the interface parameters. In addition, other information of the interface parameters can also be parsed, such as the interface uniform resource locator, interface method type, interface input parameter type, and interface output parameter type.

[0077] The field types of the interface parameters include input parameter fields and output parameter fields. Each parameter field has a corresponding parameter field name and field attribute information and field type corresponding to the parameter field name. The server's database pre-stores preset parameter value rules corresponding to each parameter field. The parameter value rules include parameter value ranges and / or regular expressions, parameter value ranges such as safety values, upper boundary values, lower boundary values, null values, parameter values ​​that are not of this field type, etc.

[0078] 102. Perform machine learning on all interface parameters according to the actual values ​​of the parameters of each interface parameter and the characteristic information of the target service to obtain parameter value rules of each interface parameter.

[0079] The characteristic information of the target service includes information such as the service name, domain name, and business function points of the target service.

[0080] Specifically, machine learning is performed on the parameter field names of the interface parameters, the actual values ​​of the parameters corresponding to the parameter field names, the service name and domain name of the target service, and the business function points of the target service to analyze the parameter value rules of each interface parameter, that is, to find out the rules of the parameter value rules.

[0081] Among them, machine learning can use algorithms such as clustering algorithms, neural networks, Bayesian, regression analysis, etc. to analyze parameter value rules for each interface parameter and generate regular results of the parameter value rules (such as clustering or classification results, etc.).

[0082] It should be understood that the embodiments of the present invention do not limit the specific machine learning process.

[0083] 103. Assign values ​​to each interface parameter according to the parameter value selection rules of each interface parameter, and generate multiple test cases for the target service.

[0084] The implementation process of step 103 may include:

[0085] According to the parameter value rules of each interface parameter, and in combination with equivalence class division and / or boundary value method, each interface parameter is assigned a value to generate multiple test cases for the target service.

[0086] Among them, the equivalence class partitioning method divides the test data into valid equivalence class data and invalid equivalence class data. The valid equivalence class data is a reasonable and meaningful data set that conforms to the specified rules, and the invalid equivalence class data is an unreasonable and meaningless data set; the boundary value analysis method tests the boundaries of input or output by selecting the upper point, inner point and outlier point of the specified data domain.

[0087] In addition, other test case design methods may also be considered, such as scenario method, orthogonal table method, etc. This embodiment does not limit the specific test case generation process.

[0088] The test case generation method provided by the present invention, since the interface parameter information of the target service includes the actual parameter values ​​of the respective multiple interface parameters obtained by parsing the actual traffic data of the target service, all the interface parameters are machine-learned according to the actual parameter values ​​of the respective interface parameters and the characteristic information of the target service, and the parameter value rules of the respective interface parameters are obtained, and according to the parameter value rules of the respective interface parameters, each interface parameter is assigned a value, and multiple test cases of the target service are generated, which can make the test cases closer to the actual traffic in the production environment, thereby effectively improving the accuracy of the test cases. In addition, the method can also quickly and efficiently generate test cases for the target service, improve the generation efficiency of the test cases, and thus reduce the workload of the test personnel in writing automated test cases.

[0089] Embodiment 2

[0090] The embodiment of the present invention provides a test case generation method, which can be applied to a server, and the server can be implemented by an independent server or a server cluster, such as Figure 2 As shown, the method may include the following steps:

[0091] 201 , obtaining interface parameter information of a target service, where the interface parameter information includes actual parameter values ​​of a plurality of interface parameters obtained by parsing actual traffic data of the target service.

[0092] Specifically, the implementation process of step 201 may refer to step 101, which will not be described in detail here.

[0093] 202. Perform machine learning on all interface parameters according to the interface parameter information and characteristic information of the target service to obtain parameter value rules of each interface parameter.

[0094] Specifically, the implementation process of step 202 may refer to step 102, which will not be described in detail here.

[0095] 203. For each interface parameter, determine whether the interface parameter has a preset parameter value rule. If yes, push the preset parameter value rule of the interface parameter and the parameter value rule obtained through machine learning to the user end for the user to choose.

[0096] The server database pre-stores preset parameter value rules corresponding to the parameter fields of various interface parameters. A visual configuration interface can be provided to the user end to receive the parameter value rules configured by the user for the interface parameters through the visual configuration interface, and the interface parameter fields and the corresponding configured parameter value rules are stored in the database in the form of key-value pairs.

[0097] Specifically, the preset parameter value rules of the interface parameters and the parameter value rules obtained by machine learning are pushed to the user end for the user to select, which may further include:

[0098] Perform similarity calculation on the preset parameter value rules of the interface parameters and the parameter value rules obtained through machine learning, determine the target interface parameters whose similarity results exceed the preset similarity threshold, and push the preset parameter value rules of the target interface parameters and the parameter value rules obtained through machine learning to the user end.

[0099] The preset similarity threshold can be preset according to actual needs. The similarity calculation method can refer to the existing technology, such as using Euclidean distance, Hamming distance, cosine distance, etc.

[0100] 204 , receiving selection information of the user terminal for the parameter value rule of the interface parameter, and determining the parameter value rule indicated by the selection information as the parameter value rule of the interface parameter.

[0101] Among them, step 203 to step 204 are optional steps.

[0102] In this embodiment, the parameter value rules preset for the target interface parameters whose similarity results exceed the preset similarity threshold and the parameter value rules obtained through machine learning are pushed to the user end, and the parameter value rules indicated by the received selection information are determined as the parameter value rules for the interface parameters. This can reduce the workload of the user in selecting the parameter value rules and further improve the efficiency of generating subsequent test cases.

[0103] In this embodiment, by pushing the preset parameter value rules of the interface parameters and the parameter value rules obtained through machine learning to the user end for user selection, and receiving the user end's selection information for the parameter value rules of the interface parameters, and determining the parameter value rules indicated by the selection information as the parameter value rules of the interface parameters, the parameter value rules of the interface parameters can be made more accurate, thereby improving the accuracy of subsequent test case generation.

[0104] 205 , assign values ​​to the various interface parameters according to the parameter value selection rules of the various interface parameters, and generate multiple test cases for the target service.

[0105] Specifically, the implementation process of step 205 may refer to step 103, which will not be described in detail here.

[0106] 206. Execute multiple test cases through a test case execution engine to obtain code coverage data corresponding to each test case.

[0107] The service program code corresponding to the target service is stored in a preset service code. The service program code includes a plurality of program code segments, and different program code segments have different program functions.

[0108] Specifically, multiple test cases are executed in the test environment through the test case execution engine to obtain the coverage report of the service code of the target service, and the code coverage data is extracted from the coverage report. The code coverage data includes: information about the code covered by the test, information about the code not covered by the test, and code coverage. The code information can be code features, including but not limited to: business line, service name, class name, method name, and code line number, etc. The code coverage is calculated based on the information about the code covered by the test and the information about the code not covered by the test. Here, the test environment refers to an environment simulated to be close to the real production environment, for example, it can be a staging test environment.

[0109] 207, all test cases are screened according to the code coverage data corresponding to each test case.

[0110] Specifically, according to the code coverage data corresponding to each test case, the code coverage rate corresponding to each test case is determined, and the test cases whose code coverage rate exceeds a preset threshold are screened out.

[0111] In the embodiment of the present invention, all test cases can be screened according to the code coverage data corresponding to each test case, which can reduce the number of test cases for the software and effectively avoid the problems of duplication and redundancy of test work, thereby improving test efficiency.

[0112] In a preferred embodiment, Figure 3 As shown, in the above step 207, all test cases are screened according to the code coverage data corresponding to each test case. The implementation process includes:

[0113] 2071, obtaining the similarity between the code coverage data corresponding to each test case, and classifying each test case according to each similarity to obtain multiple test case subsets.

[0114] Specifically, in step 2071, the similarity between the code coverage data corresponding to each test case is obtained. The process may include steps a to b, wherein:

[0115] Step a: Bind each test case with the program code segment covered by each test case according to the code coverage data corresponding to each test case.

[0116] Among them, the program code segments covered by each test case can be determined based on the test coverage code information in the code coverage data corresponding to each test case, and a binding relationship between each test case and the program code segment covered by each test case can be established. In establishing a "test case-code segment" binding relationship, it is used to indicate which code lines are covered by each test case, that is, each test case is bound to the code segment it covers.

[0117] It is understandable that a test case can be bound to one or more program code segments. A program code segment contains at least one code line.

[0118] Step b, for each target test case in all test cases, calculate the degree of similarity between the program code segment bound to the target test case and the program code segments bound to other test cases in all test cases, and based on the calculation results, obtain the similarity between the code coverage data corresponding to each test case.

[0119] It can be understood that the target test case may be a test case randomly selected from all test cases, and the other test cases are test cases other than the target test case among all test cases.

[0120] This embodiment does not limit the specific similarity acquisition process.

[0121] It is understandable that when the similarity between the program code segments bound to the two test cases is higher, the code coverage data corresponding to the two test cases are more similar. The number of program code segments bound to the two test cases can be one or more.

[0122] In step 2071, each test case is classified according to each similarity to obtain a subset of multiple test cases. This process may include:

[0123] According to each similarity and preset similarity conditions, mutually similar code coverage data are determined, and the test cases corresponding to the mutually similar code coverage data are classified into the same test case set.

[0124] Specifically, it is determined whether the similarity between the code coverage data satisfies a preset similarity condition. If so, it is determined that the code coverage data are similar to each other.

[0125] Among them, the preset similarity condition can be set as: when the similarity between any two code coverage data exceeds a preset threshold, the two code coverage data are similar code coverage data. It can be understood that the preset threshold can be set according to actual conditions, for example, set to 80%.

[0126] 2072, each test case subset is screened according to the code coverage data corresponding to the test cases contained in each test case subset.

[0127] The code coverage data includes code coverage rate.

[0128] Specifically, for each test case subset, each test case in the test case subset is sorted in descending order according to the code coverage to obtain a sorting result; and

[0129] Filter out the top N test cases in the sorting results as the optimal test cases, where N is greater than or equal to 1.

[0130] In this embodiment, the similarities between the code coverage data corresponding to each test case are calculated, and each test case is classified according to each similarity to obtain multiple test case subsets, and each test case subset is screened according to the code coverage data corresponding to the test cases contained in each test case subset. Not only are the screened test cases highly targeted and can effectively reduce the number of test cases for the software and avoid the execution of a large number of redundant test cases, but the screened test cases are also more comprehensive, so that even program code segments covered by fewer test cases can also be tested, thereby improving the effectiveness and comprehensiveness of the test.

[0131] Embodiment 3

[0132] The embodiment of the present invention provides a test case generation device, such as Figure 4 As shown, the device may include:

[0133] The parameter acquisition module 42 is used to acquire the interface parameter information of the target service, where the interface parameter information includes the actual parameter values ​​of all interface parameters obtained by parsing the actual traffic data of the target service;

[0134] The machine learning module 44 is used to perform machine learning on all interface parameters according to the actual values ​​of the parameters of each interface parameter and the characteristic information of the target service to obtain the parameter value rules of each interface parameter;

[0135] The use case generation module 46 is used to assign values ​​to various interface parameters according to the parameter value rules of various interface parameters, and generate multiple test cases for the target service.

[0136] In a preferred embodiment, the device further comprises a parameter rule processing module, and the parameter rule processing module is specifically used for:

[0137] For each interface parameter, determine whether the interface parameter has a preset parameter value rule. If yes, push the preset parameter value rule of the interface parameter and the parameter value rule obtained by machine learning to the user end for the user to choose;

[0138] The user terminal receives selection information of the parameter value rule for the interface parameter, and determines the parameter value rule indicated by the selection information as the parameter value rule for the interface parameter.

[0139] In a preferred embodiment, the use case generation module 46 is specifically used to:

[0140] According to the parameter value rules of each interface parameter, and in combination with equivalence class division and / or boundary value method, each interface parameter is assigned a value to generate multiple test cases for the target service.

[0141] In a preferred embodiment, the device further comprises a use case screening module 48, and the use case screening module 48 comprises:

[0142] A test case execution unit is used to execute multiple test cases through a test case execution engine to obtain code coverage data corresponding to each test case;

[0143] The use case screening unit is used to screen all test cases according to the code coverage data corresponding to each test case.

[0144] In a preferred embodiment, the use case screening unit includes:

[0145] Get the sub-units and obtain the similarity between the code coverage data corresponding to each test case;

[0146] The classification subunit is used to classify each test case according to each similarity to obtain a subset of multiple test cases;

[0147] The screening subunit is used to screen each test case subset according to the code coverage data corresponding to the test cases contained in each test case subset.

[0148] In a preferred embodiment, the acquisition subunit is specifically used for:

[0149] According to the code coverage data corresponding to each test case, each test case is bound to the program code segment covered by each test case;

[0150] For each target test case among all test cases, calculate the degree of similarity between the program code segment bound to the target test case and the program code segments bound to other test cases among all test cases, and obtain the similarity between the code coverage data corresponding to each test case based on the calculation result;

[0151] The classification subunits are specifically used for:

[0152] Determine code coverage data that are similar to each other according to the respective similarities and the preset similarity conditions;

[0153] The test cases corresponding to the code coverage data that are similar to each other are classified into the same test case set.

[0154] In a preferred embodiment, the code coverage data includes code coverage rate, and the screening subunit is specifically used for:

[0155] For each test case subset, sort each test case in the test case subset in descending order of code coverage to obtain a sorting result; and

[0156] Filter out the top N test cases in the sorting results as the optimal test cases, where N is greater than or equal to 1.

[0157] For the specific definition of the test case generation device, please refer to the definition of the test case generation method above, which will not be repeated here. Each module in the above-mentioned test case generation 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 in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0158] 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 5 As shown. The server includes a processor, a memory, and a network interface 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 and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with other devices through a network connection. When the computer program is executed by the processor, a test case generation method is implemented.

[0159] 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.

[0160] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0161] Obtaining interface parameter information of the target service, the interface parameter information including actual parameter values ​​of all interface parameters obtained by parsing actual traffic data of the target service;

[0162] Perform machine learning on all interface parameters based on the actual values ​​of the parameters and the characteristic information of the target service to obtain the parameter value rules of each interface parameter;

[0163] According to the parameter value rules of each interface parameter, each interface parameter is assigned a value to generate multiple test cases for the target service.

[0164] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0165] Obtaining interface parameter information of the target service, the interface parameter information including actual parameter values ​​of all interface parameters obtained by parsing actual traffic data of the target service;

[0166] Perform machine learning on all interface parameters based on the actual values ​​of the parameters and the characteristic information of the target service to obtain the parameter value rules of each interface parameter;

[0167] According to the parameter value rules of each interface parameter, each interface parameter is assigned a value to generate multiple test cases for the target service.

[0168] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments 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 the present 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).

[0169] 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.

[0170] 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 generation method, characterized in that: The method comprises: Acquire interface parameter information of the target service, the interface parameter information including actual parameter values ​​of all interface parameters obtained by parsing actual traffic data of the target service; Perform machine learning on all the interface parameters according to the actual values ​​of the parameters of each interface parameter and the characteristic information of the target service to obtain parameter value rules of each interface parameter; Assigning values ​​to each of the interface parameters according to the parameter value rules of each of the interface parameters to generate multiple test cases for the target service; Execute the plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each of the test cases; All the test cases are screened according to the code coverage data corresponding to each of the test cases, including: Obtaining similarities between the code coverage data corresponding to each of the test cases, and classifying each of the test cases according to the similarities to obtain a subset of multiple test cases; Screening each of the test case subsets according to code coverage data corresponding to the test cases contained in the test case subset; Wherein, obtaining the similarity between the code coverage data corresponding to each of the test cases includes: Binding each of the test cases to the program code segments covered by each of the test cases according to the code coverage data corresponding to each of the test cases; For each target test case among all the test cases, calculate the degree of similarity between the program code segment bound to the target test case and the program code segments bound to other test cases among all the test cases, and obtain the similarity between the code coverage data corresponding to each of the test cases based on the calculation result; The test cases are classified according to the similarities to obtain a subset of multiple test cases, including: Determining mutually similar code coverage data according to the respective similarities and the preset similarity conditions; The test cases corresponding to the mutually similar code coverage data are classified into the same test case set.

2. The method according to claim 1, characterized in that: Before the step of assigning values ​​to the interface parameters according to the parameter value rules of the interface parameters to generate multiple test cases for the target service, the method further includes: For each of the interface parameters, determine whether the interface parameter has a preset parameter value rule, and if so, push the preset parameter value rule of the interface parameter and the parameter value rule obtained by machine learning to the user end for the user to select; The method further comprises receiving selection information of a parameter value rule for the interface parameter from the user terminal, and determining the parameter value rule indicated by the selection information as the parameter value rule for the interface parameter.

3. The method according to claim 1, characterized in that The step of assigning values ​​to the interface parameters according to the parameter value rules of the interface parameters to generate multiple test cases for the target service includes: According to the parameter value rules of each of the interface parameters, and in combination with equivalence class division and / or boundary value method, each of the interface parameters is assigned a value to generate multiple test cases for the target service.

4. The method according to claim 1, characterized in that: The code coverage data includes code coverage rate, and the screening of each of the test case subsets according to the code coverage data corresponding to the test cases included in each of the test case subsets includes: For each of the test case subsets, sort each test case in the test case subset in descending order of code coverage to obtain a sorting result; and The test cases ranked in the top N positions in the sorting result are selected as the optimal test cases, where N is greater than or equal to 1.

5. A device for implementing the test case generation method according to claim 1, characterized in that: The device comprises: A parameter acquisition module, used to acquire interface parameter information of a target service, wherein the interface parameter information includes actual parameter values ​​of all interface parameters obtained by parsing actual traffic data of the target service; A machine learning module, used to perform machine learning on all the interface parameters according to the actual values ​​of the parameters of each of the interface parameters and the characteristic information of the target service, to obtain parameter value rules for each of the interface parameters; The use case generation module is used to assign values ​​to each of the interface parameters according to the parameter value rules of each of the interface parameters, and generate multiple test cases for the target service.

6. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.

7. 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 4 are implemented.