Test case generation method, electronic equipment, readable storage medium and program product

By deduplication and optimization of pre-recorded target traffic, test cases are generated, and the problems of low efficiency and high cost of manual writing test cases are solved, and efficient and accurate test cases are automatically generated.

CN120179558APending Publication Date: 2025-06-20KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510358764.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

During software testing, manual writing of test cases is inefficient and costly, especially when the software functions are complex or version iterations are fast.

Method used

By obtaining the call data in the pre-recorded multiple target traffic and response information, deduplication processing is performed, the target traffic after deduplication is generated as a test case, and the test case is optimized through steps such as boundary value analysis and traffic playback.

Benefits of technology

It realizes automated generation of test cases, reduces the need for manual intervention, saves costs, and improves the generation efficiency and accuracy of test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179558A_ABST
    Figure CN120179558A_ABST
Patent Text Reader

Abstract

The invention provides a test case generation method, electronic equipment, a readable storage medium and a program product. The test case generation method comprises the steps that multiple target flows and calling data of response information in the multiple target flows in the generation process are obtained, and the multiple target flows are flows recorded in advance for the same interface of the same software; the traffic is request information transmitted by the software through the interface in the running process and response information corresponding to the request information; performing duplicate removal on the target traffic with the same calling data in the multiple pieces of target traffic to obtain the target traffic after duplicate removal; and taking the deduplicated target traffic as a test case.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical fields of computers and the like, and particularly relates to a test case generation method, an electronic device, a readable storage medium, and a program product. Background Art

[0002] With the continuous development of computer technology, the types and versions of software are increasing. Software testing is crucial in the field of computer technology. Different types and versions of software need to be extensively tested before and after going online, and test cases are indispensable data in the software testing process.

[0003] In the related art, test cases are manually written for the software to be tested, and then the software to be tested is tested using the manually written test cases. In the case where the software functions are complex or the software version iterates rapidly, a large number of test cases need to be written frequently, resulting in high labor costs and low test case generation efficiency. Summary of the Invention

[0004] The present disclosure provides a test case generation method, an electronic device, a readable storage medium, and a program product.

[0005] According to one aspect of the present disclosure, there is provided a test case generation method, including: Obtaining a plurality of target traffic flows and call data during the generation of response information in the plurality of target traffic flows, where the plurality of target traffic flows are traffic flows pre-recorded for the same interface of the same software, and the traffic flow is request information transmitted through the interface during the operation of the software and response information corresponding to the request information; Removing duplicates from the target traffic flows with the same call data among the plurality of target traffic flows to obtain deduplicated target traffic flows; and Using the deduplicated target traffic flows as test cases.

[0006] According to the test case generation method of at least one embodiment of the present disclosure, the call data includes the number of external dependency calls and / or the types of internal method calls; Removing duplicates from the target traffic flows with the same call data among the plurality of target traffic flows to obtain deduplicated target traffic flows, including: Determining at least one set of first target traffic flows and second target traffic flows among the plurality of target traffic flows, where each set of the first target traffic flows includes a plurality of target traffic flows with the same number of external dependency calls and / or the same types of internal method calls, and the second target traffic flows are the target traffic flows other than the at least one set of first target traffic flows among the plurality of target traffic flows; and Use one target traffic in each group of the at least one group of first target traffic and the second target traffic as the deduplicated target traffic.

[0007] According to the test case generation method of at least one embodiment of the present disclosure, after using the deduplicated target traffic as a test case, it further includes: Perform boundary value analysis on the request parameters of the request information in the test case to obtain the boundary values of the request parameters; Generate target request information according to the request information in the test case and the parameter values of the request parameters; Record the traffic corresponding to the target request information; and Use the traffic corresponding to the target request information as a new test case.

[0008] According to the test case generation method of at least one embodiment of the present disclosure, performing boundary value analysis on the request parameters of the request information in the test case to obtain the boundary values of the request parameters includes: Input the request information in the test case into a trained boundary value analysis model, and perform boundary value analysis on the request parameters of the request information in the test case through the boundary value analysis model to obtain the boundary values of the request parameters.

[0009] According to the test case generation method of at least one embodiment of the present disclosure, after using the traffic corresponding to the target request information as a new test case, it further includes: Determine a first code coverage rate and a second code coverage rate, where the first code coverage rate is the proportion of the software source code that is tested during the testing of the software based on the test case, and the second code coverage rate is the proportion of the software source code that is tested during the testing of the software based on the test case and the new test case; and Delete the new test case if the second code coverage rate is less than or equal to the first code coverage rate.

[0010] According to the test case generation method of at least one embodiment of the present disclosure, after using the deduplicated target traffic as a test case, it further includes: In response to the online deployment of new code of the software, perform traffic playback based on the request information in the test case in the running environment of the new code; Determine whether the test case is noise if the traffic playback result is inconsistent with the response information in the test case; and Mark the status of the test case as an invalid status or delete the test case if the test case is not noise.

[0011] A test case generation method according to at least one embodiment of the present disclosure for determining whether the test case is noise includes: In the operating environment of the new code, performing multiple traffic replays based on the request information in the test case to obtain multiple traffic replay results; and Determining that the test case is noise when the multiple traffic replay results are different from each other.

