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

Through the combination of Doom traffic platform and intelligent single-test server, unit test cases are automatically generated, solving the problems of large workload, low efficiency and high cost of manually writing unit test cases, and improving testing efficiency and coverage.

CN119065981APending Publication Date: 2024-12-03PING AN BANK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411202461.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

In the prior art, manual writing of unit test cases has problems such as high workload, low efficiency and high cost, especially in complex financial systems.

Method used

The traffic data of the project to be tested in the test environment is captured through the Doom traffic platform, and sent it to the intelligent single test server for analysis and matching, generate test case templates and data sets, and automatically generate unit test cases.

Benefits of technology

It realizes the automated generation of unit test cases, reduces the workload and cost of manual writing, and improves test efficiency and coverage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119065981A_ABST
    Figure CN119065981A_ABST
Patent Text Reader

Abstract

The invention discloses a unit test case generation method and device, computer equipment and a storage medium, relates to the technical field of testing, and is applied to a financial service related unit test case generation scene, and the method comprises the following steps: capturing flow data generated by a to-be-tested project in a test environment through a Doom flow platform, sending the flow data to an intelligent single-measurement server; analyzing the received flow data through the intelligent single test server, and generating a test case data set; and in response to a case generation instruction triggered by a target user at the intelligent single test server, generating a test case template, and after matching and splicing the test case template and the test case data set, generating a unit test case. By means of the method, automatic generation of the unit test case can be achieved, and the problems that in the prior art, the workload is large, the efficiency is low and the cost is high when the unit test case is manually written can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of testing technology, and is applied to unit test case generation scenarios related to financial services, and specifically to a unit test case generation method, device, computer equipment, and non-volatile computer-readable storage medium. Background Art

[0002] At present, with the rapid development of financial technology, the software development of many projects such as the clearing of bank financial products, calculation of returns and market analysis has become increasingly complex. These projects not only require a high degree of accuracy and stability, but also must comply with strict regulatory requirements and security standards. Therefore, developers must write detailed unit test cases during the development process to ensure the quality and performance of related projects.

[0003] Currently, most traditional unit testing methods rely on developers to manually write unit test cases. There are several significant problems with manually writing unit test cases:

[0004] 1. Heavy workload: Manually writing unit test cases is a labor-intensive process, especially for financial systems involving a large number of interfaces and complex logic;

[0005] 2. Low efficiency: Manually writing test cases is not only time-consuming but also error-prone, resulting in insufficient test coverage and possible omission of important test scenarios;

[0006] 3. High cost: As the scale of the project expands, the cost of manual testing will increase significantly, which includes not only direct labor costs, but also potential risk costs caused by insufficient testing.

[0007] Therefore, the existing technology still needs to be improved and developed. Summary of the invention

[0008] In view of the above-mentioned deficiencies in the prior art, the object of the present invention is to provide a unit test case generation method, apparatus, computer equipment and non-volatile computer-readable storage medium that can be used in financial technology or other related fields, aiming to solve the problems of large workload, low efficiency and high cost in manually writing unit test cases in the prior art.

[0009] In order to achieve the above object, the present invention adopts the following technical solutions:

[0010] A method for generating unit test cases, comprising:

[0011] Capture the traffic data generated by the project to be tested in the test environment through the Doom traffic platform, and send the traffic data to the intelligent single test server;

[0012] The intelligent single test server parses the received traffic data to generate a test case data set;

[0013] In response to a case generation instruction triggered by a target user on the intelligent unit test server, a test case template is generated, and after matching and splicing the test case template with the test case data set, a unit test case is generated.

[0014] In a further technical solution, the unit test case generation method, wherein the flow data generated by the project to be tested in the test environment is captured by the Doom flow platform, and the flow data is sent to the intelligent unit test server, includes:

[0015] Install the traffic acquisition plug-in in the Doom traffic platform in advance;

[0016] The Doom original data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the corresponding traffic data is obtained after data processing is performed on the Doom original data;

[0017] The traffic data is sent to the intelligent single test server through the traffic acquisition plug-in.

[0018] In a further technical solution, the unit test case generation method, wherein the Doom raw data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the corresponding traffic data is obtained after data processing is performed on the Doom raw data, including:

[0019] The Doom raw data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the corresponding Doom traffic data is obtained after preprocessing the Doom raw data;

[0020] After the Doom traffic data is sampled and processed by the traffic acquisition plug-in, corresponding traffic data is obtained.

