Test data generation method and device, equipment, storage medium and program product

By receiving and parsing test data generation requests, creating SQL statements and generating random data, the problem of low efficiency in test data generation in database tests is solved, and one-click generation and high-efficiency generation of test data is realized.

CN119557225APending Publication Date: 2025-03-04CHINA TELECOM CLOUD TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411730729.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

In database testing, the generation efficiency of test data is low, mainly because the testers need to manually generate random data that complies with business rules and multiple field types, which is time-consuming and labor-intensive.

Method used

By receiving test data generation requests, parsing the request content, creating SQL statements for the target database, and calling the data generation tool to generate random data, and finally generating test data. This method does not require testers to understand the SQL syntax of the target database, and realizes one-click generation of test data.

Benefits of technology

It greatly improves the efficiency of the generation of test data, reduces the time and cost of manually generating test data, and simplifies the database testing process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557225A_ABST
    Figure CN119557225A_ABST
Patent Text Reader

Abstract

The invention relates to a test data generation method and device, equipment, a storage medium and a program product. The method comprises the following steps: receiving a test data generation request; analyzing the generation request of the test data, and determining identification information of a to-be-tested target database and generation parameters of the test data; creating a structured query language (SQL) statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data; calling a data generation tool to generate random data corresponding to the target database; and generating test data of the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database. By adopting the method, the generation efficiency of the test data can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data testing technology, and in particular to a method, device, equipment, storage medium and program product for generating test data. Background Art

[0002] In today's rapidly developing information technology, databases are the core components of data storage and management, and their stability and performance are crucial to business operations. However, database testing is often cumbersome and expensive due to the complexity and cost of data generation.

[0003] In related technologies, test data is often generated manually, and testers need to quickly master and become familiar with the syntax specifications of the Structured Query Language (SQL) of the database to be tested in a short period of time to efficiently generate test data that meets the test requirements. For the testing of related tools provided by the database, such as the Data Transmission Service (DTS), the generated test data needs to cover a variety of field types, such as integer, floating point, string, date, etc., and it is necessary to ensure that the generated test data complies with business rules and has a certain degree of randomness.

[0004] However, when faced with large-scale data testing scenarios, manually generating test data by testers is time-consuming and laborious, resulting in low test data generation efficiency. Summary of the invention

[0005] Based on this, it is necessary to provide a test data generation method, device, equipment, storage medium and program product that can improve the test data generation efficiency in response to the above technical problems.

[0006] In a first aspect, the present application provides a method for generating test data, comprising:

[0007] receiving a request for generating test data;

[0008] Parsing the test data generation request to determine identification information of the target database to be tested and generation parameters of the test data;

[0009] Creating a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data;

[0010] Calling a data generation tool to generate random data corresponding to the target database;

[0011] Generate test data of the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database.

[0012] In one embodiment, generating test data of the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database includes:

[0013] Create a database table structure in the target database using the SQL statement corresponding to the target database;

[0014] The random data corresponding to the target database is written into the library table structure to generate test data of the target database.

[0015] In one of the embodiments, after writing the random data corresponding to the target database into the library table structure to generate the test data of the target database, the method further includes:

[0016] If the random data is successfully written into the database table structure, a prompt message is generated and displayed, where the prompt message is used to indicate that the test data of the target database is successfully generated.

[0017] In one embodiment, the calling of a data generation tool to generate random data corresponding to the target database includes:

[0018] Determining the data type of the target database according to the field requirement information of the target database;

[0019] The data generation tool is called, and random data corresponding to the data type of the target database is generated through a random number generation library in the data generation tool.

[0020] In one of the embodiments, before generating the test data of the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database, the method further includes:

[0021] A connection relationship is established with the target database through the connection mode of the target database encapsulated in the data interface.

[0022] In one of the embodiments, the generation parameters of the test data include at least one of the following: library table name, field type, and field name.

[0023] In a second aspect, the present application provides a device for generating test data, comprising:

[0024] A receiving module, used for receiving a request for generating test data;

[0025] A parsing module, used for parsing the request for generating the test data, and determining the identification information of the target database to be tested and the generation parameters of the test data;

[0026] A creation module, used to create a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data;

[0027] A calling module, used to call a data generation tool to generate random data corresponding to the target database;

[0028] A generating module is used to generate test data of the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database.

[0029] In one of the embodiments, the generation module is further used to create a library table structure in the target database through an SQL statement corresponding to the target database; and write random data corresponding to the target database into the library table structure to generate test data for the target database.

[0030] In one of the embodiments, the generation module is further used to generate and display prompt information if the random data is successfully written into the library table structure, wherein the prompt information is used to indicate that the test data of the target database is successfully generated.

