Data generation method and device, terminal equipment and computer readable storage medium

The data generation method addresses the issue of limited sample data by generating and combining random data based on algorithm models and system attributes, enhancing test data volume and reliability, and improving software testing accuracy.

CN119226124APending Publication Date: 2024-12-31CONTEMPORARY AMPEREX FUTURE ENERGY RES INST (SHANGHAI) LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310789677.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-29
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

The accuracy and reliability of software test results are low due to the limited amount of existing sample data available for testing, which does not meet the volume requirements.

Method used

A data generation method that involves obtaining first data fields corresponding to a test task, generating random data for these fields, and combining them to create multiple groups of test data, using algorithm models and data definition documents to ensure data relevance and validity, and incorporating sample data from the target system.

Benefits of technology

This method expands the volume of test data, ensuring accuracy and reliability by generating targeted and valid test data that reflects the operating status of the system, reducing labor costs and improving test efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226124A_ABST
    Figure CN119226124A_ABST
Patent Text Reader

Abstract

The invention relates to the field of data processing, in particular to a data generation method and device, terminal equipment and a computer readable storage device. The data generation method comprises the steps of obtaining a first data field corresponding to a test task; generating a plurality of random data of each first data field; and performing data combination according to the multiple pieces of random data of each first data field to obtain multiple groups of test data corresponding to the test task. By means of the method, the test data of a certain data size can be obtained, and therefore the accuracy and reliability of the test result are guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a data generation method, device, terminal equipment and computer-readable storage device. Background Art

[0002] With the advent of the big data era, business platforms are increasingly dependent on data. In the process of software testing on business platforms, a large amount of test data is usually required to ensure the accuracy and reliability of the test results.

[0003] At present, the test data required for software testing usually relies on existing sample data. In practical applications, the amount of existing sample data is limited and cannot meet the data volume requirements of software testing, resulting in low accuracy and reliability of test results. Summary of the invention

[0004] The present application provides a data generation method, apparatus, terminal device and computer-readable storage device, which solve the problem in the prior art that the accuracy and reliability of test results are low due to limited sample data.

[0005] In order to achieve the above objectives, this application adopts the following technical solutions:

[0006] In a first aspect, a data generation method is provided, comprising:

[0007] Obtaining a first data field corresponding to the test task;

[0008] generating a plurality of random data for each of the first data fields;

[0009] Data combination is performed according to the multiple random data in each of the first data fields to obtain multiple groups of test data corresponding to the test task.

[0010] In the embodiment of the present application, multiple random data can be generated for each first data field corresponding to the test task, thereby expanding the test data; then, data combination is performed based on the multiple random data of each first data field, further increasing the amount of test data. In the above manner, a certain amount of test data can be obtained, thereby ensuring the accuracy and reliability of the test results.

[0011] In an implementation of the first aspect, obtaining a first data field corresponding to the test task includes:

[0012] Obtaining an algorithm model corresponding to the test task;

[0013] The first data field corresponding to the test task is determined according to the algorithm model.

[0014] Since different test tasks may involve different data fields, determining the first data field corresponding to the test task according to the algorithm model corresponding to the test task can avoid taking into account some data fields irrelevant to the test task, which is more targeted and ensures the accuracy and reliability of the test results.

[0015] In an implementation of the first aspect, determining the first data field corresponding to the test task according to the algorithm model includes:

[0016] Identifying variable parameters included in the algorithm model;

[0017] The first data field corresponding to the test task is determined according to the variable parameter.

[0018] Usually, the variable parameters of the algorithm model are the key factors that affect the algorithm execution results. Therefore, in the embodiment of the present application, it is equivalent to determining the first data field corresponding to the test task according to the key factors that affect the algorithm execution results of the test task. In this way, it is possible to avoid taking into account some data fields that are irrelevant to the test task or some data fields that have a weaker impact on the test results, which is more targeted, thereby ensuring the accuracy and reliability of the test results.

[0019] In an implementation manner of the first aspect, generating a plurality of random data for each of the first data fields includes:

[0020] Obtaining data attributes of each of the first data fields;

[0021] A plurality of random data of each of the first data fields is generated according to a data attribute of each of the first data fields.