[0021] In a further technical solution, the unit test case generation method, wherein the intelligent unit test server parses the traffic data received to generate a test case data set, includes:

[0022] The intelligent single test server parses the received traffic data and extracts key information from the traffic data to generate a test case data set;

[0023] The generated test case data set is stored in the database of the intelligent unit testing server.

[0024] In a further technical solution, the unit test case generation method, wherein the response target user triggers a case generation instruction on the intelligent unit test server, generates a test case template, and generates a unit test case after matching and splicing the test case template with the test case data set, includes:

[0025] Responding to a case generation instruction triggered by a target user clicking a case generation button on the intelligent single testing server;

[0026] Analyze the code base of the project to be tested through the intelligent single test server to generate multiple test case templates corresponding to the class and / or method dimensions of the project to be tested;

[0027] After matching and splicing the plurality of test case templates with the test case data set through the intelligent unit test server, a plurality of unit test cases are generated.

[0028] In a further technical solution, the unit test case generation method, wherein the intelligent unit test server matches and splices the plurality of test case templates with the test case data set to generate a plurality of unit test cases, comprises:

[0029] Analyzing the plurality of test case templates through the intelligent single test server to identify the position in each test case template where data needs to be filled;

[0030] According to the position of the data to be filled in each of the test case templates, searching and matching the data that can be filled in each of the test case templates in the test case data set;

[0031] After the intelligent unit test server fills the retrieved target data that matches the position that needs to be filled with data in each test case template into the corresponding position in each test case template, a corresponding plurality of unit test cases are generated.

[0032] In a further technical solution, the unit test case generation method, wherein after the intelligent unit test server fills the retrieved target data matching the position where data needs to be filled in each test case template into the corresponding position in each test case template, generates a corresponding plurality of unit test cases, further comprising:

[0033] Verifying each of the generated unit test cases according to a preset verification strategy;

[0034] The unit test cases that have passed the verification are stored in the database of the intelligent unit testing server.

[0035] A unit test case generating device, comprising:

[0036] A data capture module is used to capture the traffic data generated by the project to be tested in the test environment through the Doom traffic platform, and send the traffic data to the intelligent single test server;

[0037] A data analysis module, used to analyze the traffic data received by the intelligent single test server to generate a test case data set;

[0038] The case generation module is used to respond to the case generation instruction triggered by the target user on the intelligent unit test server, generate a test case template, and generate a unit test case after matching and splicing the test case template with the test case data set.

[0039] A computer device, wherein the computer device comprises at least one processor; and

[0040] a memory communicatively connected to the at least one processor; wherein,

[0041] The memory stores a computer program that can be executed by the at least one processor. When the computer program is executed by the at least one processor, the unit test case generation method as described in any one of the above items can be implemented.

[0042] A non-volatile computer-readable storage medium stores a computer program, wherein the computer program, when executed by at least one processor, can implement any of the unit test case generation methods described above.

[0043] Compared with the prior art, the present invention provides a method, device, computer equipment and non-volatile computer-readable storage medium for generating unit test cases, wherein the method includes: capturing the traffic data generated by the project to be tested in the test environment through the Doom traffic platform, and sending the traffic data to the intelligent unit test server; parsing the traffic data received by the intelligent unit test server to generate a test case data set; responding to the case generation instruction triggered by the target user on the intelligent unit test server, generating a test case template, and matching and splicing the test case template with the test case data set to generate a unit test case. In this way, the method of the present invention can realize the automatic generation of unit test cases, which can solve the problems of large workload, low efficiency and high cost in manually writing unit test cases in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0045] Figure 1 A schematic diagram of a flow chart of a method for generating unit test cases provided in an embodiment of the present invention.

[0046] Figure 2 A schematic diagram of functional modules of a unit test case generating device provided by an embodiment of the present invention.

[0047] Figure 3 A schematic diagram of the hardware structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0049] In the description of the present invention, the terms "include", "including", "have", "contain", etc. are all open terms, which mean including but not limited to. The descriptions with reference to the terms "one embodiment", "a specific embodiment", "some embodiments", "for example", etc. mean that the specific features, structures or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures or characteristics described may be combined in a suitable manner in any one or more embodiments or examples. The order of steps involved in each embodiment is used to schematically illustrate the implementation of the present application, and the order of steps therein is not limited and can be appropriately adjusted as needed.

[0050] Various non-limiting embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.