[0031] In one of the embodiments, the calling module is further used to determine the data type of the target database based on the field requirement information of the target database; call the data generation tool, and generate random data corresponding to the data type of the target database through the random number generation library in the data generation tool.

[0032] In one of the embodiments, the generating module is further configured to establish a connection relationship with the target database through the connection mode of the target database encapsulated in the data interface.

[0033] In one of the embodiments, the generation parameters of the test data include at least one of the following: library table name, field type, and field name.

[0034] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the test data generation method of the first aspect when executing the computer program.

[0035] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for generating test data according to the first aspect described above is implemented.

[0036] In a fifth aspect, the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements the test data generation method of the first aspect described above.

[0037] The above-mentioned test data generation method, device, equipment, storage medium and program product first receive a test data generation request; secondly, parse the test data generation request to determine the identification information of the target database to be tested and the generation parameters of the test data; thirdly, create a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data, and call a data generation tool to generate random data corresponding to the target database; finally, generate test data for the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database. Since the structured query language SQL statement corresponding to the target database is created according to the identification information of the target database to be tested and the generation parameters of the test data, the tester can automatically generate the SQL statement without knowing the SQL syntax corresponding to the target database when generating the test data, and at the same time, call the data generation tool to generate the random data corresponding to the target database, which also realizes the automatic generation of random data, thereby realizing the one-click generation of test data, greatly improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0039] FIG1 is an application environment diagram of a method for generating test data provided in an embodiment of the present application;

[0040] Figure 2 A flow chart of a method for generating test data provided in an embodiment of the present application;

[0041] Figure 3 A schematic diagram of the principle of a method for generating test data provided in an embodiment of the present application;

[0042] Figure 4 A flowchart of another method for generating test data provided in an embodiment of the present application;

[0043] Figure 5 A structural block diagram of a test data generation device provided in an embodiment of the present application;

[0044] FIG6 is a diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0046] The test data generation method provided in the embodiment of the present application can be applied in the application environment shown in FIG1. ​​In which, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 includes a target database.

[0047] When test data needs to be generated, the terminal 102 first receives a request for generating test data, parses the request for generating test data, and determines the identification information of the target database to be tested and the generation parameters of the test data. Secondly, the terminal 102 creates a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data. Thirdly, the terminal 102 calls a data generation tool to generate random data corresponding to the target database. Finally, the terminal 102 generates test data for the target database in the server 104 according to the SQL statement corresponding to the target database and the random data corresponding to the target database.

[0048] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, portable wearable devices, etc. The server 104 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0049] Figure 2 A flow chart of a method for generating test data provided in an embodiment of the present application, Figure 3 A schematic diagram of the principle of a method for generating test data provided in an embodiment of the present application is provided, and the method is applied to a terminal as an example for explanation, such as Figure 2 and Figure 3 As shown, the method for generating the test data includes S201-S205:

[0050] S201: Receive a request for generating test data.

[0051] In the present application, when test data needs to be generated, the terminal may receive a request for generating the test data.

[0052] In some embodiments, the above-mentioned request for generating test data can be generated by the user through information selected or filled in a visual interface on the terminal. Exemplarily, a visual interface can be displayed on the terminal, and the user can select or fill in relevant information through the visual interface to customize the request for generating test data.

[0053] Exemplarily, the user can select the identification information of the target database (i.e., data source) to be tested according to actual needs through the visual interface. The target database to be tested may include databases such as MySQL, POSTGRESQL, and SQL Server. The user can also fill in the test data generation parameters such as the library table name, table field type, and field name through the visual interface. Subsequently, the terminal generates a test data generation request including the identification information of the target database and the test data generation parameters.

[0054] Exemplarily, the terminal can provide fields including more than 30 field types corresponding to the MySQL database and more than 25 field types corresponding to the POSTGRESQL database for users to select on the visual interface, and supports length definition for data types such as variable-length strings (varchar) and bits (bit), thereby supporting personalized customized test data generation requests to the greatest extent.

[0055] For example, Table 1 is a schematic diagram of selecting or filling in relevant information in a visual interface provided in an embodiment of the present application. As shown in Table 1, the user can select a data source in the visual interface and fill in test data generation parameters such as library name, table name, field information, and data volume, thereby generating a test data generation request containing the above information.

[0056] Table 1

[0057]

[0058] In an embodiment of the present application, the user inputs the identification information of the target database and the generation parameters of the test data through a visual interface, thereby constructing a test data generation request that meets the specific test scenario, achieving a highly personalized and customized test environment setting, and effectively lowering the threshold for database testing.

