CN113986747A - Data generation method and device, electronic equipment and storage medium - Google Patents

Data generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113986747A
CN113986747A CN202111307512.9A CN202111307512A CN113986747A CN 113986747 A CN113986747 A CN 113986747A CN 202111307512 A CN202111307512 A CN 202111307512A CN 113986747 A CN113986747 A CN 113986747A
Authority
CN
China
Prior art keywords
data
field
target
preset
format
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111307512.9A
Other languages
Chinese (zh)
Inventor
焦放
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jingdong Technology Information Technology Co Ltd
Original Assignee
Jingdong Technology Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jingdong Technology Information Technology Co Ltd filed Critical Jingdong Technology Information Technology Co Ltd
Priority to CN202111307512.9A priority Critical patent/CN113986747A/en
Publication of CN113986747A publication Critical patent/CN113986747A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a data generation method, a device, electronic equipment and a storage medium, which are used for receiving a data generation request sent by a user, wherein the data generation request at least comprises a target service scene; if the data generation request indicates that the data format of the data required by testing the target service scene is the target data format, acquiring a preset data template which is preset and corresponds to the target data format; generating a target data template corresponding to a target service scene according to a preset data template, and identifying the target data template to obtain a plurality of fields and position information corresponding to each field; and for each field, writing the data of the field into a position corresponding to the target data template according to the position information of the field, wherein the data of the field is generated according to a preset rule which is preset and corresponds to the field. The invention can improve the data generation efficiency, is suitable for different service test scenes, and has certain universality.

Description