[0012] According to another aspect of the present disclosure, there is provided an electronic device, including: a memory storing execution instructions; and a processor that executes the execution instructions stored in the memory, such that the processor executes the test case generation method of any one of the embodiments of the present disclosure.

[0013] According to still another aspect of the present disclosure, there is provided a readable storage medium storing execution instructions, and when the execution instructions are executed by a processor, they are used to implement the test case generation method of any one of the embodiments of the present disclosure.

[0014] According to yet another aspect of the present disclosure, there is provided a computer program product including a computer program, and when the computer program is executed by a processor, it implements the test case generation method of any one of the embodiments of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The drawings illustrate exemplary embodiments of the present disclosure and, together with the description thereof, are used to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are included in this specification and form a part of this specification.

[0016] Figure 1 is a flowchart of a test case generation method according to an embodiment of the present disclosure.

[0017] Figure 2 is a schematic diagram of the process of deduplication according to an embodiment of the present disclosure.

[0018] Figure 3 is a schematic diagram of the process of adding new test cases according to an embodiment of the present disclosure.

[0019] Figure 4 is a schematic diagram of the process of maintaining newly added test cases according to an embodiment of the present disclosure.

[0020] Figure 5 is a schematic diagram of the process of maintaining test cases according to an embodiment of the present disclosure.

[0021] Figure 6 is a schematic diagram of the process of determining noise according to an embodiment of the present disclosure.

[0022] Figure 7 It is a schematic flowchart of the test case full - life - cycle management of an embodiment of the present disclosure.

[0023] Figure 8 It is a schematic block diagram of the structure of a test case generation device of an embodiment of the present disclosure.

[0024] Figure 9 It is a schematic block diagram of the structure of an electronic device of an embodiment of the present disclosure. Detailed implementation manners

[0025] The present disclosure will be further described in detail below with reference to the accompanying drawings and examples. It can be understood that the specific examples described herein are only used to explain the relevant content and do not limit the present disclosure. Additionally, it should be noted that for the sake of description, only the parts related to the present disclosure are shown in the drawings.

[0026] It should be noted that, without conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The technical solutions of the present disclosure will be described in detail below with reference to the drawings and embodiments.

[0027] The functions integrated in the software are diverse. For example, security authentication functions, data transmission functions, payment collection functions, payment functions, query functions, brief information display functions, detailed information display functions, and so on. In order to comprehensively ensure the accurate operation of various functions of the software, a large number of tests on various functions of the software are usually required before and after the software is launched. If testers manually write test cases for the software to be tested and then use the test cases written by the testers to test the software to be tested, then testers need to write a large number of test cases, that is, write a large number of requests, request parameters, and expected return values, etc. This will result in a high investment in labor costs and a low generation efficiency of test cases.

[0028] Therefore, the present disclosure proposes a test case generation method.

[0029] The test case generation method of the present disclosure can be used for an electronic device to automatically de - duplicate a plurality of pre - recorded target traffic and automatically generate test cases based on the de - duplicated target traffic. In the present disclosure, the electronic device includes but is not limited to servers, mobile phones, tablet computers, laptop computers, personal computers, wearable devices, teller machines, etc.

[0030] For the sake of description and to make the technical solutions of the detailed implementation manners of the present disclosure easier to understand, before describing the test case generation method implemented by the present disclosure, the technical terms involved in the detailed implementation manners of the present disclosure are explained as follows: Traffic refers to the set of requests and their associated data sent from a client (such as a browser, mobile application, or other system) to a server during a specific time period. The traffic includes, but is not limited to, request information and response information for that request information.

[0031] Boundary value analysis is a black-box testing method that tests the boundary values of inputs or outputs.

[0032] Code coverage is a metric in software testing that describes the proportion and extent to which the source code in a software is tested. The resulting proportion is called the code coverage rate.

[0033] Figure 1 The overall flowchart of the test case generation method M100 according to an embodiment of the present disclosure is shown. As Figure 1 shown, the method includes steps S110 to S130. Among them, the method can be executed by an electronic device such as a server, a mobile phone, or a computer.

[0034] Specifically, Figure 1 the method shown includes: S110. Obtain a plurality of target traffic and the call data of the response information in the generation process among the plurality of target traffic. Among them, the plurality of target traffic is the traffic pre-recorded for the same interface of the same software, and the traffic can be the request information transmitted through the interface during the operation of the software and the response information corresponding to the request information; During the online operation of the software, the traffic transmitted by each interface of the software can be recorded to obtain the traffic of each interface of the software. Then, during the process of automatically generating test cases, the recorded traffic corresponding to each interface of the software can be de-duplicated one by one in units of the interfaces of the software, so as to obtain the test cases for each interface.

[0035] Each target traffic may include request information and the response information for that request information. In the process of processing the request information to generate the response information, external dependency calls and internal method calls may be involved. The call data of the response information in the generation process can be automatically obtained through a log parsing tool or an application performance monitoring tool. That is, the call data can be all external dependency calls (such as API requests, database queries, etc.) and internal method calls (such as function calls within the same process) initiated in the process of processing the request information to generate the response information, as well as the input data, output data, and their metadata (such as call time, duration, status code, etc.).