[0051] At present, with the rapid development of financial technology, the software development of many projects such as the clearing of bank financial products, calculation of returns and market analysis has become increasingly complex. These projects not only require a high degree of accuracy and stability, but also must comply with strict regulatory requirements and security standards. Therefore, developers must write detailed unit test cases during the development process to ensure the quality and performance of related projects.

[0052] Currently, most traditional unit testing methods rely on developers to manually write unit test cases. There are several significant problems with manually writing unit test cases:

[0053] 1. Heavy workload: Manually writing unit test cases is a labor-intensive process, especially for financial systems involving a large number of interfaces and complex logic;

[0054] 2. Low efficiency: Manually writing test cases is not only time-consuming but also error-prone, resulting in insufficient test coverage and possible omission of important test scenarios;

[0055] 3. High cost: As the scale of the project expands, the cost of manual testing will increase significantly, which includes not only direct labor costs, but also potential risk costs caused by insufficient testing.

[0056] To solve the above problems, see Figure 1 The embodiment of the present invention provides a method for generating a unit test case, wherein the method comprises the steps of:

[0057] S100, capturing the traffic data generated by the project to be tested in the test environment through the Doom traffic platform, and sending the traffic data to the intelligent single test server;

[0058] S200, parsing the received traffic data by the intelligent single test server to generate a test case data set;

[0059] S300, responding to a case generation instruction triggered by a target user on the intelligent unit test server, generating a test case template, and matching and concatenating the test case template with the test case data set to generate a unit test case.

[0060] Furthermore, the unit test case generation method, wherein the step S100, capturing the traffic data generated by the project to be tested in the test environment through the Doom traffic platform, and sending the traffic data to the intelligent unit test server, specifically includes:

[0061] Install the traffic acquisition plug-in in the Doom traffic platform in advance;

[0062] The Doom original data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the corresponding traffic data is obtained after data processing is performed on the Doom original data;

[0063] The traffic data is sent to the intelligent single test server through the traffic acquisition plug-in.

[0064] Furthermore, the unit test case generation method, wherein the Doom original data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the corresponding traffic data is obtained after data processing is performed on the Doom original data, specifically includes:

[0065] The Doom raw data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the corresponding Doom traffic data is obtained after preprocessing the Doom raw data;

[0066] After the Doom traffic data is sampled and processed by the traffic acquisition plug-in, corresponding traffic data is obtained.

[0067] In the specific implementation, in this embodiment, a traffic acquisition plug-in is pre-installed in the Doom traffic platform; the Doom original data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the Doom original data is pre-processed to obtain the corresponding Doom traffic data; the Doom traffic data is sampled and processed by the traffic acquisition plug-in to obtain the corresponding traffic data; the traffic acquisition plug-in sends the traffic data to the intelligent single test server; wherein, the specific implementation process is roughly as follows:

[0068] 1) Install the traffic acquisition plug-in

[0069] In the Doom traffic platform, you first need to install a dedicated traffic acquisition plug-in (such as the Doom agent plug-in). This traffic acquisition plug-in is a tool for capturing network traffic, which can be integrated into the test environment of the project to be tested.

[0070] The installation process may include downloading the plug-in, configuring plug-in parameters (such as the type of traffic to be captured, capture conditions, etc.), and deploying the plug-in to the server in the test environment;

[0071] Among them, Doom Traffic Platform is an automated testing tool platform that improves the efficiency and quality of software testing by capturing real online traffic and using it for automatic regression testing. The core feature of this platform is that it can record and replay traffic within the application through AOP (aspect-oriented programming) technology, and supports the verification of read and write interfaces, including user order interfaces, payment interfaces, etc. The advantage of Doom Traffic Platform is that it can provide low-cost, high-coverage test cases, while being less invasive to applications and supporting a variety of test scenarios, such as system reconstruction and daily automated regression testing. Doom Traffic Platform is open to the public as a cloud service, supporting direct application for use by applications on Alibaba Cloud's Yunxiao, and also supporting direct application for use by any application that can access the public network. In general, Doom Traffic Platform is a powerful tool that can help enterprises solve multiple problems in the R&D and testing process, improve testing efficiency, reduce costs, and ultimately improve the quality of software products.

[0072] 2) Capture Doom raw data

[0073] After the traffic acquisition plug-in is activated, it starts to monitor and capture all network traffic generated by the project under test in the test environment; this data includes requests sent by the client and responses returned by the server;

[0074] The captured data is usually raw and may contain a lot of information, such as HTTP headers, cookies, request bodies, response bodies, etc.

[0075] 3) Preprocessing Doom raw data

[0076] The captured Doom raw data needs to be preprocessed for subsequent analysis and use; the preprocessing steps may include filtering irrelevant traffic, removing duplicate data, formatting data structures, etc.

[0077] Preprocessing can be done through built-in functions of plugins, or by writing scripts or using data processing tools;

[0078] 4) Sampling and processing

[0079] In order to improve processing efficiency and reduce data volume, the Doom traffic data obtained after preprocessing is sampled; the sampling strategy can be time-based (such as sampling once every minute), quantity-based (such as sampling once every 100 requests) or condition-based (such as sampling only requests containing specific parameters);

[0080] The sampling process needs to ensure the representativeness of the samples so that the generated unit test cases can cover the key test scenarios;

[0081] 5) Send traffic data to the smart single test server

[0082] The sampled and processed data is organized into a traffic data set and sent to the intelligent single test server through the traffic acquisition plug-in; data transmission can be carried out through the network, using encryption and security protocols to ensure data security and integrity;

[0083] Through the above process, it is ensured that the traffic data captured from the test environment can be effectively processed and transmitted, providing the necessary data support for the generation of automated unit test cases.

[0084] Further, the unit test case generation method, wherein the step S200, parsing the traffic data received by the intelligent unit test server to generate a test case data set, specifically includes:

[0085] The intelligent single test server parses the received traffic data and extracts key information from the traffic data to generate a test case data set;

[0086] The generated test case data set is stored in the database of the intelligent unit testing server.

[0087] In the specific implementation, in this embodiment, the intelligent single test server parses the received traffic data and extracts key information from the traffic data to generate a test case data set; the generated test case data set is stored in the database of the intelligent single test server; wherein the specific implementation process is roughly as follows:

[0088] 1) Traffic data reception

[0089] The smart single test server receives traffic data sent by the traffic acquisition plug-in through its network interface; this data may include HTTP requests and responses, API call details, user operation records, etc.

[0090] 2) Data analysis

[0091] The server-side parsing module processes the received traffic data and extracts key information; this usually involves parsing HTTP request and response messages, JSON or XML data formats, and other relevant information that may be contained in the traffic;

[0092] During the parsing process, key information such as API endpoints, request parameters, response status codes, response bodies, etc. will be identified and extracted. This information is essential for simulating user behavior and reproducing test scenarios.

[0093] 3) Extraction of key information

[0094] Based on the analysis, further extract key information useful for unit test case generation; this may include determining test scenarios, identifying potential test data, and discovering possible test assertion points;

[0095] The extracted information is organized into a structured format, such as a test case dataset, to facilitate subsequent unit test case generation and execution;

[0096] 4) Dataset Generation

[0097] Based on the extracted key information, the intelligent unit test server generates test case data sets; these data sets contain all the necessary information for building unit test cases, such as input data, expected results, test steps, etc.

[0098] The test case dataset will be designed in a format that can be directly used by the test framework or test script to facilitate the implementation of automated testing;

[0099] 5) Store in database

[0100] The generated test case dataset is stored in the database of the smart unit testing server; the database may include a relational database such as MySQL, PostgreSQL, or a non-relational database such as MongoDB, depending on the server's architecture and technology stack;

[0101] During data storage, operations such as data indexing, optimizing query performance, and ensuring data consistency and security may be involved;

[0102] Through the above process, the intelligent unit test server can convert the traffic data it receives into a test case data set that can be used for unit test case generation.

[0103] Further, the unit test case generation method, wherein the step S300, in response to the case generation instruction triggered by the target user on the intelligent unit test server, generates a test case template, and generates a unit test case after matching and splicing the test case template with the test case data set, specifically includes:

[0104] Responding to a case generation instruction triggered by a target user clicking a case generation button on the intelligent single testing server;

[0105] Analyze the code base of the project to be tested through the intelligent single test server to generate multiple test case templates corresponding to the class and / or method dimensions of the project to be tested;

[0106] After matching and splicing the plurality of test case templates with the test case data set through the intelligent unit test server, a plurality of unit test cases are generated.

[0107] Furthermore, the unit test case generation method, wherein the intelligent unit test server matches and splices the plurality of test case templates with the test case data set to generate a plurality of unit test cases, specifically includes:

[0108] Analyzing the plurality of test case templates through the intelligent single test server to identify the position in each test case template where data needs to be filled;

[0109] According to the position of the data to be filled in each of the test case templates, searching and matching the data that can be filled in each of the test case templates in the test case data set;

[0110] After the intelligent unit test server fills the retrieved target data that matches the position that needs to be filled with data in each test case template into the corresponding position in each test case template, a corresponding plurality of unit test cases are generated.

[0111] Furthermore, the unit test case generation method, wherein the intelligent unit test server fills the retrieved target data matching the position where data needs to be filled in each test case template into the corresponding position in each test case template, and generates a corresponding plurality of unit test cases, specifically also includes:

[0112] Verifying each of the generated unit test cases according to a preset verification strategy;

[0113] The unit test cases that have passed the verification are stored in the database of the intelligent unit testing server.

[0114] In the specific implementation, in this embodiment, in response to the case generation instruction triggered by the target user clicking the case generation button on the intelligent unit testing server; the code library of the project to be tested is analyzed by the intelligent unit testing server to generate multiple test case templates corresponding to the class and / or method dimensions of the project to be tested; the multiple test case templates are analyzed by the intelligent unit testing server to identify the position where data needs to be filled in each test case template; according to the position where data needs to be filled in each test case template, the data that can be filled in each test case template is retrieved and matched in the test case data set; after the target data matching the position where data needs to be filled in each test case template is filled in the corresponding position in each test case template, the intelligent unit testing server generates multiple corresponding unit test cases; the generated unit test cases are verified according to the preset verification strategy; the unit test cases that have passed the verification are stored in the database of the intelligent unit testing server; wherein the specific implementation process is roughly as follows:

[0115] 1) User triggers case generation command

[0116] The user clicks the "Generate Case" button through the graphical user interface (GUI) of the intelligent unit test server to issue a request to generate a unit test case;

[0117] After receiving the request, the intelligent unit testing server triggers the start of the case generation process;

[0118] 2) Code base analysis and test case template generation

[0119] The intelligent unit test server performs static analysis on the code base of the connected project to be tested and identifies the classes and methods that need to be tested;

[0120] The intelligent unit test server automatically generates multiple test case templates based on the results of code analysis. These templates define the test structure and the data locations that need to be filled in.

[0121] 3) Test case template analysis and data matching

[0122] The intelligent single test server analyzes the generated test case template and identifies the locations in the template where data needs to be filled, such as input parameters, expected output, etc.

[0123] The intelligent unit test server retrieves data in the test case data set that matches the data filling position in the template;

[0124] 4) Data filling and unit test case generation

[0125] The intelligent unit test server fills the matched target data into the corresponding position of the test case template and generates a specific unit test case;

[0126] Each filled template becomes a complete unit test case, containing all necessary information for the test, such as test steps, input data, expected results, etc.

[0127] 5) Unit test case verification

[0128] The intelligent unit test server verifies the generated unit test cases according to the preset verification strategy to ensure the validity and accuracy of the unit test cases;

[0129] Verification may include syntax checking, logical consistency verification, and comparative analysis with existing test cases;

[0130] 6) Store the test cases that have passed the verification

[0131] Verified unit test cases are stored in the database of the intelligent unit test server for subsequent test execution and maintenance;

[0132] The database storage process may involve operations such as version control, case classification, and index optimization to facilitate the management of unit test cases;

[0133] Through the above process, the intelligent unit test server can automatically generate, verify and store unit test cases, thereby improving the testing efficiency and quality in the software development process; of course, users can also view, copy and download complete unit test cases online on the intelligent unit test server.

[0134] It can be seen from the above method embodiments that the unit test case generation method provided by the present invention includes: capturing the traffic data generated by the project to be tested in the test environment through the Doom traffic platform, and sending the traffic data to the intelligent single test server; parsing the traffic data received by the intelligent single test server to generate a test case data set; responding to the case generation instruction triggered by the target user on the intelligent single test server, generating a test case template, and matching and splicing the test case template with the test case data set to generate a unit test case. In this way, the method of the present invention can realize the automatic generation of unit test cases, which can solve the problems of large workload, low efficiency, and high cost in manually writing unit test cases in the prior art.

[0135] Specifically, in the unit test case generation method provided by the embodiment of the present invention, the user can automatically generate a complete unit test case through the intelligent unit test server. It is not just a template case. The case has been filled with the interface traffic information in the user's test environment, which reduces the time for the user to simulate most of the unit test data. The entire process relies on automatic generation by the intelligent unit test server. After generation, it can be directly copied or downloaded for use, which significantly improves the user's development efficiency.