[0022] In the embodiment of the present application, the multiple random data of each first data field are generated according to the data attribute of the first field. In other words, the generated random data conforms to the data attribute of the first data field. In this way, the validity of the expanded test data can be guaranteed, thereby ensuring the accuracy and reliability of the test results.

[0023] In an implementation of the first aspect, obtaining a data attribute of each of the first data fields includes:

[0024] Obtaining a data definition document of a target system corresponding to the test task, wherein the data definition document includes data attributes of each data field in the target system;

[0025] The data attribute of each of the first data fields is found from the data definition document.

[0026] Usually, a data definition document is generated during the system development process, and the data definition document defines the data attributes of each data field involved in the system development process. Therefore, the data attributes included in the data definition document are relatively accurate and comprehensive. It is convenient to search for the data attributes of each first data field corresponding to the test task through the data definition document, which is conducive to improving efficiency; and the data attributes found are also relatively accurate, thereby ensuring the validity of the random data generated subsequently.

[0027] In an implementation of the first aspect, the data attribute includes a value range;

[0028] Generating a plurality of random data of each first data field according to the data attribute of each first data field comprises:

[0029] A plurality of random data of each of the first data fields is generated within a value range of each of the first data fields.

[0030] In the embodiment of the present application, by limiting the value range of the first data field, the validity of the generated random data can be guaranteed. In other words, it can be guaranteed that the generated random data is valid when substituted into the algorithm model, thereby ensuring the reliability of the test result.

[0031] In an implementation of the first aspect, the data attribute further includes a data type;

[0032] Generating a plurality of random data of each first data field within a value range of each first data field includes:

[0033] For each of the first data fields, a plurality of random data conforming to the data type of the first data field are generated within the value range of the first data field.

[0034] During the program development process, each first data field has its corresponding data type, such as integer, floating point, and string, etc. Generating random data according to the data type of the first data field can ensure the validity of the generated random data. In other words, substituting the generated random data into the algorithm model later can avoid the situation where the algorithm cannot be executed due to data type errors, thereby ensuring the reliability of the test.

[0035] In an implementation of the first aspect, combining data according to the multiple random data of each of the first data fields to obtain multiple groups of test data corresponding to the test task includes:

[0036] Acquire at least one test sample corresponding to the test task, each of the test samples including sample data of the first data field and sample data of a second data field, wherein the second data field is a data field other than the first data field in the target system corresponding to the test task;

[0037] Data combination is performed based on the sample data of the second data field in at least one of the test samples and the multiple random data in each of the first data fields to obtain multiple groups of the test data corresponding to the test task.

[0038] In practical applications, each test task may be targeted at a function of the target system, and the target system usually involves multiple functions. In the embodiment of the present application, in the process of generating test data, not only the first data field related to the test task is considered, but also the second data field in the target system except the first data field is considered. In this way, the generated test data can more truly reflect the operating status of the target system, which is conducive to improving the accuracy of the test results.

[0039] In an implementation of the first aspect, combining data according to sample data of the second data field in at least one of the test samples and a plurality of random data of each of the first data fields to obtain a plurality of groups of the test data corresponding to the test task includes:

[0040] Arrange and combine multiple random data of each of all first data fields corresponding to the test task to obtain multiple groups of data sequences, wherein each group of data sequences includes one random data of each of all first data fields corresponding to the test task;

[0041] Each of the test samples is combined with multiple groups of the data sequences to obtain multiple groups of the test data corresponding to each of the test samples.

[0042] In the embodiment of the present application, in the process of generating test data, not only the first data field related to the test task is considered, but also the second data field in the target system other than the first data field is considered. In this way, the generated test data can more truly reflect the operating status of the target system, which is conducive to improving the accuracy of the test results. In addition, by combining the random data of the randomly generated first data field with the sample data of the second data field in the test sample, the data volume of the test data is further increased, thereby ensuring the accuracy and reliability of the test results.

[0043] In an implementation of the first aspect, the method further includes:

[0044] A data file in a preset format is generated according to the multiple groups of test data corresponding to the test task, and the data file is used to provide test data for the test task, wherein the preset format is a plain text format.

[0045] Files in plain text format are easy to read and modify. By generating data files in plain text format from multiple sets of test data, subsequent developers can modify and view them easily, which helps improve user experience.