Data generation method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data generation method and apparatus, an electronic device, and a storage medium.
Background
With the rapid development of internet technology and computer technology, business systems are more and more widely applied to enterprises, public institutions and other units. The service system needs to perform service testing in the stages of development, daily maintenance, upgrading and the like, and before performing the service testing, data required for testing the service needs to be prepared.
In the prior art, data is usually manually input or generated in batch by a batch data generation tool, but the manual data input is long in time consumption and low in data generation efficiency, and the data generated by the batch data generation tool is single in format, cannot be applied to all service test scenes, and has no universality.
Disclosure of Invention
In view of this, the present invention provides a data generation method, an apparatus, an electronic device, and a storage medium, so as to achieve the purposes of improving data generation efficiency, being suitable for different service test scenarios, and having a certain versatility.
The first aspect of the present invention discloses a data generating method, which includes:
receiving a data generation request sent by a user, wherein the data generation request at least comprises a target service scene;
if the data generation request indicates that the data format of the data required for testing the target service scene is the target data format, acquiring a preset data template which is preset and corresponds to the target data format;
generating a target data template corresponding to the target service scene according to a preset data template, and identifying the target data template to obtain a plurality of fields and position information corresponding to each field;
and for each field, writing the data of the field into a position corresponding to the target data template according to the position information of the field, wherein the data of the field is generated according to a preset rule corresponding to the field, and the preset rule is preset.
Optionally, the generating the data of the field according to a preset rule corresponding to the field, which is preset, includes:
if the field is the constant field, acquiring data corresponding to the constant field from a database;
if the field is the variable field, acquiring a preset rule corresponding to the variable field, wherein the preset rule comprises the field format and the parameter type of the variable field;
and randomly generating data corresponding to the variable field according to the field format and the parameter type of the variable field.
Optionally, the method further includes:
if the data generation request indicates that the data format of the data required for testing the target service scene is not the target data format, generating a field set corresponding to the target service scene based on the target service scene, wherein the field set comprises a plurality of fields, and the fields comprise a plurality of constant fields and a plurality of variable fields;
and generating a data file according to each field and the data of each field, wherein the data of each field is generated according to a preset rule which is preset and corresponds to each field.
Optionally, the method further includes:
and storing the target data template written in the data of each field into a database so as to test the service indicated by the target service scene by using the target data template written in the data of each field in the database.
Optionally, the method further includes:
and storing the data file into a database so as to test the service indicated by the target service scene by using the data file in the database in the following process.
A second aspect of the present invention discloses a data generating apparatus, the apparatus comprising:
a receiving unit, configured to receive a data generation request sent by a user, where the data generation request at least includes a target service scenario;
a first obtaining unit, configured to obtain a preset data template corresponding to a target data format that is preset if the data generation request indicates that a data format of data required for testing the target service scenario is the target data format;
the first generating unit is used for generating a target data template corresponding to the target service scene according to a preset data template, and identifying the target data template to obtain a plurality of fields and position information corresponding to each field;
and the writing unit is used for writing the data of the fields into the corresponding positions of the target data template according to the position information of the fields, wherein the data of the fields are generated according to the second generating unit.
Optionally, the second generating unit includes:
a second obtaining unit, configured to obtain, if the field is the constant field, data corresponding to the constant field from a database;
a third obtaining unit, configured to obtain a preset rule corresponding to the variable field, where the preset rule includes a field format and a parameter type of the variable field, if the field is the variable field;
and the third generating unit is used for randomly generating data corresponding to the variable field according to the field format and the parameter type of the variable field.
Optionally, the apparatus further comprises:
a fourth generating unit, configured to generate a field set corresponding to the target service scenario based on the target service scenario if the data generation request indicates that a data format of data required for testing the target service scenario is not the target data format, where the field set includes a plurality of fields, and the fields include a plurality of constant fields and a plurality of variable fields;
and the fifth generating unit is used for generating a data file according to each field and the data of each field, wherein the data of each field is generated according to a preset rule which is preset and corresponds to each field.
A third aspect of the present invention shows an electronic device comprising a processor and a memory, the memory being adapted to store program code for data generation and data, the processor being adapted to invoke program instructions in the memory to perform a data generation method as shown in the first aspect of the present invention.
A fourth aspect of the present invention shows a storage medium including a stored program, wherein, when the program runs, a device on which the storage medium is located is controlled to execute a data generation method as shown in the first aspect of the present invention.
The invention provides a data generation method, a data generation device, electronic equipment and a storage medium, wherein under the condition that a data generation request sent by a user is received to indicate that the data format of data required by testing a target service scene is the target data format, a preset data template corresponding to the target data format is obtained in advance, further, a target data template corresponding to the target service scene can be generated according to the preset data template, and the generated target data template is identified to obtain a plurality of fields and position information corresponding to each field; and finally, generating data corresponding to each field according to a preset rule corresponding to each preset field, writing the data corresponding to each field into a target data template according to the field information of each field, and further storing the target data template written with the data corresponding to each field into a database so as to test the service indicated by the target service scene by using the target data template written with the data corresponding to each field in the database. According to the technical scheme provided by the invention, the test data required by testing different service scenes can be generated through the preset data template and the preset rule corresponding to each field, namely the technical scheme provided by the invention is suitable for different service test scenes and has certain universality, and the technical scheme provided by the invention does not need to manually input the data required by the service scenes required to be tested, so that the data generation efficiency is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a schematic flow chart of a data generation method according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of another data generation method according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a data generating apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules, or units, and are not used for limiting the order or interdependence of the functions performed by the devices, modules, or units.
It is noted that references to "a", "an", and "the" modifications in the disclosure are exemplary rather than limiting, and that those skilled in the art will understand that "one or more" unless the context clearly dictates otherwise.
Referring to fig. 1, a schematic flow chart of a data generation method provided in an embodiment of the present invention is shown, where the data generation method includes:
s101: and receiving a data generation request sent by a user, wherein the data generation request at least comprises a target service scene.
In the process of specifically executing step S101, a data generation request sent by a user based on a service scenario that needs to be tested is received, and for convenience of distinguishing, the service scenario carried in the data generation request is referred to as a target service scenario.
It should be noted that the target service scenario may be an interface batch test service scenario. The method can be determined according to practical application, and the embodiment of the invention is not limited.
S102: judging whether the data format of the data required for testing the target service scene indicated by the data generation request is the target data format or not; if the data generation request indicates that the data format of the data required for testing the target service scene is the target data format, executing step S103; if the data generation request indicates that the data format of the data required for testing the target service scenario is not the target data format, step S106 is not executed.
In step S102, a target data format is preset, and a preset data template corresponding to the target data format is preset.
In the embodiment of the present application, the preset target data format may be an excel data format, and correspondingly, the preset data template corresponding to the preset target data format may be an excel preset data template.
The above is only a preferred format of the target data format provided by the present invention, and the specific format of the target data format may be set according to practical applications, and the embodiment of the present invention is not limited thereto.
It should be noted that the data format other than the target data format may be a csv data format, an xlsx data format, and so on.
In the specific process of executing step S102, after receiving the data generation request sent by the user, it may be determined whether the data format of the data required for testing the target service scenario indicated by the data generation request is the target data format, and if the data format of the data required for testing the target service scenario indicated by the data generation request is not the target data format, step S106 is executed.
And under the condition that the data generation request indicates that the data format of the data required by the target service scene is the target data format, acquiring a preset data template which is preset and corresponds to the target data format.
S103: and acquiring a preset data template which is preset and corresponds to the target data format.
In the process of specifically executing step S103, when it is determined that the data format of the data required for the target service scenario is indicated by the data generation request, the preset data template corresponding to the target data format is acquired.
S104: and generating a target data template corresponding to the target service scene according to the preset data template, and identifying the target data template to obtain a plurality of fields and position information corresponding to each field.
In the specific execution process of step S104, after the target data template corresponding to the target data format is acquired, the target data template corresponding to the target service scene is generated according to the acquired preset data template, and the generated target data template is identified to obtain a plurality of fields and position information corresponding to each field.
In the embodiment of the present application, the plurality of fields obtained by identifying the target data template include a plurality of constant fields and a plurality of variable fields. Wherein, the constant field can be a title field, and the variable field can be an identity card field, a name field, a telephone number field, etc.
The location information of each field that needs to be specified is used to indicate where the field is located in the target data template.
S105: and for each field, writing the data of the field into a position corresponding to the target data template according to the position information of the field, wherein the data of the field is generated according to a preset rule which is preset and corresponds to the field.
In step S105, for each field corresponding to each service scenario, a corresponding preset rule is set in advance for generating data corresponding to the field. Specifically, if the field is a constant field, corresponding data is set for the constant field in advance, and the preset data corresponding to the constant field is stored in the database, so that the data corresponding to the constant field can be directly obtained from the database.
If the field is a variable field, setting a corresponding field format and a corresponding parameter type for the variable field in advance, that is, the preset rule corresponding to the variable field, which is set in advance, includes the field format and the parameter type of the variable field, and further, data corresponding to the variable field can be randomly generated according to the field format and the parameter type corresponding to the variable field.
For example, if the variable field is the identification number, the preset field format corresponding to the variable field (identification number) may be xxxx-xxxx-xxxx-xxxx, and the corresponding parameter type is the name type, and further, according to the field format and the parameter type corresponding to the variable field (identification number), the data corresponding to the variable field (identification number) may be 1345-3567-567234 generated randomly.
Regarding the field format and the parameter type corresponding to the variable field, the inventor may set the field format and the parameter type according to practical applications, and the embodiment of the present invention is not limited.
In the embodiment of the application, after the generated target data template is identified and a plurality of fields are obtained. For each constant field in the plurality of fields, the preset data corresponding to the constant field is directly obtained from the database.
And for each variable field in the plurality of fields, acquiring a preset field and a preset parameter type corresponding to the variable field, and then randomly generating data corresponding to the variable field according to the acquired field format and parameter type.
In the embodiment of the application, after the type corresponding to each field obtained by identifying the target data template is generated, for each field, according to the position information corresponding to the field, the data corresponding to the field is written into the position corresponding to the target data template, so that the target data template of the data written into each field is stored in the database.
S106: and generating a field set corresponding to the target business scene based on the target business scene, wherein the field set comprises a plurality of fields, and the fields comprise a plurality of constant fields and a plurality of variable fields.
In the specific process of executing step S106, when it is determined that the data format of the data required for testing the target service scenario is not the target data format, a field set composed of a plurality of fields corresponding to the target service scenario is directly generated.
Wherein the field set comprises a plurality of fields, the plurality of fields comprising a plurality of constant fields and a plurality of variable fields. The constant field may be a title field and the variable field may be an identification card field, a name field, a phone number field, etc.
S107: and generating a data file according to each field and the data of each field, wherein the data of each field is generated according to a preset rule which is preset and corresponds to each field.
In step S107, for each field corresponding to each service scenario, a corresponding preset rule is set in advance for generating data corresponding to the field. The preset rule set for each field in advance is the same as the preset rule set corresponding to each field in step S105, and reference may be made to the preset rule set corresponding to each field in step S105, which is not described herein again.
In the specific implementation process of step S107, after a field set corresponding to the target service scenario is generated, for each constant field in the field set, data corresponding to the preset constant field is directly obtained from the database; for each variable field in the field set, acquiring a preset field and a preset parameter type corresponding to the variable field, and then randomly generating data corresponding to the variable field according to the acquired field format and parameter type; and after generating the data corresponding to each field in the field set, generating a corresponding data file according to each field in the field set and the data of each field, so as to store the generated data file into a database.
The invention provides a data generation method, which can generate a target data template corresponding to a target service scene according to a preset data template under the condition that a data generation request indicates that the data format of data required by testing the target service scene is the target data format, and write the data of each field into the corresponding position of the target data template according to the field information corresponding to each field after generating the data corresponding to each field according to a preset rule corresponding to each field obtained by identifying the target data template, thereby storing the target data template written into the data of each field into a database; under the condition that the data format of the data required by the target service scene is not the target data format indicated by the data generation request, directly generating a field set corresponding to the target service scene, and generating a corresponding data file according to the data of each field generated by a preset rule corresponding to each field in the field set, so as to subsequently utilize a target data template in which the data corresponding to each field is written in a database, or the data file tests the target service scene indication. According to the technical scheme provided by the invention, the target data template corresponding to the target service scene can be generated through the preset data template, or the field set corresponding to the target service scene can be directly generated, so that the target data template or the data corresponding to each field in the field set can be generated according to the preset rule corresponding to each field, and the data required by testing different service scenes can be generated.
Referring to fig. 2, a schematic flow chart of a data generation method provided in an embodiment of the present invention is shown, where the data generation method includes:
s201: and receiving a data generation request sent by a user, wherein the data generation request at least comprises a target service scene.
S202: judging whether the data format of the data required for testing the target service scene indicated by the data generation request is the target data format or not; if the data generation request indicates that the data format of the data required for testing the target service scene is the target data format, executing step S203; if the data generation request indicates that the data format of the data required for testing the target service scenario is not the target data format, step S207 is not executed.
S203: and acquiring a preset data template which is preset and corresponds to the target data format.
In the process of specifically executing step S203, when it is determined that the data format of the data required for the target service scenario is indicated by the data generation request and is the target data format, a preset data template corresponding to the target data format, which is set in advance, is acquired.
S204: and generating a target data template corresponding to the target service scene according to the preset data template, and identifying the target data template to obtain a plurality of fields and position information corresponding to each field.
S205: and for each field, writing the data of the field into a position corresponding to the target data template according to the position information of the field, wherein the data of the field is generated according to a preset rule which is preset and corresponds to the field.
In the process of specifically executing step S201 to step S205, the specific execution process and implementation principle of step S201 to step S205 are the same as the specific execution process and implementation principle of step S101 to step S105 in fig. 1 disclosed in the above embodiment of the present invention, and reference may be made to the corresponding parts in fig. 1 disclosed in the above embodiment of the present invention, which is not described again here.
S206: and storing the target data template written with the data corresponding to each field into a database so as to test the service indicated by the target service scene by using the target data template written with the data corresponding to each field in the database.
In the process of specifically executing step S206, after the data corresponding to each field is written into the corresponding position of the target data template, the target data template written with the data corresponding to each field is stored in the database, so that the service indicated by the target service scenario is tested by using the target data template written with the data corresponding to each field in the database in the following process.
S207: and generating a field set corresponding to the target business scene based on the target business scene, wherein the field set comprises a plurality of fields, and the fields comprise a plurality of constant fields and a plurality of variable fields.
S208: and generating a data file according to each field and the data of each field, wherein the data of each field is generated according to a preset rule which is preset and corresponds to each field.
In the process of specifically executing step S207 to step S208, the specific execution process and implementation principle of step S207 to step S208 are the same as the specific execution process and implementation principle of step S106 to step S107 in fig. 1 disclosed in the foregoing embodiment of the present invention, and reference may be made to corresponding parts in fig. 1 disclosed in the foregoing embodiment of the present invention, which is not described again here.
S209: and storing the data file into a database so as to test the service indicated by the target service scene by using the data file in the database in the following process.
In the process of specifically executing step S209, after the data file is generated according to the data corresponding to each field in the field set, the target data template written in the data corresponding to each field may be stored in the database, so that the service indicated by the target service scenario may be tested by using the target data template written in the data corresponding to each field in the database in the following process.
In the embodiment of the application, when the data generation request indicates that the data format of the data required for testing the target service scenario is the target data format, a target data template corresponding to the target service scenario may be generated according to a preset data template, and after the data of each field is generated according to a preset rule corresponding to each field obtained by identifying the target data template, the data of each field is written into a position corresponding to the target data template according to the field information of each field, and the target data template written into the data corresponding to each field is stored in a database, so that the service indicated by the target service scenario is tested by using the target data template written into the data corresponding to each field in the database; under the condition that the data format of the data required by the target service scene is not the target data format indicated by the data generation request, a field set corresponding to the target service scene is directly generated, corresponding data files are generated according to the data of each field generated by a preset rule corresponding to each field in the field set, and then the data files are stored in a database so as to be used for testing the service indicated by the target service scene in the subsequent process.
Based on the data generation method disclosed in the embodiment of the present invention, the embodiment of the present invention also discloses a data generation device correspondingly, and as shown in fig. 3, the data generation device includes:
a receiving unit 31, configured to receive a data generation request sent by a user, where the data generation request at least includes a target service scenario;
a first obtaining unit 32, configured to obtain a preset data template corresponding to a target data format, where the preset data template is preset, if a data generation request indicates that a data format of data required for testing a target service scenario is the target data format;
the first generating unit 33 is configured to generate a target data template corresponding to a target service scene according to a preset data template, and identify the target data template to obtain a plurality of fields and position information corresponding to each field;
and a writing unit 34, configured to write, for each field, data of the field into a corresponding position of the target data template according to the position information of the field, where the data of the field is generated according to the second generating unit.
The specific principle and the execution process of each unit in the data generation device disclosed in the above embodiment of the present invention are the same as those of the data generation method disclosed in the above embodiment of the present invention, and reference may be made to corresponding parts in the data generation method disclosed in the above embodiment of the present invention, which are not described herein again.
The invention provides a data generation device, which is characterized in that under the condition that a data format of data required by testing a target service scene is a target data format as indicated by a data generation request sent by a user, a preset data template corresponding to the target data format is obtained, a target data template corresponding to the target service scene can be further generated according to the preset data template, and the generated target data template is identified to obtain a plurality of fields and position information corresponding to each field; and finally, generating data corresponding to each field according to a preset rule corresponding to each preset field, writing the data corresponding to each field into a target data template according to the field information of each field, and further storing the target data template written with the data corresponding to each field into a database so as to test the service indicated by the target service scene by using the target data template written with the data corresponding to each field in the database. According to the technical scheme provided by the invention, the test data required by testing different service scenes can be generated through the preset data template and the preset rule corresponding to each field, namely the technical scheme provided by the invention is suitable for different service test scenes and has certain universality, and the technical scheme provided by the invention does not need to manually input the data required by the service scenes required to be tested, so that the data generation efficiency is improved.
Optionally, the second generating unit includes:
the second obtaining unit is used for obtaining data corresponding to the constant field from the database if the field is the constant field;
a third obtaining unit, configured to obtain a preset rule corresponding to the variable field, where the preset rule includes a field format and a parameter type of the variable field, if the field is the variable field;
and the third generating unit is used for randomly generating data corresponding to the variable field according to the field format and the parameter type of the variable field.
Further, the data generating apparatus provided in the embodiment of the present invention further includes:
a fourth generating unit, configured to generate a field set corresponding to the target service scenario based on the target service scenario if the data generation request indicates that the data format of the data required for testing the target service scenario is not the target data format, where the field set includes a plurality of fields, and the plurality of fields includes a plurality of constant fields and a plurality of variable fields;
and the fifth generating unit is used for generating a data file according to each field and the data of each field, wherein the data of each field is generated according to a preset rule which is preset and corresponds to each field.
Further, the data generating apparatus provided in the embodiment of the present invention further includes:
and the first storage unit is used for storing the target data template of the data written in each field into the database so as to test the service indicated by the target service scene by using the target data template of the data written in each field in the database in the following process.
Further, the data generating apparatus provided in the embodiment of the present invention further includes:
and the second storage unit is used for storing the data file into the database so as to test the service indicated by the target service scene by using the data file in the database in the following process.
An electronic device provided in the embodiments of the present application is, as shown in fig. 4, provided with a processor 401 and a memory 402, where the memory 402 is used to store program codes and data for data generation, and the processor 401 is used to call program instructions in the memory to execute steps that implement the data generation method in the above embodiments.
The embodiment of the application provides a storage medium, the storage medium comprises a storage program, and when the program runs, a device on which the storage medium is located is controlled to execute the data generation method shown in the embodiment.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the system or system embodiments are substantially similar to the method embodiments and therefore are described in a relatively simple manner, and reference may be made to some of the descriptions of the method embodiments for related points. The above-described system and system embodiments are merely illustrative, wherein units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that it is obvious to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and these modifications and improvements should also be considered as the protection scope of the present invention.