[0136] It should be understood that, although the present application provides method operation steps as described in the embodiments or flowcharts, more or less operation steps may be included based on conventional or non-creative labor, and these operation steps are not necessarily performed in sequence according to the embodiment or flowchart. The order of steps listed in the embodiment or flowchart is only one way of executing the order of many steps, and does not represent the only execution order. It should be noted that there is not necessarily a certain order between the above steps. A person of ordinary skill in the art can understand from the description of the embodiment of the present invention that in different embodiments, the above steps may have different execution orders, that is, they may be executed in parallel, or they may be executed in exchange, etc. Moreover, at least a part of the steps in the embodiment or flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but may be executed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but may be executed in turn, alternately or synchronously with other steps or at least a part of the sub-steps or stages of other steps.

[0137] Based on the above method embodiment, please refer to Figure 2 Another embodiment of the present invention further provides a unit test case generation device, wherein the device comprises:

[0138] The data capture module 11 is used to capture the traffic data generated by the project to be tested in the test environment through the Doom traffic platform, and send the traffic data to the intelligent single test server;

[0139] A data analysis module 12, configured to analyze the traffic data received by the intelligent single test server to generate a test case data set;

[0140] The case generation module 13 is used to respond to the case generation instruction triggered by the target user on the intelligent unit test server, generate a test case template, and generate a unit test case after matching and splicing the test case template with the test case data set.

[0141] Furthermore, in the unit test case generating device, the data capturing module 11 specifically comprises:

[0142] A plug-in installation unit, used for pre-installing a traffic acquisition plug-in in the Doom traffic platform;

[0143] A data capture unit, used to capture the Doom original data generated by the project to be tested in the test environment through the traffic acquisition plug-in, and obtain corresponding traffic data after performing data processing on the Doom original data;

[0144] The data sending unit is used to send the traffic data to the intelligent single test server through the traffic acquisition plug-in.

[0145] Further, the unit test case generation device, wherein the Doom original data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the corresponding traffic data is obtained after data processing of the Doom original data, specifically includes:

[0146] The Doom raw data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the corresponding Doom traffic data is obtained after preprocessing the Doom raw data;

[0147] After the Doom traffic data is sampled and processed by the traffic acquisition plug-in, corresponding traffic data is obtained.

[0148] Furthermore, in the unit test case generating device, the data parsing module 12 specifically includes:

[0149] A data parsing unit, configured to parse the traffic data received by the intelligent single test server and extract key information from the traffic data to generate a test case data set;

[0150] The data storage unit is used to store the generated test case data set in the database of the intelligent unit testing server.

[0151] Furthermore, in the unit test case generating device, the case generating module 13 specifically comprises:

[0152] An instruction response unit, used to respond to a case generation instruction triggered by a target user clicking a case generation button on the intelligent single testing server;

[0153] A template generating unit, configured to analyze the code base of the project to be tested through the intelligent single test server, and generate a plurality of test case templates corresponding to the class and / or device dimensions of the project to be tested;

[0154] The case generation unit is used to generate multiple unit test cases after matching and splicing the multiple test case templates with the test case data set through the intelligent unit test server.

[0155] Further, the unit test case generation device, wherein the intelligent unit test server matches and splices the plurality of test case templates with the test case data set to generate a plurality of unit test cases, specifically includes:

[0156] Analyzing the plurality of test case templates through the intelligent single test server to identify the position in each test case template where data needs to be filled;

[0157] According to the position of the data to be filled in each of the test case templates, searching and matching the data that can be filled in each of the test case templates in the test case data set;

[0158] After the intelligent unit test server fills the retrieved target data that matches the position that needs to be filled with data in each test case template into the corresponding position in each test case template, a corresponding plurality of unit test cases are generated.

[0159] Further, the unit test case generation device, wherein, after the intelligent unit test server fills the retrieved target data matching the position where data needs to be filled in each test case template into the corresponding position in each test case template, generates a corresponding plurality of unit test cases, specifically further includes:

[0160] Verifying each of the generated unit test cases according to a preset verification strategy;

[0161] The unit test cases that have passed the verification are stored in the database of the intelligent unit testing server.

[0162] The specific implementation process and effects of the device embodiment of the present invention can be found in the above method embodiment, which will not be described in detail here.

[0163] It can be seen from the above device embodiments that the unit test case generation device provided by the present invention includes: a data capture module, which is used to capture the traffic data generated by the project to be tested in the test environment through the Doom traffic platform, and send the traffic data to the intelligent single test server; a data analysis module, which is used to analyze the traffic data received by the intelligent single test server to generate a test case data set; a case generation module, which is used to respond to the case generation instruction triggered by the target user on the intelligent single test server, generate a test case template, and match and splice the test case template with the test case data set to generate a unit test case. In this way, the automatic generation of unit test cases can be realized through the device of the present invention, which can solve the problems of large workload, low efficiency, and high cost in manually writing unit test cases in the prior art.

[0164] Specifically, in the unit test case generation device provided by the embodiment of the present invention, the user can automatically generate a complete unit test case through the intelligent unit test server. It is not just a template case. The case has been filled with the interface traffic information in the user's test environment, which reduces the time for the user to simulate most of the unit test data. The entire process relies on automatic generation by the intelligent unit test server. After generation, it can be directly copied or downloaded for use, which significantly improves the user's development efficiency.

[0165] Based on the above method embodiment, please refer to Figure 3 Another embodiment of the present invention further provides a computer device, wherein the computer device 10 comprises:

[0166] memory 120 and one or more processors 110, Figure 3 A processor 110 is used as an example for description. The processor 110 and the memory 120 may be connected via a communication bus or other means. Figure 3 The example of connection via a communication bus is taken as an example.

[0167] The processor 110 is used to complete various control logics of the computer device 10. It can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or any combination of these components. In addition, the processor 110 can also be any traditional processor, microprocessor or state machine. The processor 110 can also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a DSP, or any other such configuration.

[0168] The memory 120, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as the computer program corresponding to the unit test case generation method in any of the above method embodiments of the present invention. The processor 110 executes various functional applications and data processing of the computer device 10 by running the non-volatile software programs, instructions and units stored in the memory 120, that is, implements the unit test case generation method in any of the above method embodiments.

[0169] The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store an application required for operating the device or at least one function; the data storage area may store data created according to the use of the computer device 10, etc. In addition, the memory 120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 120 may optionally include a memory remotely arranged relative to the processor 110, and these remote memories may be connected to the computer device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0170] One or more units are stored in the memory 120, and when executed by one or more processors 110, the unit test case generation method in any of the above method embodiments can be implemented, for example, the above described unit test case generation method can be implemented. Figure 1 The method comprises steps S100 to S300.

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

[0172] Based on the above method embodiments, another embodiment of the present invention further provides a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by at least one processor, the unit test case generation method in any of the above method embodiments can be implemented, for example, the above described Figure 1 The method comprises steps S100 to S300.

[0173] As an example, the non-volatile storage medium can include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable ROM (EEPROM), or a flash memory. Volatile memory can include a random access memory (RAM) as an external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM, (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synch link DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The disclosed memory components or memories of the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.

[0174] Based on the above method embodiments, another embodiment of the present invention further provides a computer program product, the computer program product includes a computer program stored on a non-volatile computer-readable storage medium, the computer program includes program instructions, when the program instructions are executed by a processor, the unit test case generation method in any of the above method embodiments can be implemented, for example, the above described Figure 1 The method comprises steps S100 to S300.

[0175] The embodiments described above are merely illustrative, in which the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0176] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can exist in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0177] Conditional language such as "can," "can," "might," or "may," unless specifically stated otherwise or otherwise understood within the context as used, is generally intended to convey, among other things, that a particular embodiment can include (while other embodiments do not) a particular feature, element, and / or operation. Thus, such conditional language is also generally intended to imply that a feature, element, and / or operation is required for one or more embodiments anyway or that one or more embodiments must include logic for determining, with or without input or prompting, whether such features, elements, and / or operations are included or will be performed in any particular embodiment.

[0178] What has been described herein, in this specification and in the accompanying drawings includes examples that can provide a method, apparatus, computer equipment, and non-volatile computer-readable storage medium for generating unit test cases. Of course, it is not possible to describe every conceivable combination of elements and / or methods for the purpose of describing the various features of the present disclosure, but it is recognized that many other combinations and permutations of the disclosed features are possible. Therefore, it is obvious that various modifications can be made to the present disclosure without departing from the scope or spirit of the present disclosure, but all these various modifications should belong to the scope of protection of the claims attached to the present invention. In addition, or in an alternative, other embodiments of the present disclosure may be obvious from consideration of the present specification and the accompanying drawings and from the practice of the present disclosure as presented herein. It is intended that the examples proposed in the present specification and the accompanying drawings are considered to be illustrative and not restrictive in all respects. Although specific terms are used herein, they are used in a general and descriptive sense and are not used for limiting purposes.

Claims

1. A unit test case generation method, It is characterized in that include: Capture the traffic data generated by the project to be tested in the test environment through the Doom traffic platform, and send the traffic data to the intelligent single test server; The intelligent single test server parses the received traffic data to generate a test case data set; In response to a case generation instruction triggered by a target user on the intelligent unit test server, a test case template is generated, and after matching and splicing the test case template with the test case data set, a unit test case is generated.

2. The unit test case generation method according to claim 1, It is characterized in that The method of capturing the traffic data generated by the project to be tested in the test environment through the Doom traffic platform and sending the traffic data to the intelligent single test server includes: Install the traffic acquisition plug-in in the Doom traffic platform in advance; The Doom original data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the corresponding traffic data is obtained after data processing is performed on the Doom original data; The traffic data is sent to the intelligent single test server through the traffic acquisition plug-in.

3. The unit test case generation method according to claim 2, It is characterized in that The method of capturing the Doom original data generated by the project to be tested in the test environment through the traffic acquisition plug-in and performing data processing on the Doom original data to obtain corresponding traffic data includes: The Doom raw data generated by the project to be tested in the test environment is captured by the traffic acquisition plug-in, and the corresponding Doom traffic data is obtained after preprocessing the Doom raw data; After the Doom traffic data is sampled and processed by the traffic acquisition plug-in, corresponding traffic data is obtained.

4. The unit test case generation method according to claim 2 or 3, It is characterized in that The intelligent single test server analyzes the received traffic data to generate a test case data set, including: The intelligent single test server parses the received traffic data and extracts key information from the traffic data to generate a test case data set; The generated test case data set is stored in the database of the intelligent unit testing server.

5. The unit test case generation method according to claim 4, It is characterized in that The responding target user triggers a case generation instruction on the intelligent unit test server, generates a test case template, and generates a unit test case after matching and splicing the test case template with the test case data set, including: Responding to a case generation instruction triggered by a target user clicking a case generation button on the intelligent single testing server; Analyze the code base of the project to be tested through the intelligent single test server to generate multiple test case templates corresponding to the class and / or method dimensions of the project to be tested; After matching and splicing the plurality of test case templates with the test case data set through the intelligent unit test server, a plurality of unit test cases are generated.

6. The unit test case generation method according to claim 5, It is characterized in that After matching and splicing the plurality of test case templates with the test case data set through the intelligent unit test server, a plurality of unit test cases are generated, including: Analyzing the plurality of test case templates through the intelligent single test server to identify the position in each test case template where data needs to be filled; According to the position of the data to be filled in each of the test case templates, searching and matching the data that can be filled in each of the test case templates in the test case data set; After the intelligent unit test server fills the retrieved target data that matches the position that needs to be filled with data in each test case template into the corresponding position in each test case template, a corresponding plurality of unit test cases are generated.

7. The unit test case generation method according to claim 6, It is characterized in that After the intelligent unit test server fills the retrieved target data matching the position in each test case template that needs to be filled with data into the corresponding position in each test case template, and generates a plurality of corresponding unit test cases, the method further includes: Verifying each of the generated unit test cases according to a preset verification strategy; The unit test cases that have passed the verification are stored in the database of the intelligent unit testing server.

8. A unit test case generating device, It is characterized in that include: A data capture module is used to capture the traffic data generated by the project to be tested in the test environment through the Doom traffic platform, and send the traffic data to the intelligent single test server; A data analysis module, used to analyze the traffic data received by the intelligent single test server to generate a test case data set; The case generation module is used to respond to the case generation instruction triggered by the target user on the intelligent unit test server, generate a test case template, and generate a unit test case after matching and splicing the test case template with the test case data set.

9. A computer device, It is characterized in that The computer device comprises at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor. When the computer program is executed by the at least one processor, the unit test case generation method according to any one of claims 1 to 7 can be implemented.

10. A non-volatile computer-readable storage medium, It is characterized in that The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by at least one processor, the unit test case generation method according to any one of claims 1 to 7 can be implemented.