[0059] S202: Parse the request for generating test data, and determine the identification information of the target database to be tested and test data generation parameters.

[0060] In this step, after receiving the request for generating test data, the terminal may parse the request for generating test data to determine the identification information of the target database to be tested and the generation parameters of the test data.

[0061] The test data generation parameters include at least one of the following: library table name, field type, and field name.

[0062] It should be understood that the embodiments of the present application do not limit how to parse the test data generation request. In some embodiments, the terminal can use the Flask framework to parse the test data generation request to determine the identification information of the target database to be tested and the test data generation parameters.

[0063] Among them, the Flask framework is a lightweight framework with efficient information parsing and processing capabilities, thereby achieving efficient parsing of test data generation requests.

[0064] In some embodiments, after determining the identification information of the target database to be tested and the generation parameters of the test data, the terminal can also select the generation parameters corresponding to the target database from the generation parameters of the test data according to the identification information of the target database. Subsequently, the terminal can also perform format conversion on the generation parameters of the test data, organize the generation parameters such as the library table name, field type, and field name in a JavaScript Object Notation (JSON) format and pass them to the subsequent processing module to generate the corresponding table structure.

[0065] S203: Create a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data.

[0066] In this step, after the terminal parses the test data generation request and determines the identification information of the target database to be tested and the test data generation parameters, it can create an SQL statement corresponding to the target database according to the identification information of the target database and the test data generation parameters.

[0067] It should be understood that the embodiments of the present application do not limit how to create the SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data. In some embodiments, the terminal can first determine the SQL standard corresponding to the target database through the identification information of the target database. Then, based on the SQL standard corresponding to the target database, the corresponding standard SQL statement is obtained, and then the standard SQL statement is adjusted by the generation parameters of the test data, so as to obtain the SQL statement corresponding to the target database.

[0068] In the embodiments of the present application, SQL statements corresponding to the target database can be automatically created based on the identification information of the target database and the generation parameters of the test data. The SQL statements corresponding to the target database can be used to construct a library table structure that meets the requirements in the target database, which greatly simplifies the process of creating the database table structure and improves the efficiency of database initialization.

[0069] S204: Call a data generation tool to generate random data corresponding to the target database.

[0070] In this step, after the terminal creates a structured query language SQL statement corresponding to the target database, it can call a data generation tool to generate random data corresponding to the target database.

[0071] The random data may include normal data in the target database, or abnormal data in the target database.

[0072] The data generation tool may be a data generator (DataFaker) tool, which may include a random number generation library provided by a programming language (python), and the random number generation library may include a random library, an ime library, etc., to support the generation of a wide range of field types. In addition, the DataFaker tool may also encapsulate random generation methods for multiple data types.

[0073] In the embodiment of the present application, since the data generation tool includes various random number generation libraries and random generation methods of various data types, the diversity and rationality of the generated random data can be guaranteed. At the same time, abnormal data can also be generated as needed to test the fault tolerance and stability of the target database.

[0074] It should be understood that the embodiments of the present application do not limit how to call the data generation tool to generate random data corresponding to the target database. In some embodiments, the terminal can first determine the data type of the target database based on the field requirement information of the target database. Subsequently, the terminal calls the data generation tool and generates random data corresponding to the data type of the target database through the random number generation library in the data generation tool.

[0075] The above data types may include not only general data types such as integer (int), variable-length character string (varchar), and large integer (bigint) types, but also special data types such as one-dimensional object (linestring), multiple polygon (multipolygon), and geometry (geometry) types to meet the needs of different test scenarios.

[0076] The field requirement information is used to indicate the data types required by different fields in the target database.

[0077] Exemplarily, after determining the data type required by each field in the target database through the field requirement information of the target database, the above data generation tool can generate random data of the corresponding data type by encapsulating the random generation method of the corresponding type and using different random number generation libraries. Since the field requirement information of the target database is referenced when generating random data, legal random data that meets the requirements of the target database can be quickly generated, providing rich data resources for database testing.

[0078] S205: Generate test data for the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database.

[0079] In this step, after the terminal calls the data generation tool to generate random data corresponding to the target database, test data of the target database can be generated according to the SQL statement corresponding to the target database and the random data corresponding to the target database.

[0080] In some embodiments, the terminal may first create a library table structure in the target database using a SQL statement corresponding to the target database, and then write random data corresponding to the target database into the library table structure to generate test data for the target database.

[0081] Exemplarily, the terminal may connect to an interface of the target database, execute SQL statements corresponding to the target database in the target database, and create a library table structure.