[0036] It can be understood that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, usage scopes, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to users and the authorization of the users should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0037] For example, when responding to an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested by the user will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application program, server, or storage medium that performs the operations of the present disclosure's technical solution based on the prompt message.

[0038] As an optional but non-limiting implementation manner, the manner of sending a prompt message to the user in response to receiving an active request from the user may, for example, be in the form of a pop-up window, and the prompt message may be presented in text in the pop-up window. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0039] It can be understood that the above notification and user authorization process is only illustrative and does not constitute a limitation on the implementation manner of the present disclosure. Other manners that comply with relevant laws and regulations can also be applied to the implementation manner of the present disclosure.

[0040] At the same time, it can be understood that the data involved in the technical solution of the present disclosure (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of corresponding laws, regulations, and related regulations.

[0041] S120. Deduplicate the target traffic with the same called data among multiple target traffic to obtain the deduplicated target traffic; Software usually has characteristics such as a large number of users and high concurrency. There may be a large amount of traffic with duplicate functions for the same interface of the software. These traffic may correspond to the same business logic, with the difference being the specific parameters. Considering that in different business logics, the external dependencies (such as databases, caches, third-party services, etc.) and / or internal methods that need to be called in the process of generating the response information corresponding to the request information are different, therefore, deduplicating the target traffic with the same called data among multiple target traffic can effectively remove the traffic with duplicate functions, ensuring that the deduplicated target traffic has a smaller data volume on the basis of covering more business logics, which is beneficial to improving the efficiency of software testing based on the deduplicated target traffic.

[0042] S130. Use the deduplicated target traffic as a test case.

[0043] Since the target traffic before and after deduplication includes both the request information and the response information corresponding to the request information, the deduplicated target traffic can be directly used as a test case.

[0044] The number of the target traffic after deduplication can be one, and then this one target traffic after deduplication can be used as a test case to obtain one test case; the target traffic after deduplication can also be multiple, and then multiple target traffic after deduplication can be used as test cases respectively to obtain multiple test cases.

[0045] Exemplarily, after using the target traffic after deduplication as a test case, it may further include: determining the parameter value of the target parameter in the target traffic after deduplication; using the target parameter as the retrieval field of the test case, and using the parameter value of the target parameter as the value of the retrieval field of the test case; and storing the retrieval field and the value of the retrieval field of the test case. In this way, it is convenient to quickly query and call the test case later. The types of target parameters can be preset by relevant personnel.

[0046] The test case generation method according to the embodiments of the present disclosure deduplicates multiple target traffic based on the call data of the response information in the target traffic during the generation process, and then uses the target traffic after deduplication as a test case, realizing the automatic generation of test cases, reducing the need for manual intervention, saving labor costs, and improving the generation efficiency of test cases. At the same time, since the test cases are obtained from pre-recorded traffic, the parameter values in the test cases are all values in the real production environment, rather than virtual values written manually. Therefore, when using the test cases of the present disclosure for software testing, the test results are more accurate and reliable. In addition, the number of test cases with duplicate functions is reduced through deduplication. Therefore, when using the test cases of the present disclosure for software testing, the test efficiency is higher.

[0047] Regarding step S120, in some embodiments of the present disclosure, the call data includes the number of external dependency calls and / or the types of internal method calls; correspondingly, step S120 may include steps S121 and S122 as Figure 2 shown.

[0048] S121. Determine at least one group of first target traffic and second target traffic among the multiple target traffic, where each group of first target traffic includes multiple target traffic with the same number of external dependency calls and / or the same types of internal method calls, and the second target traffic is the target traffic other than at least one group of first target traffic among the multiple target traffic.

[0049] The number of external dependency calls represents how many external dependencies are called by the response information in a traffic during the generation process. The types of internal method calls represent which types of internal methods are called by the response information in a traffic during the generation process.

[0050] As a possible implementation, each group of first target traffic includes multiple target traffic with the same number of external dependency calls, and the number of external dependency calls of different groups of first target traffic is different. For example, the number of external dependency calls of target traffic A is 2, the number of external dependency calls of target traffic B is 2, the number of external dependency calls of target traffic C is 1, the number of external dependency calls of target traffic D is 3, the number of external dependency calls of target traffic E is 3, and the number of external dependency calls of target traffic F is 4. Then target traffic A and target traffic B are a group of first target traffic, target traffic D and target traffic E are another group of first target traffic, and target traffic C and target traffic F are second target traffic. In this way, by grouping and deduplicating the target traffic based on the number of external dependency calls, the traffic with similar external dependency characteristics can be identified more accurately. This deduplication method can be used for interfaces that interact frequently with external systems to ensure that the generated test cases cover different external dependency call scenarios.

[0051] As another possible implementation, each group of first target traffic includes multiple target traffic with the same type of internal method calls, and the types of internal method calls of different groups of first target traffic are different. For example, the types of internal method calls of target traffic A are method 1 and method 2, the types of internal method calls of target traffic B are method 1 and method 3, the types of internal method calls of target traffic C are method 1 and method 3, the types of internal method calls of target traffic D are method 1, method 2 and method 4, the types of internal method calls of target traffic E are method 1, method 2 and method 4, and the type of internal method calls of target traffic F is method 5. Then target traffic B and target traffic C are a group of first target traffic, target traffic D and target traffic E are another group of first target traffic, and target traffic A and target traffic F are second target traffic. In this way, by grouping and deduplicating the target traffic based on the type of internal method calls, the traffic with similar internal logical paths can be identified more accurately. This deduplication method can be used for interfaces with complex business logics to ensure that the generated test cases cover different internal method call scenarios.

[0052] As another possible implementation, each group of first target traffic includes multiple target traffic with the same number of external dependency calls and the same types of internal method calls. The number of external dependency calls or the types of internal method calls of different groups of first target traffic are different. For example, in one group of first target traffic, the number of external dependency calls of multiple target traffic is 2 and the types of internal method calls are method 6 and method 7; in another group of first target traffic, the number of external dependency calls of multiple target traffic is 2 and the types of internal method calls are method 7 and method 8; in yet another group of first target traffic, the number of external dependency calls of multiple target traffic is 3 and the types of internal method calls are method 6 and method 7. In this way, both the number of external dependency calls and the types of internal method calls are included as the basis for deduplication, achieving multi-dimensional analysis of the target traffic. This deduplication method can more comprehensively reflect the actual operation of the interface, ensuring that the generated test cases cover both external dependency scenarios and internal logic paths.

[0053] It should be noted that the specific values mentioned above are only for detailed illustration of the implementation of the present disclosure as examples and should not be construed as a limitation of the present disclosure. In other examples, embodiments or implementations, other values can be selected according to the present disclosure, and no specific limitation is made here.

[0054] S122. Use one target traffic from each group of first target traffic in at least one group of first target traffic and the second target traffic as the deduplicated target traffic.

[0055] Although each group of first target traffic includes multiple target traffic, only one target traffic from each group of first target traffic will be retained. Therefore, it can effectively deduplicate the first target traffic and reduce the number of the obtained deduplicated target traffic.

[0056] Exemplarily, one random target traffic from each group of first target traffic in at least one group of first target traffic and the second target traffic can be used as the deduplicated target traffic, or one most recently recorded target traffic from each group of first target traffic in at least one group of first target traffic and the second target traffic can be used as the deduplicated target traffic, or one target traffic with the most occurrences from each group of first target traffic in at least one group of first target traffic and the second target traffic can be used as the deduplicated target traffic. No limitation is made here.

[0057] It can be understood that if there is no second target traffic, one target traffic from each group of first target traffic in at least one group of first target traffic is used as the deduplicated target traffic.

[0058] The test case generation method of the above embodiments determines at least one set of first target traffic and second target traffic among multiple target traffic, and uses one target traffic in each set of the first target traffic in at least one set of the first target traffic and the second target traffic as the deduplicated target traffic. In this way, by partitioning the multiple target traffic based on the number of external dependency calls and / or the types of internal method calls, more refined grouping management is achieved, which is beneficial for more accurate deduplication. Only one target traffic is retained from multiple target traffic of the same type as the deduplicated target traffic, ensuring the representativeness of the test cases and avoiding repeated testing.

[0059] In some embodiments of the present disclosure, after step S130, it may further include steps S140 to S170 as Figure 3 shown.

[0060] S140. Perform boundary value analysis on the request parameters of the request information in the test case to obtain the boundary values of the request parameters.

[0061] Considering that errors that occur during the operation of the software often occur at the boundaries of the input or output range, rather than inside the input or output range, therefore, determining the boundary values of the request parameters and designing test cases based on the boundary values of the request parameters is beneficial for detecting more potential risks during the software testing process and improving the accuracy of the software test results.

[0062] Exemplarily, the boundary values of numerical request parameters may include one or more of the maximum value, the minimum value, and special values (such as NaN, Null, or Infinity); the boundary values of character request parameters may include the minimum value of the string length (such as 0, representing an empty string) and / or the maximum value of the string length (such as 255, representing a maximum of 255 characters).

[0063] S150. Generate target request information according to the request information and the parameter values of the request parameters in the test case.

[0064] Exemplarily, after copying the request information in the test case, replace the parameter values of the request parameters in the copied request information with the boundary values to obtain the target request information, that is, generating the target request information does not affect the existence of the original request information.

[0065] In the case where multiple request parameters are included in the request information, in step S140, the boundary values of each request parameter among the multiple request parameters can be obtained. Furthermore, the parameter values of the request parameters in the request information can be replaced respectively in the manner of different combinations of boundary values of different types to obtain multiple target request information. For example, if the request information includes an age parameter and a region parameter, the boundary value corresponding to the age parameter is 0, and the boundary value corresponding to the region parameter is Null, then the parameter value of the age parameter in the request information can be replaced with 0 to obtain a target request information, and the parameter value of the region parameter in the request information can be replaced with Null to obtain another target request information, and the parameter value of the age parameter in the request information can be replaced with 0 and the parameter value of the region parameter can be replaced with Null to obtain yet another target request information.

[0066] In some embodiments, steps S140 and S150 can be implemented by a large language model. For example, the request information is concatenated into a preset template to obtain input data. Furthermore, the input data is input into the trained large language model, and the target request information output by the large language model is received. The preset template may include information such as descriptive text for the generation requirements of the target request information.

[0067] S160. Record the traffic corresponding to the target request information.

[0068] Exemplarily, the target request information is sent to the interface corresponding to the test case, and the response information for the target request information is received through the interface. Furthermore, the target request information and the response information corresponding to the target request information are stored as a piece of traffic.

[0069] S170. Use the traffic corresponding to the target request information as a new test case.

[0070] That is, without changing the original test case, the traffic corresponding to the target request information is also determined as a test case.

[0071] The test case generation method of the above embodiments performs boundary value analysis on the request parameters of the request information in the test case to obtain the boundary values of the request parameters; generates target request information according to the request information and the parameter values of the request parameters in the test case; records the traffic corresponding to the target request information; and uses the traffic corresponding to the target request information as a new test case. In this way, test cases for boundary values are added on the basis of the original test case, realizing automatic expansion of the test scope, avoiding manual writing of test cases, enhancing the coverage ability of test cases for extreme cases and boundary conditions, facilitating the detection of more potential risks in the software testing process, and improving the accuracy of software test results.

[0072] Regarding step S140, in some embodiments of the present disclosure, specifically, it may be: input the request information in the test case into the trained boundary value analysis model, and perform boundary value analysis on the request parameters in the request information of the test case through the boundary value analysis model to obtain the boundary values of the request parameters.

[0073] The input data of the boundary value analysis model is the request information, and the output data of the boundary value analysis model is the boundary values of the request parameters in the request information.

[0074] Exemplarily, the boundary value analysis model can be obtained based on one or more of a multi-layer perceptron (MLP), an autoencoder, a convolutional neural network (CNN), a recurrent neural network (RNN) and its variants (LSTM, GRU), a generative adversarial network (GAN), a graph neural network (GNN), and an attention mechanism model (such as Transformer).

[0075] The test case generation method in the above embodiments uses the trained boundary value analysis model to analyze the request parameters in the test case, which can automatically identify the boundary values of the request parameters, improving the accuracy and efficiency of the analysis. The boundary value analysis model can generate corresponding boundary values according to different types of request parameters, with a wider scope of application. By using the boundary value analysis model to replace manual boundary value analysis, the risk of errors caused by human judgment is reduced.

[0076] Regarding step S140, as another possible implementation, the electronic device can also automatically analyze and obtain the boundary values of the request parameters based on pre-set boundary value analysis rules and / or the value range of the request parameters, thereby reducing the boundary value analysis cost.

[0077] In some embodiments of the present disclosure, after step S170, it may further include steps S180 and S190 as shown in Figure 4 Figure.

[0078] S180. Determine the first code coverage rate and the second code coverage rate, where the first code coverage rate is the proportion of the software source code that is tested during the testing of the software based on the test case, and the second code coverage rate is the proportion of the software source code that is tested during the testing of the software based on the test case and the newly added test case.

[0079] Exemplarily, the first code coverage rate and the second code coverage rate can be determined by a pre-configured code coverage tool (such as JaCoCo, Java Code Coverage).

[0080] S190. When the second code coverage rate is less than or equal to the first code coverage rate, delete the newly added test cases.

[0081] Exemplarily, if the second code coverage rate is greater than the first code coverage rate, it indicates that the newly added test cases have improved the code coverage rate during the software testing process. Therefore, when the second code coverage rate is greater than the first code coverage rate, no action needs to be taken, that is, the test case set includes both the original test cases and the newly added test cases. If the second code coverage rate is less than or equal to the first code coverage rate, it indicates that the newly added test cases are not helpful for improving the code coverage rate. Therefore, when the second code coverage rate is less than or equal to the first code coverage rate, deleting the newly added test cases in a timely manner is beneficial to improving the software testing efficiency.

[0082] For the test case generation method of the above embodiment, when the second code coverage rate is less than or equal to the first code coverage rate, delete the newly added test cases. In this way, by comparing the first code coverage rate and the second code coverage rate, the actual contribution of the newly added test cases to code coverage can be evaluated, avoiding the introduction of invalid test cases, and improving the quality of the test case set. At the same time, deleting the newly added test cases that make no contribution to the code coverage rate in a timely manner reduces the unnecessary test execution overhead, improves the utilization rate of test resources, and enhances the software testing efficiency.

[0083] In some embodiments of the present disclosure, after step S130, the following steps S210 to S230 may further be included as Figure 5 shown.

[0084] S210. In response to the new code of the software going online, in the running environment of the new code, perform traffic replay based on the request information in the test cases.

[0085] Exemplarily, it can be automatically determined that the new code goes online by listening to the new code online message of the software.

[0086] S220. When the traffic replay result is inconsistent with the response information in the test cases, determine whether the test case is noise.

[0087] Exemplarily, the inconsistency between the traffic replay result and the response information in the test cases may be caused by the test case belonging to noise, or may be caused by the test case no longer being applicable to the new code. By determining whether the test case is noise, the cause of the inconsistency can be determined, thus providing support for the execution of subsequent steps.

[0088] The noise recognition method in the related art can be used to determine whether a test case is noise.

[0089] Exemplarily, when the traffic replay result of the request information in a test case is consistent with the response information in this test case, no processing is required for this test case. Then, it is determined whether the traffic replay result of the request information in another test case is consistent with the response information in this other test case, and so on.

[0090] S230. When the test case is not noise, mark the status of the test case as an invalid status or delete the test case.

[0091] Since the test case is not noise, it can be considered that the reason for the inconsistency between the traffic replay result and the response information in the test case is that the test case is no longer applicable to the new code. Therefore, mark the status of the test case as an invalid status or delete the test case to avoid using useless test cases for software testing continuously, improve the quality of the test case set, and improve the accuracy of the software test result.

[0092] Specifically, the processing method when the test case is not noise can be pre-configured as marking the status of the test case as an invalid status or deleting the test case, so as to facilitate the electronic device to accurately manage the test case when it is determined that the test case is not noise.

[0093] Exemplarily, when the test case is noise, add the identifier of the test case to the noise library, and mark the status of the test case as an invalid status or delete the test case, so as to avoid using the noise for software testing next time and avoid affecting the accuracy of the software test result due to using the noise.

[0094] The test case generation method in the above embodiment can automatically perform traffic replay based on the test case after the new code is online, can timely discover the inconsistency problem between the test case and the new code, realizes the dynamic management and maintenance of the test case, and is beneficial to maintaining the timeliness of the test case set.

[0095] Regarding step S220, in some embodiments of the present disclosure, it may include steps S221 and S222 as Figure 6 shown.

[0096] S221. In the running environment of the new code, perform multiple traffic replays based on the request information in the test case to obtain multiple traffic replay results.

[0097] The number of traffic replays and the interval duration of the traffic replays can be set according to actual needs and are not limited herein.

[0098] Exemplarily, before S221, the identifier of the test case can be directly matched with the identifiers of the noises in the pre-generated noise library. If there is a matching noise, it is determined that the test case is a noise; if there is no matching noise, it is further determined whether the test case is a noise through step S221 and step S222.

[0099] S222. In the case where multiple traffic playback results are different from each other, it is determined that the test case is a noise.

[0100] The traffic playback result includes the response information obtained by playing back the request information.

[0101] In the case where the response information obtained by playback includes multiple unordered data, if an unordered data exists in the response information of one traffic playback result but does not exist in the response information of another traffic playback result, it is determined that these two traffic playback results are different from each other; if each unordered data in the response information of one traffic playback result exists in the response information of another traffic playback result, and each unordered data in the response information of another traffic playback result exists in the response information of one traffic playback result, and the number of unordered data in the two traffic playback results is the same, it is determined that these two traffic playback results are the same.

[0102] In the case where the response information obtained by playback includes multiple ordered data, if each ordered data in the response information of one traffic playback result exists in the response information of another traffic playback result, and each ordered data in the response information of another traffic playback result exists in the response information of one traffic playback result, and the number and order of the ordered data in the two traffic playback results are the same, it is determined that these two traffic playback results are the same, otherwise it is determined that these two traffic playback results are different from each other.

[0103] Exemplarily, in the case where there are identical traffic playback results among multiple traffic playback results, it is determined that the test case is not a noise.

[0104] The test case generation method of the above embodiment verifies the consistency of the test case through multiple traffic playbacks, can more accurately determine whether the test case is a noise, and reduces the possibility of misjudgment.

[0105] Please combine Figure 7 , in an example, the test case generation method may include the following steps S301 to step S319. The content related to steps S301 to S319 can refer to the description of the above embodiment. For the sake of brevity, it will not be elaborated here.

[0106] In step S301, the traffic of an interface of the software is recorded to obtain multiple target traffic flows. Among them, the recorded traffic can be stored in the first database (such as Hbase database) in the form of key-value pairs. In this way, the recorded traffic can be stored completely, facilitating subsequent calls and viewing.

[0107] In step S302, the call data during the generation of the response information in the multiple target traffic flows is obtained.

[0108] In step S303, at least one group of first target traffic flows and second target traffic flows are determined from the multiple target traffic flows. Among them, each group of first target traffic flows includes multiple target traffic flows with the same number of external dependency calls and / or the same types of internal method calls, and the second target traffic flows are the target traffic flows other than at least one group of first target traffic flows among the multiple target traffic flows.

[0109] In step S304, one target traffic flow in each group of first target traffic flows and the second target traffic flow in at least one group of first target traffic flows are used as the deduplicated target traffic flows.

[0110] In step S305, the deduplicated target traffic flows are used as test cases.

[0111] In step S306, the request information in the test case is input into the trained boundary value analysis model, and the boundary value analysis of the request parameters in the request information of the test case is performed through the boundary value analysis model to obtain the boundary values of the request parameters.

[0112] In step S307, the target request information is generated according to the request information and the parameter values of the request parameters in the test case.

[0113] In step S308, the traffic corresponding to the target request information is recorded.

[0114] In step S309, the traffic corresponding to the target request information is used as an additional test case.

[0115] In step S310, the first code coverage rate c1 and the second code coverage rate c2 are determined. Among them, the first code coverage rate c1 is the proportion of the software source code that is tested during the testing of the software based on the test cases, and the second code coverage rate c2 is the proportion of the software source code that is tested during the testing of the software based on the test cases and the additional test cases.

[0116] In step S311, it is judged whether the second code coverage rate c2 is less than or equal to the first code coverage rate c1. If so, step S312 is executed; otherwise, step S313 is executed.

[0117] In step S312, when the second code coverage rate c2 is less than or equal to the first code coverage rate c1, the newly added test cases are deleted.

[0118] In step S313, when the second code coverage rate c2 is greater than the first code coverage rate c1, no action is taken. It should be noted that for each test case generated in step S305, steps S306 to S313 need to be executed separately. For each test case, the target parameters of the test case can be stored in a second database (such as Elasticsearch), so that the target test cases can be quickly filtered through the second database, and the complete information of the filtered target test cases can be obtained through the first database.

[0119] In step S314, in response to the online of new code of the software, a test case set is determined, that is, the set of test cases whose status associated with the software is the valid status.

[0120] In step S315, a test case is selected from the test case set for traffic replay. Specifically, in the running environment of the new code, traffic replay is performed based on the request information in the test case.

[0121] In step S316, it is judged whether the traffic replay result is consistent with the response information in the test case. If so, step S315 is executed; otherwise, step S317 is executed.

[0122] In step S317, when the traffic replay result is inconsistent with the response information in the test case, it is judged whether the test case is noise. If so, step S318 is executed; otherwise, step S319 is executed.

[0123] In step S318, when the test case is noise, the identifier of the test case is added to the noise library.

[0124] In step S319, when the test case is not noise, the status of the test case is marked as the invalid status.

[0125] In step S320, it is judged whether all the test cases in the test case set have been traversed. If so, the process ends; otherwise, step S315 is executed. In this way, the automated management of the entire life cycle of test cases is realized. Among them, steps S301 to S309 are for the generation of test cases, steps S310 to S313 are for the expansion of test cases, and steps S314 to S320 are for the validity management of test cases.

[0126] Based on any of the above embodiments, the present disclosure further provides a test case generation device.

[0127] Figure 8It is a structural schematic block diagram of a test case generation device according to an embodiment of the present disclosure.

[0128] As Figure 8 shown, the test case generation device includes: An acquisition module 110, configured to acquire a plurality of target traffic flows and call data during the generation of response information in the plurality of target traffic flows. Among them, the plurality of target traffic flows are traffic flows pre-recorded for the same interface of the same software, and the traffic flow can be request information transmitted through the interface during the operation of the software and response information corresponding to the request information; A deduplication module 120, configured to deduplicate the target traffic flows with the same call data among the plurality of target traffic flows to obtain deduplicated target traffic flows; A generation module 130, configured to use the deduplicated target traffic flows as test cases.

[0129] The above test case generation device may be in the form of computer software, and each module of the above test case generation device may be implemented by computer software modules.

[0130] In some embodiments of the present disclosure, the call data includes the number of external dependency calls and / or the types of internal method calls; correspondingly, the deduplication module 120 is configured to: determine at least one group of first target traffic flows and second target traffic flows among the plurality of target traffic flows, where each group of first target traffic flows includes a plurality of target traffic flows with the same number of external dependency calls and / or the same types of internal method calls, and the second target traffic flows are the target traffic flows other than at least one group of first target traffic flows among the plurality of target traffic flows; and use one target traffic flow in each group of first target traffic flows and the second target traffic flows as the deduplicated target traffic flows.

[0131] In some embodiments of the present disclosure, the test case generation device may further include: an analysis module, configured to perform boundary value analysis on the request parameters of the request information in the test case to obtain the boundary values of the request parameters; a second generation module, configured to generate target request information according to the request information and the parameter values of the request parameters in the test case; a recording module, configured to record the traffic flow corresponding to the target request information; and a third generation module, configured to use the traffic flow corresponding to the target request information as a new test case.

[0132] In some embodiments of the present disclosure, the analysis module is configured to: input the request information in the test case into a trained boundary value analysis model, and perform boundary value analysis on the request parameters of the request information in the test case through the boundary value analysis model to obtain the boundary values of the request parameters.

[0133] In some embodiments of the present disclosure, the test case generation device may further include: a determination module, configured to determine a first code coverage rate and a second code coverage rate, where the first code coverage rate is the proportion of the software source code that is tested during the process of testing the software based on the test cases, and the second code coverage rate is the proportion of the software source code that is tested during the process of testing the software based on the test cases and the newly added test cases; and a deletion module, configured to delete the newly added test cases when the second code coverage rate is less than or equal to the first code coverage rate.

[0134] In some embodiments of the present disclosure, the test case generation device may further include: a traffic replay module, configured to, in response to the online of new code of the software, perform traffic replay based on the request information in the test cases in the running environment of the new code; a judgment module, configured to judge whether the test case is noise when the traffic replay result is inconsistent with the response information in the test cases; and a processing module, configured to, when the test case is not noise, mark the status of the test case as an invalid status or delete the test case.

[0135] In some embodiments of the present disclosure, the judgment module is configured to: perform multiple traffic replays based on the request information in the test cases in the running environment of the new code to obtain multiple traffic replay results; and determine that the test case is noise when the multiple traffic replay results are different from each other.

[0136] The implementation processes of the functions and effects of each module in the above device are specifically described in detail in the implementation processes of the corresponding steps in the above method, and will not be elaborated here.

[0137] The execution subject of the test case generation method in the specific embodiments of the present disclosure may be an electronic device such as a server, a mobile phone, or a computer.

[0138] Therefore, based on any of the above embodiments, the present disclosure further provides an electronic device, which can execute the test case generation method of any of the above embodiments described in the present disclosure.

[0139] Figure 9 It is a structural schematic diagram of an electronic device 1000 according to an embodiment of the present disclosure.

[0140] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture may include any number of interconnected buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, a memory 1300, and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc.

[0141] The bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience in representation, only one connecting line is used in this figure, but it does not mean that there is only one bus or one type of bus.

[0142] The present disclosure also provides a readable storage medium having a computer program stored therein, and when the computer program is executed by a processor, it is used to implement the above-mentioned method. The "readable storage medium" can be any device that can contain, store, communicate, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples of the readable storage medium include the following: an electrical connection part (electronic device) having one or more wirings, a portable computer disk cartridge (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.

[0143] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, the processes or functions of the present disclosure are executed in whole or in part.

[0144] The computer program or instructions can be stored in a readable storage medium, or transmitted from one readable storage medium to another readable storage medium. For example, the computer program or instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired or wireless manner. The readable storage medium can be any available medium that can be accessed or a data storage device such as a server or data center integrating one or more available mediums. The available medium can be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it can also be an optical medium, such as a digital video disc; or it can be a semiconductor medium, such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or can include both volatile and non-volatile types of storage media.

[0145] Those skilled in the art should understand that the embodiments of the present disclosure may be provided as a method, a system, or a computer program product. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0146] The present disclosure is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the present disclosure. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for realizing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.

[0147] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means realizes the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.

[0148] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for realizing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.

[0149] In the description of this specification, the description with reference to terms such as "one embodiment / way", "some embodiments / ways", "example", "specific example", or "some examples", etc. means that the specific features, structures, or characteristics described in connection with the embodiment / way or example are included in at least one embodiment / way or example of the present disclosure. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment / way or example. Moreover, the specific features, structures, or characteristics described can be combined in a suitable manner in any one or more embodiments / ways or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments / ways or examples described in this specification and the features of different embodiments / ways or examples.

[0150] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "a plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0151] Those skilled in the art should understand that the above embodiments are merely for clearly explaining the present disclosure and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications can be made on the basis of the above disclosure, and these changes or modifications are still within the scope of the present disclosure.

Claims

1. A test case generation method, characterized in that: include: Acquire call data of multiple target flows and response information in the multiple target flows during the generation process, wherein the multiple target flows are flows pre-recorded for the same interface of the same software, and the flows are request information transmitted through the interface during the operation of the software and response information corresponding to the request information; Deduplication of the target flows with the same call data among the multiple target flows to obtain deduplication target flows; and The target traffic after deduplication is used as a test case.

2. The test case generation method according to claim 1, characterized in that: The call data includes the number of external dependency calls and / or the type of internal method calls; Deduplication of the target flows with the same call data among the multiple target flows to obtain deduplication target flows includes: Determine at least one group of first target traffic and second target traffic among the multiple target traffics, wherein each group of the first target traffics includes multiple target traffics with the same number of external dependency calls and / or the same type of internal method calls, and the second target traffic is the target traffic among the multiple target traffics except the at least one group of the first target traffic; and One target flow in each group of first target flows in the at least one group of first target flows and the second target flow are used as the deduplicated target flows.

3. The test case generation method according to claim 1, characterized in that: After taking the deduplicated target traffic as a test case, the following is also included: Performing boundary value analysis on request parameters of request information in the test case to obtain boundary values ​​of the request parameters; Generate target request information according to the request information in the test case and the parameter value of the request parameter; Recording the traffic corresponding to the target request information; and The traffic corresponding to the target request information is used as a new test case.

4. The test case generation method according to claim 3, characterized in that: Performing boundary value analysis on request parameters of request information in the test case to obtain boundary values ​​of the request parameters includes: The request information in the test case is input into a trained boundary value analysis model, and the boundary value analysis model is used to perform boundary value analysis on the request parameters of the request information in the test case to obtain the boundary values ​​of the request parameters.

5. The test case generation method according to claim 3, characterized in that: After the traffic corresponding to the target request information is used as a new test case, the following is also included: Determining a first code coverage rate and a second code coverage rate, wherein the first code coverage rate is a proportion of software source code tested during a test of the software based on the test case, and the second code coverage rate is a proportion of software source code tested during a test of the software based on the test case and the newly added test case; and When the second code coverage is less than or equal to the first code coverage, the newly added test case is deleted.

6. The test case generation method according to claim 1, characterized in that: After taking the deduplicated target traffic as a test case, the following is also included: In response to the new code of the software being online, in the running environment of the new code, traffic playback is performed based on the request information in the test case; In the case where the traffic playback result is inconsistent with the response information in the test case, determining whether the test case is noise; and If the test case is not noise, the state of the test case is marked as an invalid state, or the test case is deleted.

7. The test case generation method according to claim 6, characterized in that: Determining whether the test case is noise includes: In the running environment of the new code, multiple traffic playbacks are performed based on the request information in the test case to obtain multiple traffic playback results; and When the multiple traffic playback results are different from each other, it is determined that the test case is noise.

8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instructions stored in the memory, so that the processor executes the test case generation method according to any one of claims 1 to 7.

9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which, when executed by a processor, are used to implement the test case generation method described in any one of claims 1 to 7.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the test case generating method according to any one of claims 1 to 7 is implemented.