[0046] In an implementation of the first aspect, the method further includes:

[0047] Obtaining the data file corresponding to the test task;

[0048] Parsing the data file corresponding to the test task to obtain multiple groups of test data corresponding to the test task;

[0049] The test task is executed according to the multiple groups of test data corresponding to the test task.

[0050] In the embodiment of the present application, the terminal device automatically parses the data file to obtain multiple groups of test data corresponding to the test task, and then executes the test task according to the test data, thereby realizing intelligent testing, reducing labor costs, and improving test efficiency.

[0051] In a second aspect, a data generating device is provided, comprising:

[0052] An acquisition unit, used for acquiring a first data field corresponding to the test task;

[0053] A generating unit, configured to generate a plurality of random data for each of the first data fields;

[0054] A combining unit is used to perform data combination according to multiple random data in each of the first data fields to obtain multiple groups of test data corresponding to the test task.

[0055] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the data generation method as described in any one of the first aspects above is implemented.

[0056] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data generation method as described in any one of the above-mentioned first aspects is implemented.

[0057] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the data generation method described in any one of the above-mentioned first aspects.

[0058] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.

[0059] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Moreover, the same reference numerals are used throughout the drawings to represent the same components. In the drawings:

[0061] Figure 1 It is a flowchart of a data generation method provided in an embodiment of the present application;

[0062] Figure 2 It is a flowchart of a random data generation method provided in an embodiment of the present application;

[0063] Figure 3 It is a flowchart of the data combination method provided in the embodiment of the present application;

[0064] Figure 4 It is a flow chart of the testing method provided in the embodiment of the present application;

[0065] Figure 5 is a structural block diagram of a data generating device provided in an embodiment of the present application;

[0066] Figure 6 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0067] The following embodiments of the technical solution of the present application are described in detail in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application, and are therefore only used as examples, and cannot be used to limit the scope of protection of the present application.

[0068] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned figure descriptions and any variations thereof are intended to cover non-exclusive inclusions.

[0069] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.

[0070] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0071] In the description of the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0072] In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).

[0073] With the advent of the big data era, business platforms are increasingly dependent on data. In the process of software testing on business platforms, a large amount of test data is usually required to ensure the accuracy and reliability of the test results.

[0074] At present, the test data required for software testing usually relies on existing sample data. In practical applications, the amount of existing sample data is limited and cannot meet the data volume requirements of software testing, resulting in low accuracy and reliability of test results.

[0075] In order to solve the above problems, the present application provides a data generation method. Through the data generation method provided in the present application, multiple groups of test data can be automatically generated, effectively solving the problem of low accuracy and reliability of test results due to limited sample data.

[0076] See also Figure 1 , is a flow chart of the data generation method provided in the embodiment of the present application. As an example and not a limitation, Figure 1 As shown, the data generation method may include the following steps:

[0077] S101, obtaining a first data field corresponding to a test task.

[0078] In the embodiment of the present application, the test task may be a test of one or more functions of the target system, wherein the target system refers to a software system. Accordingly, the test task involved in the embodiment of the present application refers to software testing.

[0079] In some application scenarios, the target system may be a vehicle control system. The vehicle control system can realize vehicle body control (such as parking, shifting, steering, etc.) and vehicle battery management (such as monitoring battery health status, battery charging and discharging, etc.). In other application scenarios, the target system may be a business system. Among them, the business system refers to a system developed according to the user's business needs.

[0080] The first data field corresponding to the test task refers to data items related to the function corresponding to the test task, and these data items are embodied in the form of data fields in the software code.

[0081] In actual applications, after the test task is determined, the first data field corresponding to the test task can be obtained by parsing the software code of the target system.

[0082] For example, for a vehicle control system, if the test task is to test the function of monitoring the health status of the battery, the data items related to the health status of the battery include the state of charge, battery level, battery current and time, then the first data field corresponding to the test task includes the data fields corresponding to the state of charge, battery current, battery level and time in the software code.

[0083] For another example, for a vehicle control system, if the test task is to test the abnormal trend function of monitoring the DC internal resistance of a battery, the data items related to the DC internal resistance of the battery include the DC internal resistance of the battery cell, the output voltage of the battery, the open circuit voltage and the battery current, then the first data field corresponding to the test task includes the data fields corresponding to the DC internal resistance of the battery cell, the output voltage of the battery, the open circuit voltage and the battery current in the software code.

[0084] In some embodiments, each function of the software system corresponds to a set of algorithm models.

[0085] Accordingly, S101 may include:

[0086] Acquire an algorithm model corresponding to the test task; and determine the first data field corresponding to the test task according to the algorithm model.

[0087] Since different test tasks may involve different data fields, determining the first data field corresponding to the test task according to the algorithm model corresponding to the test task can avoid taking into account some data fields irrelevant to the test task, which is more targeted and ensures the accuracy and reliability of the test results.

[0088] In one implementation, determining the first data field corresponding to the test task according to the algorithm model includes:

[0089] Identify variable parameters included in the algorithm model; and determine the first data field corresponding to the test task according to the variable parameters.

[0090] For example, in the above-mentioned test task for monitoring the health status of the battery, the algorithm model involved in the health status of the battery is SOC(t)=SOC_0+Idt / Q, where SOC(t) represents the state of charge at the tth moment, SOC_0 represents the initial state of charge, I represents the battery current, dt represents the time interval, and Q represents the battery capacity. It is identified that the variable parameters in the algorithm model include the state of charge, battery current, time, and battery capacity, and the data fields corresponding to the state of charge, battery current, time, and battery capacity in the software code are determined as the first data field.

[0091] For another example, in the test task of monitoring the trend abnormality function of the DC internal resistance of the battery, the algorithm model of the trend abnormality algorithm of the DC internal resistance is U=OCV+I×DCR, where U represents the output voltage, OCV represents the open circuit voltage, I represents the battery current, and DCR represents the DC internal resistance. It is identified that the variable parameters in the algorithm model include the output voltage, the open circuit voltage, the battery current, and the DC internal resistance, and the data fields corresponding to the output voltage, the open circuit voltage, the battery current, and the DC internal resistance in the software code are determined as the first data field.

[0092] Usually, the variable parameters of the algorithm model are the key factors that affect the algorithm execution results. Therefore, in the embodiment of the present application, it is equivalent to determining the first data field corresponding to the test task according to the key factors that affect the algorithm execution results of the test task. In this way, it is possible to avoid taking into account some data fields that are irrelevant to the test task or some data fields that have a weaker impact on the test results, which is more targeted, thereby ensuring the accuracy and reliability of the test results.

[0093] It is understandable that the algorithm model may include variable parameters and constant parameters. In other implementations, the first data field may also be determined based on the variable parameters and constant parameters in the algorithm model. Since the value of the constant parameter is fixed, this method will not improve the accuracy of the test result compared to the method of determining the first data field based only on the variable parameters, but will increase the number of the first data field and reduce the efficiency of data generation.

[0094] S102: Generate a plurality of random data for each of the first data fields.

[0095] In some implementations, a random data generation algorithm may be used to generate random data. For example, functions corresponding to commonly used random data generation algorithms include rand function, randbetween function, and randarray function.

[0096] In actual applications, the following problems may exist: the generated random data does not meet the data attributes of the first data field in the algorithm model, resulting in the inability to substitute the random data into the algorithm model, thus causing the test to fail.

[0097] In order to solve the above problems, in some embodiments, see Figure 2 , is a flow chart of the random data generation method provided in the embodiment of the present application. As an example and not a limitation, Figure 2 As shown, S102 may include:

[0098] S201: Obtain data attributes of each of the first data fields.

[0099] In the embodiment of the present application, data attributes may include data types and value ranges, etc. Among them, data types may include integer, floating point, string, and timestamp, etc.

[0100] In one implementation, S201 includes: obtaining a data definition document of a target system corresponding to the test task, wherein the data definition document includes data attributes of each data field in the target system; and finding out the data attributes of each of the first data fields from the data definition document.

[0101] In some application scenarios, the data definition document may be stored in a database of the target system. The processor of the target system obtains the data definition document from the database, then searches for the first data field in the data definition document, and then obtains the data attribute corresponding to the first data field. Exemplarily, the data definition document may be stored in the form of a data matrix or in the form of a text document, such as an Excel table.

[0102] Usually, a data definition document is generated during the system development process, and the data definition document defines the data attributes of each data field involved in the system development process. Therefore, the data attributes included in the data definition document are relatively accurate and comprehensive. It is convenient to search for the data attributes of each first data field corresponding to the test task through the data definition document, which is conducive to improving efficiency; and the data attributes found are also relatively accurate, thereby ensuring the validity of the random data generated subsequently.

[0103] S202: Generate a plurality of random data for each of the first data fields according to data attributes of each of the first data fields.

[0104] In the case where the data attribute includes a value range, an implementation of S202 includes:

[0105] A plurality of random data of each of the first data fields is generated within a value range of each of the first data fields.

[0106] For example, in the above test task for monitoring the health status of the battery, the value range of SOC is 0 to 1, and the function rand can be used to generate multiple random data, where the rand function is used to generate random integers between 0 and 1. The value range of battery current is 0 to 5, and the function randbetween(min, max) can be used, where min represents the minimum value of the value range and max represents the maximum value of the value range.

[0107] For another example, for time, there is no clear range of values, and random data of time can be generated in an incrementing manner according to a preset time interval.

[0108] In the embodiment of the present application, by limiting the value range of the first data field, the validity of the generated random data can be guaranteed. In other words, it can be guaranteed that the generated random data is valid when substituted into the algorithm model, thereby ensuring the reliability of the test result.

[0109] In the case where the data attribute includes a data type and a value range, another implementation of S202 includes:

[0110] For each of the first data fields, a plurality of random data conforming to the data type of the first data field are generated within the value range of the first data field.

[0111] During program development, each first data field has its corresponding data type, such as integer, floating point, and string, etc.

[0112] For example, in the above test task for monitoring the health status of the battery, the data type of SOC is floating point type, and accordingly, multiple floating point random data between 0 and 1 are generated. The data type of battery power is integer type, and the value range is 0 to 200, and accordingly, multiple random integers between 0 and 200 are generated.

[0113] In the embodiment of the present application, the random data is generated according to the data type of the first data field, which can ensure the validity of the generated random data. In other words, the generated random data is subsequently substituted into the algorithm model to avoid the situation where the algorithm cannot be executed due to data type errors, thereby ensuring the reliability of the test.

[0114] It can be understood that the data attributes in the embodiments of the present application include but are not limited to data types and value ranges, and may also include other data attributes.

[0115] Figure 2 In the embodiment, the multiple random data of each first data field are generated according to the data attribute of the first field, in other words, the generated random data conforms to the data attribute of the first data field. In this way, the validity of the expanded test data can be guaranteed, thereby ensuring the accuracy and reliability of the test results.

[0116] S103, combining data according to the multiple random data in each of the first data fields to obtain multiple groups of test data corresponding to the test task.

[0117] Before the target system goes online, it may not be possible to obtain actual test samples; after the target system goes online, it is difficult to obtain sufficient test samples due to the user's protection of key data. Through the method in the embodiment of the present application, multiple random data can be generated for each first data field corresponding to the test task, thereby expanding the test data; then, by combining the multiple random data of each first data field, the amount of test data is further increased. In the above manner, a certain amount of test data can be obtained, thereby ensuring the accuracy and reliability of the test results.

[0118] In some embodiments, see Figure 3 , is a flow chart of the data combination method provided in the embodiment of the present application. As an example and not a limitation, Figure 3 As shown, S103 may include:

[0119] S301: Obtain at least one test sample corresponding to the test task.

[0120] In the embodiment of the present application, the test sample may be actual data generated during the actual application of the target system.

[0121] Each of the test samples includes sample data of the first data field and sample data of the second data field, wherein the second data field is a data field other than the first data field in the target system corresponding to the test task.

[0122] S302, combining data according to sample data of the second data field in at least one of the test samples and a plurality of random data in each of the first data fields to obtain a plurality of groups of the test data corresponding to the test task.

[0123] In some implementations, the sample data of the second data field in the test sample can be randomly combined with multiple random data of the first data field. For example, the first data field includes battery power and battery current, the battery power includes 100 random data, and the battery current includes 10 random data; the second data field includes DC internal resistance, and the DC internal resistance includes 5 sample data. The 100 battery power data, 10 battery current data, and 5 DC internal resistance sample data are randomly combined.

[0124] In this way, on the one hand, random combinations may not generate sufficient test data, and on the other hand, there may be duplicate data in the generated test data.

[0125] In order to solve the above problem, in one implementation method, S302 includes: arranging and combining multiple random data of each of all the first data fields corresponding to the test task to obtain multiple groups of data sequences, wherein each group of data sequences includes one random data of each of all the first data fields corresponding to the test task; and combining each of the test samples with the multiple groups of data sequences to obtain multiple groups of test data corresponding to each of the test samples.

[0126] Continuing with the above example, firstly, the data of 100 battery power and the data of 10 battery current are arranged and combined to obtain 100×10 groups of data sequences, and then the sample data of 5 DC internal resistances are respectively combined with the 100×10 groups of data sequences to obtain 5×100×10 groups of test data.

[0127] In the embodiment of the present application, in the process of generating test data, not only the first data field related to the test task is considered, but also the second data field in the target system other than the first data field is considered. In this way, the generated test data can more truly reflect the operating status of the target system, which is conducive to improving the accuracy of the test results. In addition, by combining the random data of the randomly generated first data field with the sample data of the second data field in the test sample, the data volume of the test data is further increased, thereby ensuring the accuracy and reliability of the test results.

[0128] In practical applications, each test task may target a function of the target system, while the target system usually involves multiple functions. Figure 3 In the embodiment, in the process of generating test data, not only the first data field related to the test task is considered, but also the second data field in the target system other than the first data field is considered. In this way, the generated test data can more truly reflect the operating status of the target system, which is conducive to improving the accuracy of the test results.

[0129] As mentioned above, Figure 1 In the embodiment, multiple random data can be generated for each first data field corresponding to the test task, thereby expanding the test data; then, data combination is performed based on the multiple random data of each first data field, further increasing the amount of test data. In the above manner, a certain amount of test data can be obtained, thereby ensuring the accuracy and reliability of the test results.

[0130] In some embodiments, the method further comprises:

[0131] A data file in a preset format is generated according to the multiple groups of test data corresponding to the test task, and the data file is used to provide test data for the test task, wherein the preset format is a plain text format.

[0132] For example, the preset format may be a comma-separated values ​​(CSV) format, a txt format, a hypertext markup language (Hyper Text Mark-up Language, HTM) format, or the like.

[0133] Files in plain text format are easy to read and modify. By generating data files in plain text format from multiple sets of test data, subsequent developers can modify and view them easily, which helps improve user experience.

[0134] In some embodiments, see Figure 4 , is a flow chart of the test method provided in the embodiment of the present application. As an example and not a limitation, Figure 4 As shown, the test method includes:

[0135] S401, obtaining a data file corresponding to the test task.

[0136] S402, parsing the data file corresponding to the test task to obtain multiple groups of test data corresponding to the test task.

[0137] S403: Execute the test task according to the multiple groups of test data corresponding to the test task.

[0138] In some application scenarios, the processor of the target system is based on Figure 1 The method in the embodiment generates test data, generates a data file based on the test data, and stores the data file in a database (which can be a storage space of the target system or a third-party storage space). During the test, the processor of the target system obtains the data file from the database, parses the data file, obtains the test data, and then executes the test task based on the test data.

[0139] In other application scenarios, third-party processors (such as cloud servers, etc.) Figure 1 The method in the embodiment generates test data, generates a data file based on the test data, and stores the data file in the cloud. During the test, the processor of the target system obtains the data file from the cloud, parses the data file, obtains the test data, and then executes the test task according to the test data. For example, the cloud may store data files corresponding to each test task of the target system. When the processor of the target system needs to execute test task A, it sends a request to the third-party server; the third-party server obtains the data file corresponding to test task A from the cloud according to the request and sends it to the processor of the target system.

[0140] In the embodiment of the present application, the terminal device automatically parses the data file to obtain multiple groups of test data corresponding to the test task, and then executes the test task according to the test data, thereby realizing intelligent testing, reducing labor costs, and improving test efficiency.

[0141] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0142] Corresponding to the data generation method described in the above embodiment, Figure 5 This is a structural block diagram of a data generating device provided in an embodiment of the present application. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0143] Reference Figure 5 , the device 5 comprises:

[0144] The acquisition unit 51 is used to acquire a first data field corresponding to the test task.

[0145] The generating unit 52 is configured to generate a plurality of random data for each of the first data fields.

[0146] The combining unit 53 is used to perform data combination according to the multiple random data in each of the first data fields to obtain multiple groups of test data corresponding to the test task.

[0147] Optionally, the acquiring unit 51 is further configured to:

[0148] Obtaining an algorithm model corresponding to the test task;

[0149] The first data field corresponding to the test task is determined according to the algorithm model.

[0150] Optionally, the acquiring unit 51 is further configured to:

[0151] Identifying variable parameters included in the algorithm model;

[0152] The first data field corresponding to the test task is determined according to the variable parameter.

[0153] Optionally, the generating unit 52 is further configured to:

[0154] Obtaining data attributes of each of the first data fields;

[0155] A plurality of random data of each of the first data fields is generated according to a data attribute of each of the first data fields.

[0156] Optionally, the generating unit 52 is further configured to:

[0157] Obtaining a data definition document of a target system corresponding to the test task, wherein the data definition document includes data attributes of each data field in the target system;

[0158] The data attribute of each of the first data fields is found from the data definition document.

[0159] Optionally, the data attribute includes a value range.

[0160] Accordingly, the generating unit 52 is further used for:

[0161] A plurality of random data of each of the first data fields is generated within a value range of each of the first data fields.

[0162] Optionally, the data attribute includes a data type.

[0163] Accordingly, the generating unit 52 is further used for:

[0164] For each of the first data fields, a plurality of random data conforming to the data type of the first data field are generated within the value range of the first data field.

[0165] Optionally, the combination unit 53 is further used for:

[0166] Acquire at least one test sample corresponding to the test task, each of the test samples including sample data of the first data field and sample data of a second data field, wherein the second data field is a data field other than the first data field in the target system corresponding to the test task;

[0167] Data combination is performed based on the sample data of the second data field in at least one of the test samples and the multiple random data in each of the first data fields to obtain multiple groups of the test data corresponding to the test task.

[0168] Optionally, the combination unit 53 is further used for:

[0169] The step of combining the sample data of the second data field in at least one of the test samples and the multiple random data of each of the first data fields to obtain multiple groups of the test data corresponding to the test task includes:

[0170] Arrange and combine multiple random data of each of all first data fields corresponding to the test task to obtain multiple groups of data sequences, wherein each group of data sequences includes one random data of each of all first data fields corresponding to the test task;

[0171] Each of the test samples is combined with multiple groups of the data sequences to obtain multiple groups of the test data corresponding to each of the test samples.

[0172] Optionally, the combination unit 53 is further used for:

[0173] A data file in a preset format is generated according to the multiple groups of test data corresponding to the test task, and the data file is used to provide test data for the test task, wherein the preset format is a plain text format.

[0174] Optionally, the device 5 further comprises:

[0175] The testing unit 54 is used to obtain the data file corresponding to the testing task;

[0176] Parsing the data file corresponding to the test task to obtain multiple groups of test data corresponding to the test task;

[0177] The test task is executed according to the multiple groups of test data corresponding to the test task.

[0178] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0179] in addition, Figure 5 The data generating device shown may be a software unit, a hardware unit, or a combination of software and hardware units built into an existing terminal device, or may be integrated into the terminal device as an independent accessory, or may exist as an independent terminal device.

[0180] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0181] Figure 6 Schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Figure 6 As shown, the terminal device 6 of this embodiment includes: at least one processor 60 ( Figure 6 Only one is shown in the figure) a processor, a memory 61, and a computer program 62 stored in the memory 61 and executable on the at least one processor 60, wherein the processor 60 implements the steps in any of the above-mentioned data generation method embodiments when executing the computer program 62.

[0182] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 6 It is only an example of the terminal device 6 and does not constitute a limitation on the terminal device 6. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.

[0183] The processor 60 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0184] In some embodiments, the memory 61 may be an internal storage unit of the terminal device 6, such as a hard disk or memory of the terminal device 6. In other embodiments, the memory 61 may also be an external storage device of the terminal device 6, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 6. Further, the memory 61 may also include both an internal storage unit and an external storage device of the terminal device 6. The memory 61 is used to store an operating system, an application program, a boot loader, data, and other programs, such as the program code of the computer program. The memory 61 may also be used to temporarily store data that has been output or is to be output.

[0185] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0186] An embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0187] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0188] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0189] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0190] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0191] 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 units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0192] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A data generation method, characterized in that: include: Obtaining a first data field corresponding to the test task; generating a plurality of random data for each of the first data fields; Data combination is performed according to the multiple random data in each of the first data fields to obtain multiple groups of test data corresponding to the test task.

2. The data generation method according to claim 1, characterized in that: The obtaining of the first data field corresponding to the test task includes: Obtaining an algorithm model corresponding to the test task; The first data field corresponding to the test task is determined according to the algorithm model.

3. The data generation method according to claim 2, characterized in that: The determining the first data field corresponding to the test task according to the algorithm model includes: Identifying variable parameters included in the algorithm model; The first data field corresponding to the test task is determined according to the variable parameter.

4. The data generation method according to any one of claims 1 to 3, characterized in that: The generating a plurality of random data of each of the first data fields comprises: Obtaining data attributes of each of the first data fields; A plurality of random data of each of the first data fields is generated according to a data attribute of each of the first data fields.

5. The data generation method according to claim 4, characterized in that: The obtaining of the data attribute of each of the first data fields includes: Obtaining a data definition document of a target system corresponding to the test task, wherein the data definition document includes data attributes of each data field in the target system; The data attribute of each of the first data fields is found from the data definition document.

6. The data generation method according to claim 4, characterized in that: The data attribute includes a value range; Generating a plurality of random data of each first data field according to the data attribute of each first data field comprises: A plurality of random data of each of the first data fields is generated within a value range of each of the first data fields.

7. The data generation method according to claim 6, characterized in that: The data attributes also include data types; Generating a plurality of random data of each first data field within a value range of each first data field includes: For each of the first data fields, a plurality of random data conforming to the data type of the first data field are generated within the value range of the first data field.

8. The data generation method according to any one of claims 1 to 7, characterized in that: The step of combining the multiple random data in each of the first data fields to obtain multiple groups of test data corresponding to the test task includes: Acquire at least one test sample corresponding to the test task, each of the test samples including sample data of the first data field and sample data of a second data field, wherein the second data field is a data field other than the first data field in the target system corresponding to the test task; Data combination is performed based on the sample data of the second data field in at least one of the test samples and the multiple random data in each of the first data fields to obtain multiple groups of the test data corresponding to the test task.

9. The data generation method according to claim 8, characterized in that: The step of combining the sample data of the second data field in at least one of the test samples and the multiple random data of each of the first data fields to obtain multiple groups of the test data corresponding to the test task includes: Arrange and combine multiple random data of each of all first data fields corresponding to the test task to obtain multiple groups of data sequences, wherein each group of data sequences includes one random data of each of all first data fields corresponding to the test task; Each of the test samples is combined with multiple groups of the data sequences to obtain multiple groups of the test data corresponding to each of the test samples.

10. The data generation method according to any one of claims 1 to 9, characterized in that: The method further comprises: A data file in a preset format is generated according to the multiple groups of test data corresponding to the test task, and the data file is used to provide test data for the test task, wherein the preset format is a plain text format.

11. The data generation method according to claim 10, characterized in that: The method further comprises: Obtaining the data file corresponding to the test task; Parsing the data file corresponding to the test task to obtain multiple groups of test data corresponding to the test task; The test task is executed according to the multiple groups of test data corresponding to the test task.

12. A data generating device, characterized in that: include: An acquisition unit, used for acquiring a first data field corresponding to the test task; A generating unit, configured to generate a plurality of random data for each of the first data fields; A combining unit is used to perform data combination according to multiple random data in each of the first data fields to obtain multiple groups of test data corresponding to the test task.

13. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the data generating method according to any one of claims 1 to 11 is implemented.

14. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the data generating method according to any one of claims 1 to 11 is implemented.