Claims (10)

1. A method of data generation, the method comprising:
receiving a data generation request sent by a user, wherein the data generation request at least comprises a target service scene;
if the data generation request indicates that the data format of the data required for testing the target service scene is the target data format, acquiring a preset data template which is preset and corresponds to the target data format;
generating a target data template corresponding to the target service scene according to a preset data template, and identifying the target data template to obtain a plurality of fields and position information corresponding to each field;
and for each field, writing the data of the field into a position corresponding to the target data template according to the position information of the field, wherein the data of the field is generated according to a preset rule corresponding to the field, and the preset rule is preset.
2. The method according to claim 1, wherein the generating the data of the field according to a preset rule corresponding to the field, which is preset, comprises:
if the field is the constant field, acquiring data corresponding to the constant field from a database;
if the field is the variable field, acquiring a preset rule corresponding to the variable field, wherein the preset rule comprises the field format and the parameter type of the variable field;
and randomly generating data corresponding to the variable field according to the field format and the parameter type of the variable field.
3. The method of claim 1, further comprising:
if the data generation request indicates that the data format of the data required for testing the target service scene is not the target data format, generating a field set corresponding to the target service scene based on the target service scene, wherein the field set comprises a plurality of fields, and the fields comprise a plurality of constant fields and a plurality of variable fields;
and generating a data file according to each field and the data of each field, wherein the data of each field is generated according to a preset rule which is preset and corresponds to each field.
4. The method of claim 1, further comprising:
and storing the target data template written in the data of each field into a database so as to test the service indicated by the target service scene by using the target data template written in the data of each field in the database.
5. The method of claim 3, further comprising:
and storing the data file into a database so as to test the service indicated by the target service scene by using the data file in the database in the following process.
6. An apparatus for generating data, the apparatus comprising:
a receiving unit, configured to receive a data generation request sent by a user, where the data generation request at least includes a target service scenario;
a first obtaining unit, configured to obtain a preset data template corresponding to a target data format that is preset if the data generation request indicates that a data format of data required for testing the target service scenario is the target data format;
the first generating unit is used for generating a target data template corresponding to the target service scene according to a preset data template, and identifying the target data template to obtain a plurality of fields and position information corresponding to each field;
and the writing unit is used for writing the data of the fields into the corresponding positions of the target data template according to the position information of the fields, wherein the data of the fields are generated according to the second generating unit.
7. The apparatus of claim 6, wherein the second generating unit comprises:
a second obtaining unit, configured to obtain, if the field is the constant field, data corresponding to the constant field from a database;
a third obtaining unit, configured to obtain a preset rule corresponding to the variable field, where the preset rule includes a field format and a parameter type of the variable field, if the field is the variable field;
and the third generating unit is used for randomly generating data corresponding to the variable field according to the field format and the parameter type of the variable field.
8. The apparatus of claim 6, further comprising:
a fourth generating unit, configured to generate a field set corresponding to the target service scenario based on the target service scenario if the data generation request indicates that a data format of data required for testing the target service scenario is not the target data format, where the field set includes a plurality of fields, and the fields include a plurality of constant fields and a plurality of variable fields;
and the fifth generating unit is used for generating a data file according to each field and the data of each field, wherein the data of each field is generated according to a preset rule which is preset and corresponds to each field.
9. An electronic device, comprising a processor and a memory, the memory being configured to store program code and data for data generation, the processor being configured to invoke program instructions in the memory to perform a data generation method as claimed in any one of claims 1 to 5.
10. A storage medium characterized by comprising a stored program, wherein a device on which the storage medium is located is controlled to execute the data generation method according to any one of claims 1 to 5 when the program runs.
CN202111307512.9A 2021-11-05 2021-11-05 Data generation method and device, electronic equipment and storage medium Pending CN113986747A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111307512.9A CN113986747A (en) 2021-11-05 2021-11-05 Data generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111307512.9A CN113986747A (en) 2021-11-05 2021-11-05 Data generation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113986747A true CN113986747A (en) 2022-01-28