[0082] The interface for connecting to the target database may encapsulate the target database connection method and the SQL execution method. Through the SQL execution method, the terminal may execute the SQL statement corresponding to the target database in the target database.

[0083] Exemplarily, the random data corresponding to the target database written into the library table structure can be optimized through batch insertion, transaction management, etc., to reduce delays and blockages in the data writing process.

[0084] In the embodiment of the present application, the performance optimization of database operations is fully considered. The library table structure is first created and then the random data corresponding to the target database is written into the library table structure, ensuring the high efficiency and stability of the data writing process.

[0085] In other embodiments, before generating test data of the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database, the terminal may also establish a connection relationship with the target database through the connection method of the target database encapsulated in the data interface.

[0086] Among them, the encapsulated target database connection mode and SQL execution method can provide terminal calls in the form of a unified interface, ensuring the decoupling between various functional modules of the data testing system and the scalability of the system.

[0087] In the embodiment of the present application, by encapsulating the interface of the connection method of the target database, a series of automatic operations on the target database can be supported without manually executing SQL, which effectively reduces the manpower cost of testing.

[0088] In some embodiments, if the random data is successfully written into the library table structure, the terminal generates and displays a prompt message, where the prompt message is used to indicate that the test data of the target database is successfully generated.

[0089] In an embodiment of the present application, after the random data is written successfully, the tester will receive a prompt message on the visual interface that the test data has been successfully generated, thereby ensuring that the tester can obtain feedback in a timely manner and perform subsequent testing work.

[0090] The test data generation method provided in the embodiment of the present application first receives a test data generation request; secondly, parses the test data generation request to determine the identification information of the target database to be tested and the generation parameters of the test data; thirdly, creates a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data, and calls a data generation tool to generate random data corresponding to the target database; finally, generates test data for the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database. Since the structured query language SQL statement corresponding to the target database is created according to the identification information of the target database to be tested and the generation parameters of the test data, the tester can automatically generate the SQL statement without knowing the SQL syntax corresponding to the target database when generating the test data, and at the same time, calls the data generation tool to generate the random data corresponding to the target database, which also realizes the automatic generation of random data, thereby realizing the one-click generation of test data, greatly improving the test efficiency.

[0091] The following describes how to generate test data for the target database. Figure 4 A flow chart of another method for generating test data provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the method for generating the test data includes S301-S308:

[0092] S301: Receive a request for generating test data.

[0093] In some embodiments, the above-mentioned test data generation request can be generated by the user through the information selected or input in the visual interface on the terminal. Exemplarily, the terminal can display the visual interface, and the user can select or fill in the relevant information through the visual interface to customize the test data generation request.

[0094] S302: Parse the request for generating test data, and determine the identification information of the target database to be tested and test data generation parameters.

[0095] The test data generation parameters include at least one of the following: library table name, field type, and field name.

[0096] S303: Create a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data.

[0097] In some embodiments, the terminal may first determine the SQL standard corresponding to the target database through the identification information of the target database, then obtain the corresponding standard SQL statement based on the SQL standard corresponding to the target database, and then adjust the standard SQL statement through the generation parameters of the test data to obtain the SQL statement corresponding to the target database.

[0098] S304: Call a data generation tool to generate random data corresponding to the target database.

[0099] The data generation tool may be a data generator (DataFaker) tool, which may include a random number generation library provided by a programming language (python), and the random number generation library may include a random library, an ime library, etc., to support the generation of a wide range of field types. In addition, the DataFaker tool may also encapsulate random generation methods for multiple data types.

[0100] In some embodiments, the terminal may first determine the data type of the target database according to the field requirement information of the target database, and then call the data generation tool and generate random data corresponding to the data type of the target database through the random number generation library in the data generation tool.

[0101] S305: Establish a connection relationship with the target database through the connection method of the target database encapsulated in the data interface.

[0102] S306: Create a library table structure in the target database using the SQL statement corresponding to the target database.

[0103] S307: Write random data corresponding to the target database into the library table structure to generate test data for the target database.

[0104] S308. If the random data is successfully written into the library table structure, a prompt message is generated and displayed, and the prompt message is used to indicate that the test data of the target database is successfully generated.

[0105] The test data generation method provided in the embodiment of the present application first receives a test data generation request; secondly, parses the test data generation request to determine the identification information of the target database to be tested and the generation parameters of the test data; thirdly, creates a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data, and calls a data generation tool to generate random data corresponding to the target database; finally, generates test data for the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database. Since the structured query language SQL statement corresponding to the target database is created according to the identification information of the target database to be tested and the generation parameters of the test data, the tester can automatically generate the SQL statement without knowing the SQL syntax corresponding to the target database when generating the test data, and at the same time, calls the data generation tool to generate the random data corresponding to the target database, which also realizes the automatic generation of random data, thereby realizing the one-click generation of test data, greatly improving the test efficiency.

[0106] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0107] Based on the same inventive concept, the embodiment of the present application also provides a test data generation device for implementing the test data generation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more test data generation device embodiments provided below can refer to the limitations of the test data generation method above, and will not be repeated here.

[0108] In an exemplary embodiment, Figure 5As shown, a test data generating device 400 is provided, comprising: a receiving module 401, a parsing module 402, a creating module 403, a calling module 404 and a generating module 405, wherein:

[0109] The receiving module 401 is used to receive a request for generating test data.

[0110] The parsing module 402 is used to parse the request for generating test data and determine the identification information of the target database to be tested and the generation parameters of the test data.

[0111] The creation module 403 is used to create a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data.

[0112] The calling module 404 is used to call a data generation tool to generate random data corresponding to the target database.

[0113] The generating module 405 is used to generate the test data of the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database.

[0114] In one embodiment, the generating module 405 is further used to create a library table structure in the target database through an SQL statement corresponding to the target database; and write random data corresponding to the target database into the library table structure to generate test data for the target database.

[0115] In one embodiment, the generating module 405 is further used to generate and display a prompt message if the random data is successfully written into the library table structure, and the prompt message is used to indicate that the test data of the target database is successfully generated.

[0116] In one embodiment, the calling module 404 is further used to determine the data type of the target database according to the field requirement information of the target database; call the data generation tool, and generate random data corresponding to the data type of the target database through the random number generation library in the data generation tool.

[0117] In one embodiment, the generating module 405 is further configured to establish a connection relationship with the target database through the connection mode of the target database encapsulated in the data interface.

[0118] In one of the embodiments, the generation parameters of the test data include at least one of the following: library table name, field type, and field name.

[0119] Each module in the above-mentioned test data generation device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0120] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a method for generating test data is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

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

[0122] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above-mentioned test data generation method when executing the computer program.

[0123] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned test data generation method is implemented.

[0124] In one embodiment, a computer program product is provided, including a computer program, which implements the above-mentioned test data generation method when executed by a processor.

[0125] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0126] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0127] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

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

Claims

1. A method for generating test data, characterized in that: The method comprises: receiving a request for generating test data; Parsing the test data generation request to determine identification information of the target database to be tested and generation parameters of the test data; Creating a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data; Calling a data generation tool to generate random data corresponding to the target database; Generate test data of the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database.

2. The method according to claim 1, characterized in that The step of generating test data for the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database includes: Create a database table structure in the target database using the SQL statement corresponding to the target database; Random data corresponding to the target database is written into the library table structure to generate test data for the target database.

3. The method according to claim 2, characterized in that After writing random data corresponding to the target database into the library table structure to generate test data of the target database, the method further includes: If the random data is successfully written into the database table structure, a prompt message is generated and displayed, where the prompt message is used to indicate that the test data of the target database is successfully generated.

4. The method according to claim 1, characterized in that: The calling of the data generation tool to generate random data corresponding to the target database includes: Determining the data type of the target database according to the field requirement information of the target database; The data generation tool is called, and random data corresponding to the data type of the target database is generated through a random number generation library in the data generation tool.

5. The method according to claim 1, characterized in that Before generating the test data of the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database, the method further includes: A connection relationship is established with the target database through the connection mode of the target database encapsulated in the data interface.

6. The method according to any one of claims 1 to 5, characterized in that: The generation parameters of the test data include at least one of the following: library table name, field type, and field name.

7. A test data generating device, characterized in that: The device comprises: A receiving module, used for receiving a request for generating test data; A parsing module, used for parsing the request for generating the test data, and determining the identification information of the target database to be tested and the generation parameters of the test data; A creation module, used to create a structured query language SQL statement corresponding to the target database according to the identification information of the target database and the generation parameters of the test data; A calling module, used to call a data generation tool to generate random data corresponding to the target database; A generating module is used to generate test data of the target database according to the SQL statement corresponding to the target database and the random data corresponding to the target database.

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

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

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Test data automatic generation method, apparatus and device based on table building statement

    CN109117377A

  • Database testing method and device, equipment and storage medium

    CN115269345A

  • Method and device for manufacturing test data, medium and database

    CN116560994A

  • Data testing method and device, equipment and storage medium

    CN118331839A

  • Integrated testing tool for data replication

    US11567743B1