Family

ID=79746841

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111307512.9A Pending CN113986747A (en) 2021-11-05 2021-11-05 Data generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113986747A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114723349A (en) * 2022-06-09 2022-07-08 飞狐信息技术(天津)有限公司 Daily newspaper sending method, system, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114723349A (en) * 2022-06-09 2022-07-08 飞狐信息技术(天津)有限公司 Daily newspaper sending method, system, electronic equipment and storage medium
CN114723349B (en) * 2022-06-09 2022-09-20 飞狐信息技术(天津)有限公司 Daily newspaper sending method, system, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN107908553B (en) Association testing method, application server and computer readable storage medium
CN110765429B (en) User identity recognition method, security protection problem generation method and device
CN111177005A (en) Service application testing method, device, server and storage medium
CN107436844B (en) Method and device for generating interface use case aggregate
CN109711189B (en) Data desensitization method and device, storage medium and terminal
CN112631911A (en) Automatic testing method and device, computer equipment and storage medium
CN112463634A (en) Software testing method and device under micro-service architecture
CN112711640A (en) Method and device for configuring business handling process
CN113986747A (en) Data generation method and device, electronic equipment and storage medium
CN107220169B (en) Method and equipment for simulating server to return customized data
CN107357721B (en) Method and device for testing system
CN112433935A (en) Test method, test device, electronic equipment and storage medium
CN112433936A (en) Test method, test device and storage medium
CN112115060A (en) Audio test method and system based on terminal
CN116302889A (en) Performance test method and device for functional module and server
CN112241362A (en) Test method, test device, server and storage medium
CN114968822A (en) Interface testing method and device, computer equipment and storage medium
CN105162799A (en) Method for checking whether client is legal mobile terminal or not and server
CN114637672A (en) Automatic data testing method and device, computer equipment and storage medium
WO2019062087A1 (en) Attendance check data testing method, terminal and device, and computer readable storage medium
CN110166636B (en) Pressure testing device and method and storage medium
CN111143644B (en) Identification method and device of Internet of things equipment
CN110413672B (en) Automatic data importing method and device and computer readable storage medium
CN113051178A (en) Test data construction method, device, equipment and medium
CN111225075A (en) Configuration method and device for Internet of things directional access service

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination