CN113391992A - Test data generation method and device, storage medium and electronic equipment - Google Patents

Test data generation method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN113391992A
CN113391992A CN202011401768.1A CN202011401768A CN113391992A CN 113391992 A CN113391992 A CN 113391992A CN 202011401768 A CN202011401768 A CN 202011401768A CN 113391992 A CN113391992 A CN 113391992A
Authority
CN
China
Prior art keywords
request
historical
parameters
parameter
target
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
CN202011401768.1A
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202011401768.1A priority Critical patent/CN113391992A/en
Publication of CN113391992A publication Critical patent/CN113391992A/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

Abstract

The invention discloses a test data generation method and device, a storage medium and electronic equipment. Wherein, the method comprises the following steps: the method comprises the steps of obtaining a first request parameter set of a target interface, obtaining historical request information of the target interface, determining parameter values of request parameters in the first request parameter set according to the historical request information, obtaining target test data, automatically generating the target test data through obtaining the request parameter set and obtaining historical request information, replacing a scheme of obtaining the test data through unit testing in the related technology, achieving the purpose of optimizing the test data, achieving the technical effects of improving the generation efficiency of the test data, reducing the construction cost of the test parameters and expanding the application range of the test data, and solving the technical problem of low generation efficiency of the test data in the related technology.

Description

Test data generation method and device, storage medium and electronic equipment
Technical Field
The invention relates to the field of computers, in particular to a method and a device for generating test data, a storage medium and electronic equipment.
Background
In the related art at present, interface request parameters generated by a test platform or a tool are often null values or fixed default values, and a set of effective request data needs to be constructed in the process of debugging an interface, but when the parameter structure is complex, the parameters are of various types, so that the efficiency of parameter construction is difficult to guarantee.
In addition, in the development and test process of the service interface, various execution branches may exist, in the related technology, generally, unit tests or interface tests are used to obtain test data, various execution branches cannot be fully covered, the service interface is difficult to be fully covered and tested, and then a vulnerability problem is discovered, so that the technical problem that the generation efficiency of the test data in the related technology is low is caused.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the invention provides a method and a device for generating test data, a storage medium and electronic equipment, which are used for at least solving the technical problem of low test data generation efficiency in the related technology.
According to an aspect of the embodiments of the present invention, there is provided a method for generating test data, including: acquiring a first request parameter set of a target interface, wherein the first request parameter set is used for requesting a target service through the target interface of the target service; acquiring historical request information of the target interface, wherein the historical request information comprises a plurality of historical request parameter sets and corresponding parameter values of the target interface, and each historical request parameter set is used for requesting the target service through the target interface; and determining a parameter value of a request parameter in the first request parameter set according to the historical request information to obtain target test data, wherein the target test data comprises the first request parameter set and a corresponding parameter value, and the target test data is used for testing the request of the target service through the target interface.
Optionally, the obtaining of the historical request information of the target interface includes: acquiring historical test information of the target interface, wherein the historical request information comprises the historical test information, the historical test information comprises a plurality of historical test parameter sets and corresponding parameter values of the target interface, and each historical test parameter set is used for testing the request of the target service through the target interface; and/or obtaining historical actual request information of the target interface, wherein the historical request information comprises the historical actual request information, the historical actual request information comprises a plurality of historical actual request parameter sets of the target interface and corresponding parameter values, and each historical actual request parameter set is a parameter set which is actually used when the target service is requested through the target interface.
Optionally, the determining, according to the historical request information, a parameter value of a request parameter in the first request parameter set to obtain target test data includes: searching request parameters matched with the request parameters in the first request parameter set in the historical request information; and determining the parameter value of the request parameter in the first request parameter set according to the searched request parameter to obtain the target test data.
Optionally, the searching for the request parameter matching the request parameter in the first request parameter set in the historical request information includes: respectively acquiring parameters of each history request parameter set and the first request parameter set to obtain N sub-parameter sets, wherein N is the number of the history request parameter aggregates and is a natural number greater than 1, and each sub-parameter set comprises parameters of each history request parameter set and the first request parameter set; and determining the request parameters matched with the request parameters in the first request parameter set according to the N sub-parameter sets.
Optionally, the obtaining parameters of each historical request parameter set and the first request parameter set respectively to obtain N sub-parameter sets includes: obtaining an ith sub-parameter set of the N sub-parameter sets by: serializing parameter names of parameters in the ith historical request parameter set into an ith character string; comparing the ith character string with a target character string to obtain a sub-character string of the ith character string and the target character string which are the same, wherein the target character string is a character string formed by serializing the parameter names of the parameters in the first request parameter set; and determining the ith sub-parameter set as parameters corresponding to the same sub-character strings in the ith historical request parameter set.
Optionally, the determining, according to the N sub-parameter sets, a request parameter that matches a request parameter in the first request parameter set includes: determining a target historical request parameter set from the N historical request parameter sets according to the number of parameters in each sub-parameter set; and determining request parameters matched with the request parameters in the first request parameter set according to the target historical request parameter set.
Optionally, determining a target historical request parameter set from the N historical request parameter sets according to the number of parameters in each of the sub-parameter sets, including: determining the target historical request parameter set from the N historical request parameter sets according to the number of parameters in each sub-parameter set; in the N history request parameter sets, the number of parameters in the sub-parameter set corresponding to the target history request parameter set is the largest, or the result of requesting the target service corresponding to the target history request parameter set is successful, and in M history request parameter sets in the N history request parameter sets, the number of parameters in the sub-parameter set corresponding to the target history request parameter set is the largest, where the result of requesting the target service corresponding to each history request parameter set in the M history request parameter sets is successful, and M is less than or equal to N.
Optionally, the determining, according to the target historical request parameter set, a request parameter that matches a request parameter in the first request parameter set includes: in the event that the target historical set of request parameters includes all of the request parameters in the first set of request parameters, determining request parameters that match the request parameters in the first set of request parameters to be equal to the all of the request parameters included in the target historical set of request parameters; and/or in the case that the target historical request parameter set comprises a first part of request parameters in the first request parameter set, searching request parameters matched with a second part of request parameters in the historical request information, wherein the second part of request parameters are request parameters in the first request parameter set except the first part of request parameters; determining request parameters that match request parameters in the first set of request parameters to include: the first part of request parameters included in the target historical request parameter set and the searched request parameters matched with the second part of request parameters.
Optionally, the searching for the request parameter matching with the second part of request parameters in the historical request information includes: under the condition that the second part of request parameters are one request parameter, P historical request parameter sets comprising the one request parameter are determined in the N historical request parameter sets, wherein P is smaller than or equal to N; selecting one request parameter included in one historical request parameter set from the P historical request parameter sets as the request parameter matched with the second part of request parameters; and/or in the case that the second part of request parameters are multiple request parameters, determining Q historical request parameter sets comprising the multiple request parameters from the N historical request parameter sets, wherein Q is less than or equal to N; and selecting the plurality of request parameters included in one historical request parameter set from the Q historical request parameter sets as the request parameters matched with the second part of request parameters.
Optionally, the method further comprises: and under the condition that the request parameters matched with the second part of request parameters cannot be searched in the historical request information, setting corresponding parameter values for the second part of request parameters in the first request parameter set within a preset value range.
Optionally, the determining, according to the found request parameter, a parameter value of the request parameter in the first request parameter set to obtain the target test data includes: and setting the parameter value of the request parameter in the first request parameter set to be equal to the parameter value of the searched request parameter.
Optionally, the method further comprises at least one of: testing the request of the target service through the target interface by using the target test data; or generating a test file comprising the target test data; or printing the target test data.
According to another aspect of the embodiments of the present invention, there is also provided a device for generating test data, including:
a first obtaining module, configured to obtain a first request parameter set of a target interface, where the first request parameter set is used to request a target service through the target interface of the target service;
a second obtaining module, configured to obtain historical request information of the target interface, where the historical request information includes multiple historical request parameter sets of the target interface and corresponding parameter values, and each historical request parameter set is used to request the target service through the target interface;
a determining module, configured to determine, according to the historical request information, a parameter value of a request parameter in the first request parameter set, to obtain target test data, where the target test data includes the first request parameter set and a corresponding parameter value, and the target test data is used to test a request of the target service through the target interface.
Optionally, the second obtaining module includes: a first obtaining unit, configured to obtain historical test information of the target interface, where the historical request information includes the historical test information, the historical test information includes multiple historical test parameter sets and corresponding parameter values of the target interface, and each historical test parameter set is used to test a request of the target service through the target interface; and/or a second obtaining unit, configured to obtain historical actual request information of the target interface, where the historical request information includes the historical actual request information, the historical actual request information includes multiple historical actual request parameter sets of the target interface and corresponding parameter values, and each of the historical actual request parameter sets is a parameter set that is actually used when the target interface requests the target service.
Optionally, the determining module includes: a searching unit, configured to search the historical request information for a request parameter that matches a request parameter in the first request parameter set; and the determining unit is used for determining the parameter value of the request parameter in the first request parameter set according to the searched request parameter to obtain the target test data.
Optionally, the searching unit is configured to search the historical request information for the request parameter that matches the request parameter in the first request parameter set by: respectively acquiring parameters of each history request parameter set and the first request parameter set to obtain N sub-parameter sets, wherein N is the number of the history request parameter aggregates and is a natural number greater than 1, and each sub-parameter set comprises parameters of each history request parameter set and the first request parameter set; and determining the request parameters matched with the request parameters in the first request parameter set according to the N sub-parameter sets.
Optionally, the searching unit is configured to obtain parameters of each of the historical request parameter sets and the first request parameter set respectively in the following manner, so as to obtain N sub-parameter sets: obtaining an ith sub-parameter set of the N sub-parameter sets by: serializing parameter names of parameters in the ith historical request parameter set into an ith character string; comparing the ith character string with a target character string to obtain a sub-character string of the ith character string and the target character string which are the same, wherein the target character string is a character string formed by serializing the parameter names of the parameters in the first request parameter set; and determining the ith sub-parameter set as parameters corresponding to the same sub-character strings in the ith historical request parameter set.
Optionally, the finding unit is configured to determine, according to the N sub-parameter sets, a request parameter that matches a request parameter in the first request parameter set by the following method, where the method includes: determining a target historical request parameter set from the N historical request parameter sets according to the number of parameters in each sub-parameter set; and determining request parameters matched with the request parameters in the first request parameter set according to the target historical request parameter set.
Optionally, the apparatus is configured to determine a target history request parameter set from the N history request parameter sets according to the number of parameters in each of the sub-parameter sets by: determining the target historical request parameter set from the N historical request parameter sets according to the number of parameters in each sub-parameter set; in the N history request parameter sets, the number of parameters in the sub-parameter set corresponding to the target history request parameter set is the largest, or the result of requesting the target service corresponding to the target history request parameter set is successful, and in M history request parameter sets in the N history request parameter sets, the number of parameters in the sub-parameter set corresponding to the target history request parameter set is the largest, where the result of requesting the target service corresponding to each history request parameter set in the M history request parameter sets is successful, and M is less than or equal to N.
Optionally, the apparatus is configured to determine, according to the target historical request parameter set, a request parameter that matches a request parameter in the first request parameter set by: in the event that the target historical set of request parameters includes all of the request parameters in the first set of request parameters, determining request parameters that match the request parameters in the first set of request parameters to be equal to the all of the request parameters included in the target historical set of request parameters; and/or in the case that the target historical request parameter set comprises a first part of request parameters in the first request parameter set, searching request parameters matched with a second part of request parameters in the historical request information, wherein the second part of request parameters are request parameters in the first request parameter set except the first part of request parameters; determining request parameters that match request parameters in the first set of request parameters to include: the first part of request parameters included in the target historical request parameter set and the searched request parameters matched with the second part of request parameters.
Optionally, the apparatus is configured to search the historical request information for the request parameter matching the second part of request parameters by: under the condition that the second part of request parameters are one request parameter, P historical request parameter sets comprising the one request parameter are determined in the N historical request parameter sets, wherein P is smaller than or equal to N; selecting one request parameter included in one historical request parameter set from the P historical request parameter sets as the request parameter matched with the second part of request parameters; and/or in the case that the second part of request parameters are multiple request parameters, determining Q historical request parameter sets comprising the multiple request parameters from the N historical request parameter sets, wherein Q is less than or equal to N; and selecting the plurality of request parameters included in one historical request parameter set from the Q historical request parameter sets as the request parameters matched with the second part of request parameters.
Optionally, the apparatus is further configured to: and under the condition that the request parameters matched with the second part of request parameters cannot be searched in the historical request information, setting corresponding parameter values for the second part of request parameters in the first request parameter set within a preset value range.
Optionally, the device is configured to determine a parameter value of a request parameter in the first request parameter set according to the found request parameter in the following manner, so as to obtain the target test data: and setting the parameter value of the request parameter in the first request parameter set to be equal to the parameter value of the searched request parameter.
Optionally, the apparatus is further configured to perform at least one of the following: testing the request of the target service through the target interface by using the target test data; or generating a test file comprising the target test data; or printing the target test data.
According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the above test data generation method when running.
According to still another aspect of the embodiments of the present invention, there is also provided an electronic device, including a memory and a processor, where the memory stores therein a computer program, and the processor is configured to execute the method for generating test data described above through the computer program.
In the embodiment of the invention, a mode of acquiring the first request parameter set of the target interface, acquiring the historical request information of the target interface, determining the parameter value of the request parameter in the first request parameter set according to the historical request information, and acquiring the target test data is adopted, and the acquired historical request information is used for automatically generating the target test data, so that a scheme of obtaining the test data through unit test in the related technology is replaced, and the aim of optimizing the test data is fulfilled, thereby realizing the technical effects of improving the generation efficiency of the test data, reducing the construction cost of the test parameter, expanding the application range of the test data, and further solving the technical problem of low generation efficiency of the test data in the related technology.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a schematic diagram of an application environment of an alternative test data generation method according to an embodiment of the invention;
FIG. 2 is a flow chart illustrating an alternative method for generating test data according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an alternative test data generation method according to an embodiment of the invention;
FIG. 4 is a schematic diagram of an alternative test data generation method according to an embodiment of the invention;
FIG. 5 is a schematic diagram of yet another alternative test data generation method according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of yet another alternative test data generation method according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of yet another alternative test data generation method according to an embodiment of the invention;
FIG. 8 is a schematic diagram of yet another alternative test data generation method according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of yet another alternative test data generation method according to an embodiment of the present invention;
FIG. 10 is a schematic diagram of yet another alternative test data generation method according to an embodiment of the invention;
FIG. 11 is a schematic structural diagram of an alternative test data generating apparatus according to an embodiment of the present invention;
fig. 12 is a schematic structural diagram of an alternative electronic device according to an embodiment of the invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, 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.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
First, partial nouns or terms appearing in the description of the embodiments of the present application are applicable to the following explanations:
FUZZ: finger blur testing.
Capdock: the platform is provided with the functions of capturing, analyzing and tampering, and constructing a virtual request or a return packet, so that a network interaction scene based on a private protocol between a client and a background can be known more clearly, wherein tampering and simulation are easier to construct a user scene under any condition, and front-end and back-end separation can be realized.
LogRelay: the method is a background interface automatic testing tool based on flow recording and playback, is mainly applied to regression testing in reconstruction and daily iteration, and has the characteristics of low investment, high coverage rate and high efficiency.
Protocol buffer: is a data exchange format, independent of language and independent of platform. As a binary data transmission format excellent in efficiency and compatibility, it can be used in various fields such as network transmission, profile, data storage, and the like.
The invention is illustrated below with reference to examples:
according to an aspect of the embodiment of the present invention, a method for generating test data is provided, and optionally, in this embodiment, the method for generating test data may be applied to a hardware environment formed by a server 101 and a user terminal 103 as shown in fig. 1. As shown in fig. 1, a server 101 is connected to a terminal 103 through a network, and may be configured to provide a service to a user terminal or a client installed on the user terminal, where the client may be a video client, an instant messaging client, a browser client, an education client, a game client, or the like. The database 105 may be provided on or separate from the server for providing data storage services for the server 101, such as a game data storage server, and the network may include, but is not limited to: a wired network, a wireless network, wherein the wired network comprises: a local area network, a metropolitan area network, and a wide area network, the wireless network comprising: bluetooth, WIFI, and other networks implementing wireless communication, the user terminal 103 may be a terminal configured with an application executing the above test data generation method, and may include but is not limited to at least one of the following: the application 107 using the method for generating test data is displayed through a user terminal 103, and the application 107 may be started through an entry of the application 107 configured on the terminal for generating test data, so as to execute the method for generating test data, where the application 107 is only an example, and this is not limited in this embodiment.
As shown in fig. 1, the method for generating the test data may be implemented in the user terminal 103 by the following steps:
s1, starting the application 107 (i.e. the test client shown in fig. 1) in the user terminal 103, and obtaining a first request parameter set of the target interface, where the first request parameter set is used for requesting the target service through the target interface of the target service;
s2, obtaining historical request information of the target interface in the application 107, where the historical request information includes multiple historical request parameter sets of the target interface and corresponding parameter values, and each historical request parameter set is used for requesting a target service through the target interface;
s3, determining, in the application 107, a parameter value of a request parameter in the first request parameter set according to the historical request information, to obtain target test data, where the target test data includes the first request parameter set and a corresponding parameter value, and the target test data is used to test a request of a target service through a target interface.
Optionally, in this embodiment, the test data generation method may also be used by a client configured in a server, but not limited to.
Optionally, in this embodiment, the method for generating the test data may include, but is not limited to, using the application 107 and the server 101 in combination, and obtaining the history request information from the server 101 through the application 107 to generate the target test data.
The above is merely an example, and the present embodiment is not particularly limited.
Optionally, as an optional implementation manner, as shown in fig. 2, the method for generating test data includes:
s202, acquiring a first request parameter set of a target interface, wherein the first request parameter set is used for requesting a target service through the target interface of the target service;
s204, acquiring historical request information of the target interface, wherein the historical request information comprises a plurality of historical request parameter sets and corresponding parameter values of the target interface, and each historical request parameter set is used for requesting a target service through the target interface;
and S206, determining parameter values of the request parameters in the first request parameter set according to the historical request information to obtain target test data, wherein the target test data comprises the first request parameter set and corresponding parameter values, and the target test data is used for testing the request of the target service through the target interface.
Optionally, in this embodiment, the application scenario of the test data may include, but is not limited to, a test scenario of an instant messaging program, a test scenario of a game program, a test scenario of a transportation program, a test scenario of an electronic shopping program, a test scenario of an internet of things, and the like.
Optionally, in this embodiment, the application scenario of the test data may further include, but is not limited to, combining with an artificial intelligence technology, and is used for testing each module in the artificial intelligence.
Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result. In other words, artificial intelligence is a comprehensive technique of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a manner similar to human intelligence. Artificial intelligence is the research of the design principle and the realization method of various intelligent machines, so that the machines have the functions of perception, reasoning and decision making.
The artificial intelligence technology is a comprehensive subject and relates to the field of extensive technology, namely the technology of a hardware level and the technology of a software level. The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
Computer Vision technology (CV) Computer Vision is a science for researching how to make a machine "see", and further refers to that a camera and a Computer are used to replace human eyes to perform machine Vision such as identification, tracking and measurement on a target, and further image processing is performed, so that the Computer processing becomes an image more suitable for human eyes to observe or transmitted to an instrument to detect. As a scientific discipline, computer vision research-related theories and techniques attempt to build artificial intelligence systems that can capture information from images or multidimensional data. Computer vision technologies generally include image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content/behavior recognition, three-dimensional object reconstruction, 3D technologies, virtual reality, augmented reality, synchronous positioning, map construction, and other technologies, and also include common biometric technologies such as face recognition and fingerprint recognition.
Key technologies for Speech Technology (Speech Technology) are automatic Speech recognition Technology (ASR) and Speech synthesis Technology (TTS), as well as voiceprint recognition Technology. The computer can listen, see, speak and feel, and the development direction of the future human-computer interaction is provided, wherein the voice becomes one of the best viewed human-computer interaction modes in the future.
Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that enable efficient communication between humans and computers using natural language. Natural language processing is a science integrating linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language that people use everyday, so it is closely related to the research of linguistics. Natural language processing techniques typically include text processing, semantic understanding, machine translation, robotic question and answer, knowledge mapping, and the like.
Machine Learning (ML) is a multi-domain cross discipline, and relates to a plurality of disciplines such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and the like. The special research on how a computer simulates or realizes the learning behavior of human beings so as to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve the performance of the computer. Machine learning is the core of artificial intelligence, is the fundamental approach for computers to have intelligence, and is applied to all fields of artificial intelligence. Machine learning and deep learning generally include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and formal education learning.
With the research and progress of artificial intelligence technology, the artificial intelligence technology is developed and applied in a plurality of fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, unmanned aerial vehicles, robots, smart medical care, smart customer service, and the like.
The above is merely an example, and the present embodiment does not limit this.
Optionally, in this embodiment, the method for generating test data may be used in the client through a process including, but not limited to, the following, and fig. 3 is a schematic flow chart of another optional method for generating test data according to an embodiment of the present invention, as shown in fig. 3, where the process includes the following steps:
s302, downloading a tool;
the tool for generating the test data can be downloaded through a preset link address, and the link address is used for storing the tool for executing the method for generating the test data.
S304, initializing a configuration file;
the configuration file can be automatically generated after an operation command is automatically generated after the command is operated by a tool executing the test data generation method.
S306, inputting parameters, for example, which may include but are not limited to the following:
ngtest-gen-data config # automatic configuration file generation
S308, the user can specify 4 different patterns to construct the generated data, as shown in FIG. 3, which are the smart FUZZ pattern 310-1, the CapMock pattern 310-2, the LogRelay pattern 310-3, and the FUZZ pattern 310-4, respectively.
S310-1, an intelligent FUZZ mode is designated, and after the operation, data construction and generation are carried out by utilizing an intelligent learning and FUZZ algorithm according to a request body defined in a protocol file and reference data acquired through a data search service;
s310-2 designates a CapMock mode, after operation, historical test data is acquired from a CapMock data source as related reference data through a data search service according to a request body defined in a protocol file, and data generation is completed by recursively traversing all fields of a request parameter model;
s310-2 designates a LogReply mode, and after the operation, flow request data is acquired from a LogReply data source as related reference data through a data search service according to a request body defined in a protocol file, and all fields of a request parameter model are recursively traversed to complete data generation;
s310-4, an FUZZ mode is designated, after operation, data are generated randomly in a rule range according to a request body defined in a protocol file by combining a self-defined field value-taking rule and a type value-taking rule, and all fields of a request parameter model are recursively traversed to complete data construction;
s310, printing and outputting the test data result.
Optionally, in this embodiment, the target interface may include, but is not limited to, a data interface for exchanging Service data, for example, may include, but is not limited to, an HTTP interface, an RPC interface, a Web Service interface, and the like, and may include, but is not limited to, sending a request message through the target interface, where the request message includes a parameter in a predetermined format to implement a function corresponding to the request message.
The number of the target interfaces may be one or more.
Optionally, in this embodiment, the target service may include, but is not limited to, an application program, an APP, an applet, a web page, and other services that are required to be used when implementing the function. May include, but is not limited to, services used when using pull lists, querying orders, uploading game data, performing alert announcements, and the like.
For example, in the application program 402 shown in fig. 4, by performing a pull-down operation in the predetermined area 404 to use the service corresponding to the pull list function, the application program 402 transmits an operation instruction corresponding to the pull-down operation as the first request parameter set from the target interface to the management background corresponding to the pull list function, so as to perform display of the pulled list on the display interface of the application program, thereby implementing the function of pulling the list.
The above is merely an example, and the present embodiment is not limited in any way.
Optionally, in this embodiment, the first request parameter set may include, but is not limited to, being preconfigured according to a type of the target service or a difference of a backend management program for managing the target service, and a format of the first request parameter set may include, but is not limited to, identification information of the target service, identification information of the target interface, and the like.
For example, a parameter parser may parse parameters in a command input by a user from a terminal command line, parse the parameters in a configuration file, and then a metadata parser may perform traversal parsing on a pb protocol file or a jce protocol file specified in the parameters, so as to obtain all services and methods in the protocol file, and obtain a structure of corresponding request information and a structure of response information as the first request parameter combination, and generate a request parameter model corresponding to the first request parameter combination.
Optionally, in this embodiment, the parameters included in the first request parameter set may include, but are not limited to, determining according to a protocol corresponding to the target service, for example, after a protocol type corresponding to the target service is obtained, generating a model of the request parameters according to the protocol type, so as to obtain the first request parameters. The above is merely an example, and the present embodiment does not limit this.
Optionally, in this embodiment, the history request information combination may include, but is not limited to, a plurality of history request parameter sets and corresponding parameter values acquired from the target interface, and may include, but is not limited to, history test information or history actual request information.
It should be noted that the history request information may include, but is not limited to, history request information obtained from interfaces of the same or different versions, and may also include, but is not limited to, history request information obtained according to a predefined data range.
Optionally, in this embodiment, the target test data may include, but is not limited to, a first request parameter set and a parameter value corresponding to the first request parameter set determined according to the historical request information. The target test data may include, but is not limited to, being stored as a test data source in a predetermined database for use in a subsequent test procedure.
According to the embodiment, the first request parameter set of the target interface is obtained, the historical request information of the target interface is obtained, the parameter value of the request parameter in the first request parameter set is determined according to the historical request information, the target test data is obtained, the request parameter set is obtained, the historical request information is obtained to automatically generate the target test data, the scheme that the test data are obtained through unit testing in the related technology is replaced, the purpose of optimizing the test data is achieved, the generation efficiency of the test data is improved, the construction cost of the test parameter is reduced, the technical effect of expanding the application range of the test data is achieved, and the technical problem that the generation efficiency of the test data in the related technology is low is solved.
As an optional scheme, the obtaining of the historical request information of the target interface includes:
s1, acquiring historical test information of the target interface, where the historical request information includes the historical test information, the historical test information includes a plurality of historical test parameter sets and corresponding parameter values of the target interface, and each of the historical test parameter sets is used to test a request of the target service through the target interface; and/or
S2, obtaining historical actual request information of the target interface, where the historical request information includes the historical actual request information, the historical actual request information includes a plurality of historical actual request parameter sets and corresponding parameter values of the target interface, and each of the historical actual request parameter sets is a parameter set that is actually used when the target interface requests the target service.
Optionally, in this embodiment, the historical test information may include, but is not limited to, a plurality of historical test parameter sets of the target interface and corresponding parameter values, where each historical test parameter set is used for testing a request of the target service through the target interface.
The historical test information may include, but is not limited to, test information obtained in a process of testing a target service in the past, past test data that is obtained by a target interface in advance before a current test data generation process, test data generated in a process of testing the target service through the target interface, and the like.
For example, by specifying the capclock mode, after the operation, the historical test data may be obtained from the capclock data source as the historical request information through the data search service according to the structure of the first request parameter set defined in the protocol file.
The above is only an example, and may specifically include, but is not limited to, a combination of one or more of the above, and the present embodiment is not limited in any way.
Optionally, in this embodiment, the historical actual request information may include, but is not limited to, historical actual request information generated when the target service is requested through the target interface before the first request parameter set of the target interface is obtained.
For example, the method may include, but is not limited to, acquiring data currently generated by using the target service through a target interface as the historical actual request information, and may further include, but is not limited to, acquiring data generated after the target service has been used before as the historical actual request information.
For example, after the log replay mode is specified, traffic request data is obtained from a log replay data source as the historical request information through a data search service according to a structure of a first request parameter set defined in a protocol file.
By the embodiment, historical test information of a target interface is acquired, wherein the historical request information comprises historical test information, the historical test information comprises a plurality of historical test parameter sets and corresponding parameter values of the target interface, and each historical test parameter set is used for testing a request of a target service through the target interface; and/or obtaining historical actual request information of the target interface, wherein the historical request information comprises historical actual request information, the historical actual request information comprises a plurality of historical actual request parameter sets of the target interface and corresponding parameter values, each historical actual request parameter set is combined into a mode of a parameter set actually used when the target interface requests the target service, the historical request information can be intelligently and quickly and efficiently acquired according to the actual needs or the service types, further, parameter values can be determined according to the historical request information to obtain target test data, thereby achieving the technical effects of improving the generation efficiency of the test data, reducing the construction cost of the test parameters and expanding the application range of the test data, and the technical problem of low test data generation efficiency in the related technology is solved.
As an optional scheme, determining a parameter value of a request parameter in a first request parameter set according to historical request information to obtain target test data, including:
s1, searching the request parameters matched with the request parameters in the first request parameter set in the historical request information;
and S2, determining the parameter value of the request parameter in the first request parameter set according to the searched request parameter, and obtaining target test data.
Optionally, in this embodiment, the searching for the request parameter matching the request parameter in the first request parameter set in the historical request information may include, but is not limited to, determining that the model corresponding to the first request parameter set in the available historical request information is associated in the case that it is determined that the historical request information is available.
The above is merely an example, and the present embodiment is not limited in any way.
According to the embodiment, the request parameters matched with the request parameters in the first request parameter set are searched in the historical request information, the parameter values of the request parameters in the first request parameter set are determined according to the searched request parameters, the target test data is obtained, the problem that the historical request information cannot be effectively utilized can be solved, further, the technical effects of improving the generation efficiency of the test data, reducing the construction cost of the test parameters and expanding the application range of the test data can be achieved, and the technical problem that the generation efficiency of the test data is low in the related technology is solved.
As an optional solution, finding a request parameter matching a request parameter in the first request parameter set in the historical request information includes:
s1, respectively obtaining parameters of each history request parameter set and the first request parameter set to obtain N sub-parameter sets, wherein N is the number of the history request parameter aggregation and is a natural number greater than 1, and each sub-parameter set comprises parameters of the history request parameter set and the first request parameter set;
and S2, determining the request parameters matched with the request parameters in the first request parameter set according to the N sub-parameter sets.
Optionally, in this embodiment, the determining of the N sets of sub-parameters may include, but is not limited to, determining the number of parameters of both the historical request parameter set and the first request parameter set.
For example, taking N as 2 as an example, if the 2 history request parameter sets include a first history request parameter set (a parameter, B parameter) and a second history request parameter set (a parameter, B parameter, C parameter), and the first request parameter set includes a parameter and B parameter, then the a parameter and the B parameter included in the first history request parameter set are determined as 1 sub-parameter set, and the a parameter and the B parameter included in the first history request parameter set are determined as 1 sub-parameter set, so as to obtain 2 sub-parameter sets.
By the embodiment, N sub-parameter sets are obtained by respectively obtaining the parameters of each history request parameter set and the first request parameter set, wherein N is the number of the historical request parameter aggregations and N is a natural number greater than 1, each of the sub-parameter sets includes parameters that both the historical request parameter set and the first request parameter set have, according to the N sub-parameter sets, the request parameters matched with the request parameters in the first request parameter set are determined, so that the effective historical request parameters can be obtained more completely and accurately, furthermore, the technical effects of improving the generation efficiency of the test data, reducing the construction cost of the test parameters and expanding the application range of the test data can be achieved, and the technical problem of low generation efficiency of the test data in the related technology is solved.
As an optional scheme, the obtaining parameters of each historical request parameter set and the first request parameter set respectively to obtain N sub-parameter sets includes:
s1, obtaining the ith sub-parameter set in the N sub-parameter sets through the following steps:
s2, serializing the parameter names of the parameters in the ith history request parameter set into an ith character string;
s3, comparing the ith character string with a target character string to obtain a sub character string with the same ith character string as the target character string, wherein the target character string is a character string formed by serializing the parameter names of the parameters in the first request parameter set;
and S4, determining the ith sub-parameter set as including the parameters corresponding to the same sub-character strings in the ith history request parameter set.
Optionally, in this embodiment, the method may include, but is not limited to, traversing a plurality of acquired history request parameter sets, removing a value corresponding to each parameter in an ith history request parameter set, serializing a name corresponding to each parameter in the ith history request parameter set to obtain a corresponding ith character string, and determining that the ith sub-parameter set is combined as a parameter corresponding to the same sub-character string in the ith history request parameter set by comparing whether the ith character string is the same as a target character string corresponding to the first request parameter set or not, if the comparison result indicates that the ith character string is the same, where the ith character string is the same as the target character string corresponding to the first request parameter set.
For example, the ith history request parameter set in the plurality of history request parameter sets includes (parameters a, B, C), the obtained first request parameter set is (parameters a, B, C, D), the value of the parameter A, B, C is removed first, and the parameter name is serialized into a jason string and the jason string of the first request parameter set, and the ith sub-parameter set is determined as (parameters a, B, C) when the two jason strings are the same and the interface (service, method) name is the same.
Optionally, in this embodiment, the form of the character string includes but is not limited to a jason character string, and may also include but is not limited to other forms of character strings, which may be flexibly adjusted according to actual needs.
According to the embodiment, the parameter names of the parameters in the ith historical request parameter set are serialized into the ith character string, the ith character string is compared with the target character string to obtain the identical sub-character strings in the ith character string and the target character string, the ith sub-parameter set is determined to comprise the parameters corresponding to the identical sub-character strings in the ith historical request parameter set, the parameters of the same type as those in the first request parameter set can be extracted from the historical request parameter set, and therefore the technical effects of improving the generation efficiency of the test data, reducing the construction cost of the test parameters and expanding the application range of the test data can be achieved, and the technical problem that the generation efficiency of the test data in the related technology is low is solved.
As an optional solution, determining a request parameter matching a request parameter in the first request parameter set according to the N sub-parameter sets includes:
s1, determining a target historical request parameter set from the N historical request parameter sets according to the number of the parameters in each sub-parameter set;
s2, according to the target historical request parameter set, determining the request parameters matched with the request parameters in the first request parameter set.
Optionally, in this embodiment, the determining the target history request parameter set from the N history request parameter sets according to the number of the parameters in each sub-parameter set may include, but is not limited to, reconstructing to generate a new history request parameter set as the target history request parameter set according to the number of the parameters in each sub-parameter set from the N history request parameter sets.
Optionally, in this embodiment, after determining a target history request parameter set from the N history request parameter sets according to the number of parameters in each sub-parameter set, and determining a request parameter matching the request parameter in the first request parameter set according to the target history request parameter set, the method may further include, but is not limited to, using the target history parameter set to obtain a value of the parameter, and assigning the value to the request parameter in the first request parameter set, and after using the target history parameter set, the target history parameter set may be stored again in a predetermined database as history request information for use next time.
Optionally, in this embodiment, the determining, according to the number of parameters in each sub-parameter set, a target history request parameter set from the N history request parameter sets may include, but is not limited to, determining the number of parameters in each sub-parameter set, determining a history request parameter set corresponding to a sub-parameter set with the largest number of parameters in each sub-parameter set as an optimal history request parameter set, or scoring each history request parameter set according to the number of parameters in each sub-parameter set, so as to obtain an optimal history request parameter set or sets.
According to the embodiment, the target historical request parameter set is determined from the N historical request parameter sets according to the number of the parameters in each sub-parameter set, the request parameters matched with the request parameters in the first request parameter set are determined according to the target historical request parameter set, the required target historical parameter set can be generated according to the number of the parameters in the sub-parameter set, and therefore the technical effects of improving the generation efficiency of the test data, reducing the construction cost of the test parameters and expanding the application range of the test data can be achieved, and the technical problem that the generation efficiency of the test data is low in the related technology is solved.
As an optional scheme, determining a target historical request parameter set from the N historical request parameter sets according to the number of parameters in each sub-parameter set includes:
determining a target historical request parameter set from the N historical request parameter sets according to the number of parameters in each sub-parameter set;
wherein, in the N historical request parameter sets, the number of parameters in the sub-parameter set corresponding to the target historical request parameter set is the largest, or
The result of the target service request corresponding to the target historical request parameter set is success, and the number of parameters in the sub-parameter sets corresponding to the target historical request parameter set is the largest in the M historical request parameter sets in the N historical request parameter sets, wherein the result of the target service request corresponding to each historical request parameter set in the M historical request parameter sets is success, and M is less than or equal to N.
Optionally, in this embodiment, the maximum number of the parameters in the sub-parameter set is the maximum number of the parameters in the target history request parameter set that are matched with the first request parameter set.
Optionally, in this embodiment, the result that the target historical request parameter set corresponds to the requested target service is successful, and, in M historical request parameter sets in the N historical request parameter sets, the maximum number of the parameters in the sub-parameter set corresponding to the target historical request parameter set may include, but is not limited to, that the result that the target historical request parameter set corresponds to the requested target service is successful, and, in the M historical request parameter sets whose results are successful, the maximum number of the parameters matched with the first request parameter set is.
For example, fig. 5 is a flowchart illustrating an alternative test data generation method according to an embodiment of the present invention, and as shown in fig. 5, the method may include, but is not limited to, the following steps:
s502, obtaining M history request parameter sets in which a result of the corresponding request target service of each history request parameter set in the N history request parameter sets is successful (for example, it may be determined whether the history request parameter has a value, and if so, the result of the corresponding request target service of the history request parameter set is successful);
s504, acquiring a target history request parameter set with the maximum number of parameters in the sub-parameter sets corresponding to the target history request parameter set from the M history request parameter sets;
a correlation between the historical request information and a parameter model of the first set of request parameters;
s506, under the condition that the test result of the historical request information is determined to be passed and the historical request information is associated with the parameter model of the first request parameter set, the historical request information is determined to be matched with the request parameters in the first request parameter set, and the parameter values of the request parameters in the first request parameter set are determined to obtain the target test data.
In step S504, by scoring each obtained historical request information, a request parameter corresponding to the historical request information whose score exceeds a predetermined threshold is used as a parameter value of the request parameter in the first request parameter set.
It should be noted that, in the above scoring process, the type and value range of each parameter in the N pieces of history request information may also be combined by setting a weight value, so as to determine the finally required target test data.
According to the embodiment, the target historical request parameters are determined according to the number of the parameters matched with the first request parameter set in the sub-parameter set, so that the historical request parameters with the highest matching degree can be preferentially obtained, and the technical effects of improving the matching efficiency and optimizing the generation efficiency of the test data can be further achieved.
As an optional solution, determining a request parameter matching a request parameter in the first request parameter set according to the target historical request parameter set includes:
in the case that the target history request parameter set includes all request parameters in the first request parameter set, determining the request parameters matching the request parameters in the first request parameter set to be equal to all request parameters included in the target history request parameter set; and/or
Under the condition that the target historical request parameter set comprises a first part of request parameters in the first request parameter set, searching request parameters matched with a second part of request parameters in the historical request information, wherein the second part of request parameters are request parameters except the first part of request parameters in the first request parameter set; determining request parameters that match request parameters in the first set of request parameters to include: the request parameters comprise a first part of request parameters in the target historical request parameter set and searched request parameters matched with a second part of request parameters.
Optionally, in this embodiment, in the case that the target history request parameter set includes all request parameters in the first request parameter set, determining that the request parameters matching the request parameters in the first request parameter set are equal to all request parameters included in the target history request parameter set may include, but is not limited to, comparing whether the request parameters in the target history request parameter set and the request parameters in the first request parameter set are consistent, and in the case of consistency, directly determining the request parameters in the history request parameter set as the request parameters in the first request parameter set, and performing assignment correspondingly.
Optionally, in this embodiment, in the case that the target historical request parameter set includes a first part of request parameters in the first request parameter set, the searching for the request parameters matching with the second part of request parameters in the historical request information may include, but is not limited to, comparing whether the target historical request parameter set is consistent with the request parameters in the first request parameter set, in the case of inconsistency, determining a missing part in the target historical request parameter set relative to the first request parameter set, determining the missing part as the second part, and determining the consistent part as the first part.
For example, the target history request parameter set includes a parameter, a parameter B, a parameter C, and a parameter D, and the first request parameter set includes a parameter a, a parameter B, a parameter C, and a parameter E, and then the part including the parameter a, the parameter B, and the parameter C is used as the first part of request parameters, and the parameter E is used as the second part of request parameters, so as to find the request parameters matching with the second part of request parameters.
Through the embodiment, in the case that the target history request parameter set includes all request parameters in the first request parameter set, the request parameters matched with the request parameters in the first request parameter set are determined to be equal to all request parameters included in the target history request parameter set, and configuration and assignment can be performed on the parameters in the first request parameter set by using one target history request parameter set, so as to generate the required target test data, and in the case that the target history request parameter set includes the first part of request parameters in the first request parameter set, the request parameters matched with the second part of request parameters in the history request information are searched, so that in the case that configuration and assignment cannot be performed on the parameters in the first request parameter set at one time, the parameters which do not implement configuration and assignment can be continuously reconfigured and assigned from other history request parameter sets, the technical effects of improving the matching efficiency and optimizing the usability of the test data can be achieved.
As an optional solution, finding a request parameter matching the second part of request parameters in the historical request information includes:
under the condition that the second part of request parameters are one request parameter, P historical request parameter sets comprising one request parameter are determined in the N historical request parameter sets, wherein P is smaller than or equal to N; selecting one request parameter included in one historical request parameter set from the P historical request parameter sets as the request parameter matched with the second part of request parameters; and/or
In the case that the second part of request parameters are a plurality of request parameters, determining Q historical request parameter sets comprising the plurality of request parameters from the N historical request parameter sets, wherein Q is less than or equal to N; and selecting a plurality of request parameters included in one historical request parameter set from the Q historical request parameter sets as the request parameters matched with the second part of request parameters.
Optionally, in this embodiment, fig. 6 is a schematic diagram of another optional test data generation method according to an embodiment of the present invention, as shown in fig. 6, where the second part of request parameters is one request parameter, the case may include but is not limited to that a historical request parameter set 602 in the N historical request parameter sets includes an a parameter, a B parameter, a C parameter, and a D parameter, the historical request parameter set 604 includes an E parameter and an F parameter, and the historical request parameter set 606 includes an E parameter and a G parameter, and the first request parameter set 608 includes an a parameter, a B parameter, a C parameter, and an E parameter, then the part of the a parameter, the B parameter, and the C parameter included in the historical request parameter set 602 is used as the first part of request parameters, and the E parameter is used as the second part of request parameters to find out from the historical request parameter set 604 or the historical request parameter set 606 that matches the second part of request parameters Requesting parameters, and determining the history request parameter set comprising the E parameters in the N history request parameter sets as the P history request parameter sets.
In the above exemplary description, N is 3 and P is 2.
Optionally, in this embodiment, the case where the second part of request parameters are multiple request parameters may include, but is not limited to, the historical request parameter set 610 in the above N historical request parameter sets including the a parameter, the B parameter, the historical request parameter set including the C parameter and the D parameter 610, and the historical request parameter set 614 including the E parameter and the G parameter, the first request parameter set 616 includes a parameter, B parameter, C parameter, and E parameter, the historical request parameter set 610 includes the a parameter and the B parameter as the first part of request parameters, the historical request parameter set including the C parameter and the E parameter as the second part of request parameters to find the request parameters matching with the second part of request parameters, and determining the historical request parameter sets comprising the C parameter and/or the E parameter in the N historical request parameter sets as the Q historical request parameter sets.
And in the same way, when the uncompleted matching request parameters still exist, determining the historical request parameter set by taking the uncompleted matching request parameters as a new first request parameter set again to realize the parameter matching process, and determining the historical request parameter set again according to the number of the sub-parameters to generate the target test data when the number of the uncompleted matching request parameters is more than 1.
Optionally, in this embodiment, finding the request parameters matching the second part of request parameters in the historical request information may further include, but is not limited to, the following implementation:
for example, fig. 7 is a schematic diagram of another alternative test data generation method according to the embodiment of the present invention, and as shown in fig. 7, the process may include, but is not limited to, the following steps:
s702, downloading a tool;
the tool for generating the test data can be downloaded through a preset link address, and the link address is used for storing the tool for executing the method for generating the test data.
S704, initializing a configuration file;
the configuration file can be automatically generated after an operation command is automatically generated after the command is operated by a tool executing the test data generation method.
S706, inputting parameter tools such as protocol files and the like;
s708, generating test data;
the method comprises the following steps of automatically constructing output interface test data by a user input interface protocol file path and a tool through a set of intelligent FUZZ algorithm, and specifically but not limited to the following steps:
s708-1, establishing a request parameter model: after the tool receives the interface protocol file, a request parameter model is established according to a request body defined in the protocol file;
s708-2, random generation of FUZZ: combining a self-defined FUZZ rule in a protocol file, including a field value rule and a type value rule, carrying out FUZZ random generation of data in a rule range, and recursively traversing all fields of a request parameter model to complete data construction;
s708-3, accurate matching correction: taking interface protocol information, a request parameter model and parameter data generated by FUZZ as input, requesting data correction service, precisely matching reference data of the interface from a database by the data correction service, selecting a group of data with the highest comprehensive recommendation score, and correcting the generated parameter data, wherein the specific correction method can include but is not limited to traversing all fields of the request parameter model, and correcting the field data which can be matched into the reference data;
s708-4, correcting similarity matching: if the parameter data cannot be obtained through accurate matching or some fields cannot be matched, searching other similar interfaces serving the same interface through similarity, and matching public fields from the other similar interfaces, so that the data of the public fields are used for performing supplementary correction on the parameter data of the interface;
s708-5, type pool modification: the data correction service clusters field names through a clustering algorithm according to a large amount of flow data and historical test data, common field types to be determined are determined when the number of clustering nodes is larger than a threshold value, and the common field types enter a type pool, for fields in the type pool, value-taking rules can be automatically given or manually given according to the value-taking range of the field types, if some fields in the request parameter data corrected through the steps S708-3 and S708-4 are not corrected, the request parameter data can be further corrected according to the type pool, the specific correction method is that the uncorrected fields are input into the type pool, and if the fields can be matched with the corresponding classes, the data correction data are regenerated according to the value-taking rules of the corresponding classes;
s710, completing parameter construction: and outputting automatically constructed parameter data, initiating a request by using the parameter data by a user, further reporting a test result to a data correction service, if the request is successful, improving the recommendation score of the reference data, and if the request is failed, reducing the recommendation score of the reference data, thereby forming a feedback closed loop.
Optionally, in this embodiment, a request parameter model is built through an input interface protocol file, a "serial" intelligent correction algorithm is adopted, FUZZ random data is generated primarily by using the FUZZ algorithm according to a self-defined FUZZ rule in the protocol file, a data knowledge base built by using online traffic data and historical test data is used, the preliminarily generated data are corrected in sequence through the accurate matching, the similar matching and the type-related reference data, the automatic construction of the interface test data is finally completed and output to the user, the user initiates the interface test by using the parameter data, the test result is further reported to the data correction service, if the request is successful, the recommendation score of the reference data is improved, and if the request is failed, the recommendation score of the reference data is reduced to form a feedback closed loop, so that the test data is further optimized, and the efficiency and the processing result are improved.
Through the embodiment, different subsequent operations can be adopted according to the number of the second part of request parameters, and further, the technical effects of improving the generation efficiency of the test data and reducing the generation cost of the test data are achieved.
As an optional solution, the method further comprises:
and under the condition that the request parameters matched with the second part of request parameters cannot be searched in the historical request information, setting corresponding parameter values for the second part of request parameters in the first request parameter set within a preset value range.
Optionally, in this embodiment, in the case that the request parameter matching the second part of request parameters is not found in the historical request information, the assignment of the request parameter not matching in the first request parameter set may be obtained in a manner including, but not limited to, a preset value range, so that the target test data may be quickly generated, and a test failure caused by the presence of the request parameter not assigned is avoided.
As an optional scheme, determining a parameter value of a request parameter in the first request parameter set according to the found request parameter to obtain target test data, including:
and setting the parameter value of the request parameter in the first request parameter set to be equal to the parameter value of the searched request parameter.
Optionally, in this embodiment, the parameter value of the request parameter in the first request parameter set is a corresponding parameter value after matching according to the request parameter in the historical request parameter set, and all the original values of the parameters that can be matched in the historical request parameter set are valid original values, so that after the parameter value of the request parameter in the first request parameter set is set to be equal to the found parameter value of the request parameter, the value of the request parameter in the first request parameter set is also a valid value, which is convenient for completing the whole test procedure subsequently.
As an optional solution, the method further comprises: testing the request of the target service by using the target test data through the target interface; or generating a test file including the target test data; or print target test data.
Optionally, in this embodiment, after the target test data is generated, the target test data may include, but is not limited to, printing the target test data on a terminal console panel, and at the same time, automatically assembling the target test data into a json format of a homologous test standard, and outputting the json format to a specified file to implement a subsequent test flow, or providing test data for other tests.
Optionally, in this embodiment, the print target test data may include, but is not limited to, soil as a data source applied to a capcheck, LogReplay, Loki, or other test platform, and may also continue to be extended to interface more test platforms or data platforms.
The present application is further explained below with reference to specific examples:
fig. 8 is a schematic diagram of another alternative test data generation method according to an embodiment of the present invention, and as shown in fig. 8, the method may include, but is not limited to, being implemented based on the following:
and the parameter analyzer 802 is configured to analyze parameters in a command input by a user from a terminal command line, and analyze parameters in a configuration file.
And the metadata parser 804 is used for traversing and parsing the pb protocol file or the jce protocol file specified in the parameters to obtain all services and methods in the protocol file, and corresponding request structural bodies and response structural bodies, establishing a request parameter model for the request structural bodies, and generating data through a data construction engine and filling the data into the parameter model.
The data construction engine 806 is configured to search reference data with a certain correlation in a data search service background according to information in the request parameter model, perform intelligent learning on the reference data, calculate a score by combining types and value ranges of fields in the request parameter model and weights of the reference data, select data with the highest score as a parameter value, fill the parameter value into the model, perform FUZZ random generation by using a FUZZ algorithm if a valid parameter value is not learned, and recursively traverse all fields of the request parameter model to complete data generation. The data construction engine not only supports the test data generation of a single interface, but also supports the batch generation of test data of a plurality of interfaces, and can also include, but is not limited to, according to a request parameter model, a field value range defined in a protocol file and a FUZZ rule in a configuration file, recursively traverse all fields of the request parameter model to complete the data generation, then, the data construction engine uses an intelligent correction algorithm to correct data, uses the data primarily generated by the FUZZ algorithm as input, requests a data correction service of a background, accurately matches reference data in a data knowledge base, takes reference correction with the highest recommendation score, then performs similar matching, takes data with different namespaces of the same interface or different interfaces of the same service but with higher correlation, and performs supplementary correction on the uncorrected fields by using the data, and finally, correcting the type pool, namely inputting the field which is not corrected into the type pool, and correcting the value by using the value rule of the corresponding class if the classification can be hit.
The data search service 808 is used for providing an interface to search historical test data or flow request data in the database in real time, and simultaneously establishing an offline task, synchronously pulling up the latest data from a data source at regular time, pre-storing the latest data into the database or a file retrieval system after ETL (Extract-Transform-Load) processing, and preparing to provide effective parameter data for a client at any time. The data source is not limited to the CapMock, the LogRelay, the Loki and other test platforms, and can be continuously expanded and docked with more test platforms or data platforms.
A printing and output 810, which is used for printing the request parameter structure body on the terminal console panel after generating the test data, and meanwhile, automatically assembling the request parameter structure body into the json format of the homologous test standard and outputting the json format to a specified file
The reference data corresponds to the historical request parameter set, the request parameter structure corresponds to the target test data, and the request parameter model corresponds to the first request parameter set.
Optionally, in this embodiment, the generation method of the test data may also be implemented by using a golang program, where the client is a binary command line toolkit, the application framework generated based on the Cobra package is used for package development, the server is developed based on a trpc-go framework, and is deployed on a server or a cloud platform to provide an online RESTFUL API of an http protocol for searching for valid reference data.
Fig. 9 is a schematic diagram of another optional test data generation method according to an embodiment of the present invention, and as shown in fig. 9, a client workflow includes, but is not limited to, the following steps:
s902, the user uses the client to input a command for execution;
s904, analyzing the parameters, the configuration files and the protocol files to obtain all services, methods and corresponding request structural bodies and response structural bodies;
s906, selecting a corresponding mode according to the mode designated in the parameters and instantiating an object;
s908, establishing a request parameter model according to the protocol file;
s910, searching and acquiring reference data from a data search server through RESTAPI;
s912, calling a data construction engine; generating request parameter data by using an intelligent FUZZ algorithm based on the reference data;
s914, after the generation is finished, the request body is printed to a terminal console;
and S916, outputting the file to a local file.
Fig. 10 is a schematic diagram of another optional test data generation method according to an embodiment of the present invention, and as shown in fig. 10, the service-side workflow includes, but is not limited to, the following steps:
s1002, the data search micro service adopts a micro service architecture, and a client can request to a uniform access layer through an HTTP (hyper text transport protocol);
s1004, the access layer converts the data message into an RPC private protocol, and remotely calls a data search microservice through TCP communication;
s1006, the data search microservice internal program reads the database to search the relevant reference data, if the database does not search the needed reference data, the data is directly sent to the third-party data platform to search the latest data, and the latest data is synchronized to the server database, and the searched relevant reference data is returned to the client.
Optionally, in this embodiment, according to the definition of the protocol file on the interface request body, flow data and historical test data are automatically obtained from test platforms such as LogReplay, capdock, and combined with the type dereferencing rule and the field dereferencing rule, an effective request parameter is generated by assembling the intelligent FUZZ algorithm, and the following technical effects including but not limited to:
(1) the method helps developers to construct effective request parameters when debugging the interface, and reduces the cost of parameter construction;
(2) help to construct invalid and illegal request data, so as to verify the interface boundary processing logic;
(3) and during concurrent testing, more abundant and diverse parameter combinations are constructed to impact a test interface, so that the efficiency of constructing a large number of abundant and diverse parameter combinations is improved.
The method for generating the test data is not limited to the butt joint of test platforms such as LogRelay and CapMock, and can also be used for butt joint of more data platforms such as Loki and mysterious turtle data governance, and the success rate of parameter construction is improved by matching the corresponding protocol fields from the data pool with higher probability through butt joint of more data sources.
The method for generating the test data is not limited to a local command line tool, and the PAAS and plug-in capabilities of automatic parameter configuration can be realized to form an open public capability, so that more test platforms are accessed to meet the requirements of automatic parameter configuration, and the effect of improving efficiency and enabling energy is achieved.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
According to another aspect of the embodiment of the present invention, there is also provided a test data generation apparatus for implementing the above test data generation method. As shown in fig. 11, the apparatus includes:
a first obtaining module 1102, configured to obtain a first request parameter set of a target interface, where the first request parameter set is used to request a target service through the target interface of the target service;
a second obtaining module 1104, configured to obtain historical request information of the target interface, where the historical request information includes multiple historical request parameter sets of the target interface and corresponding parameter values, and each historical request parameter set is used to request the target service through the target interface;
a determining module 1106, configured to determine, according to the historical request information, a parameter value of a request parameter in the first request parameter set, to obtain target test data, where the target test data includes the first request parameter set and a corresponding parameter value, and the target test data is used to test the request of the target service through the target interface.
As an optional solution, the second obtaining module 1104 includes:
a first obtaining unit, configured to obtain historical test information of the target interface, where the historical request information includes the historical test information, the historical test information includes multiple historical test parameter sets and corresponding parameter values of the target interface, and each historical test parameter set is used to test a request of the target service through the target interface; and/or
A second obtaining unit, configured to obtain historical actual request information of the target interface, where the historical request information includes the historical actual request information, the historical actual request information includes multiple historical actual request parameter sets of the target interface and corresponding parameter values, and each of the historical actual request parameter sets is a parameter set that is actually used when the target service is requested through the target interface.
As an optional solution, the determining module 1106 includes:
a searching unit, configured to search the historical request information for a request parameter that matches a request parameter in the first request parameter set;
and the determining unit is used for determining the parameter value of the request parameter in the first request parameter set according to the searched request parameter to obtain the target test data.
As an optional solution, the searching unit is configured to search the historical request information for the request parameter that matches the request parameter in the first request parameter set by:
respectively acquiring parameters of each history request parameter set and the first request parameter set to obtain N sub-parameter sets, wherein N is the number of the history request parameter aggregates and is a natural number greater than 1, and each sub-parameter set comprises parameters of each history request parameter set and the first request parameter set;
and determining the request parameters matched with the request parameters in the first request parameter set according to the N sub-parameter sets.
As an optional scheme, the search unit is configured to obtain parameters of each of the history request parameter sets and the first request parameter set respectively in the following manners to obtain N sub-parameter sets:
obtaining an ith sub-parameter set of the N sub-parameter sets by:
serializing parameter names of parameters in the ith historical request parameter set into an ith character string;
comparing the ith character string with a target character string to obtain a sub-character string of the ith character string and the target character string which are the same, wherein the target character string is a character string formed by serializing the parameter names of the parameters in the first request parameter set;
and determining the ith sub-parameter set as parameters corresponding to the same sub-character strings in the ith historical request parameter set.
As an optional scheme, the finding unit is configured to determine, according to the N sub-parameter sets, a request parameter that matches a request parameter in the first request parameter set by:
determining a target historical request parameter set from the N historical request parameter sets according to the number of parameters in each sub-parameter set;
and determining request parameters matched with the request parameters in the first request parameter set according to the target historical request parameter set.
As an optional scheme, the apparatus is configured to determine a target historical request parameter set from the N historical request parameter sets according to the number of parameters in each of the sub-parameter sets by:
determining the target historical request parameter set from the N historical request parameter sets according to the number of parameters in each sub-parameter set;
wherein, in the N historical request parameter sets, the number of parameters in the sub-parameter set corresponding to the target historical request parameter set is the largest, or
The result of the target service request corresponding to the target historical request parameter set is success, and in M historical request parameter sets of the N historical request parameter sets, the number of parameters in the sub-parameter set corresponding to the target historical request parameter set is the largest, wherein the result of the target service request corresponding to each historical request parameter set of the M historical request parameter sets is success, and M is less than or equal to N.
As an alternative, the apparatus is configured to determine a request parameter matching a request parameter in the first request parameter set according to the target historical request parameter set by:
in the event that the target historical set of request parameters includes all of the request parameters in the first set of request parameters, determining request parameters that match the request parameters in the first set of request parameters to be equal to the all of the request parameters included in the target historical set of request parameters; and/or
Under the condition that the target historical request parameter set comprises a first part of request parameters in the first request parameter set, searching request parameters matched with a second part of request parameters in the historical request information, wherein the second part of request parameters are request parameters in the first request parameter set except the first part of request parameters; determining request parameters that match request parameters in the first set of request parameters to include: the first part of request parameters included in the target historical request parameter set and the searched request parameters matched with the second part of request parameters.
As an alternative, the apparatus is configured to search the historical request information for the request parameter matching the second part of the request parameters by:
under the condition that the second part of request parameters are one request parameter, P historical request parameter sets comprising the one request parameter are determined in the N historical request parameter sets, wherein P is smaller than or equal to N; selecting one request parameter included in one historical request parameter set from the P historical request parameter sets as the request parameter matched with the second part of request parameters; and/or
In the case that the second part of request parameters are a plurality of request parameters, determining Q historical request parameter sets comprising the plurality of request parameters in the N historical request parameter sets, wherein Q is less than or equal to N; and selecting the plurality of request parameters included in one historical request parameter set from the Q historical request parameter sets as the request parameters matched with the second part of request parameters.
As an optional solution, the apparatus is further configured to:
and under the condition that the request parameters matched with the second part of request parameters cannot be searched in the historical request information, setting corresponding parameter values for the second part of request parameters in the first request parameter set within a preset value range.
As an optional scheme, the apparatus is configured to determine a parameter value of a request parameter in the first request parameter set according to the found request parameter in the following manner, so as to obtain the target test data:
and setting the parameter value of the request parameter in the first request parameter set to be equal to the parameter value of the searched request parameter.
As an optional solution, the apparatus is further configured to: testing the request of the target service through the target interface by using the target test data; or generating a test file comprising the target test data; or printing the target test data.
According to another aspect of the embodiment of the present invention, there is also provided an electronic device for implementing the method for generating test data, where the electronic device may be the terminal device or the server shown in fig. 1. The present embodiment takes the electronic device as a server as an example for explanation. As shown in fig. 12, the electronic device comprises a memory 1202 and a processor 1204, the memory 1202 having stored therein a computer program, the processor 1204 being arranged to perform the steps of any of the above-described method embodiments by means of the computer program.
Optionally, in this embodiment, the electronic device may be located in at least one network device of a plurality of network devices of a computer network.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, acquiring a first request parameter set of a target interface, wherein the first request parameter set is used for requesting a target service through the target interface of the target service;
s2, acquiring historical request information of the target interface, wherein the historical request information comprises a plurality of historical request parameter sets and corresponding parameter values of the target interface, and each historical request parameter set is used for requesting a target service through the target interface;
and S3, determining parameter values of request parameters in the first request parameter set according to the historical request information to obtain target test data, wherein the target test data comprises the first request parameter set and corresponding parameter values, and the target test data is used for testing a request of a target service through a target interface.
Alternatively, it can be understood by those skilled in the art that the structure shown in fig. 12 is only an illustration, and the electronic device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 12 is a diagram illustrating a structure of the electronic device. For example, the electronics may also include more or fewer components (e.g., network interfaces, etc.) than shown in FIG. 12, or have a different configuration than shown in FIG. 12.
The memory 1202 may be used to store software programs and modules, such as program instructions/modules corresponding to the method and apparatus for generating test data in the embodiment of the present invention, and the processor 1204 executes various functional applications and data processing by running the software programs and modules stored in the memory 1202, that is, implements the method for generating test data described above. The memory 1202 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 1202 can further include memory located remotely from the processor 1204, which can be connected to a terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof. The memory 1202 may be, but is not limited to, specifically used for parameter sets and information such as request messages. As an example, as shown in fig. 12, the memory 1202 may include, but is not limited to, a first obtaining module 1102, a second obtaining module 1104, and a determining module 1106 in the generating device of the test data. In addition, the test data generating apparatus may further include, but is not limited to, other module units in the test data generating apparatus, which is not described in detail in this example.
Optionally, the transmitting device 1206 is configured to receive or transmit data via a network. Examples of the network may include a wired network and a wireless network. In one example, the transmitting device 1206 includes a Network adapter (NIC) that can be connected to a router via a Network cable to communicate with the internet or a local area Network. In one example, the transmitting device 1206 is a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
In addition, the electronic device further includes: a display 1208, configured to display the test data; and a connection bus 1210 for connecting the respective module parts in the above-described electronic apparatus.
In other embodiments, the terminal device or the server may be a node in a distributed system, where the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting a plurality of nodes through a network communication. Nodes can form a Peer-To-Peer (P2P, Peer To Peer) network, and any type of computing device, such as a server, a terminal, and other electronic devices, can become a node in the blockchain system by joining the Peer-To-Peer network.
According to an aspect of the application, a computer program product or computer program is provided, comprising computer instructions, the computer instructions being stored in a computer readable storage medium. The computer program may be configured to cause a processor of a computer device to read the computer instructions from a computer readable storage medium, the processor executing the computer instructions to cause the computer device to perform the method of generating test data provided in the various alternative implementations of the aspects of generating test data described above, wherein the computer program is arranged to perform the steps in any one of the method embodiments described above when executed.
Alternatively, in the present embodiment, the above-mentioned computer-readable storage medium may be configured to store a computer program for executing the steps of:
s1, acquiring a first request parameter set of a target interface, wherein the first request parameter set is used for requesting a target service through the target interface of the target service;
s2, acquiring historical request information of the target interface, wherein the historical request information comprises a plurality of historical request parameter sets and corresponding parameter values of the target interface, and each historical request parameter set is used for requesting a target service through the target interface;
and S3, determining parameter values of request parameters in the first request parameter set according to the historical request information to obtain target test data, wherein the target test data comprises the first request parameter set and corresponding parameter values, and the target test data is used for testing a request of a target service through a target interface.
Alternatively, in this embodiment, a person skilled in the art may understand that all or part of the steps in the methods of the foregoing embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing one or more computer devices (which may be personal computers, servers, network devices, etc.) to execute all or part of the steps of the method according to the embodiments of the present invention.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed 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 units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (15)

1. A method for generating test data, comprising:
acquiring a first request parameter set of a target interface, wherein the first request parameter set is used for requesting a target service through the target interface of the target service;
acquiring historical request information of the target interface, wherein the historical request information comprises a plurality of historical request parameter sets and corresponding parameter values of the target interface, and each historical request parameter set is used for requesting the target service through the target interface;
and determining a parameter value of a request parameter in the first request parameter set according to the historical request information to obtain target test data, wherein the target test data comprises the first request parameter set and a corresponding parameter value, and the target test data is used for testing the request of the target service through the target interface.
2. The method of claim 1, wherein the obtaining historical request information of the target interface comprises:
acquiring historical test information of the target interface, wherein the historical request information comprises the historical test information, the historical test information comprises a plurality of historical test parameter sets and corresponding parameter values of the target interface, and each historical test parameter set is used for testing the request of the target service through the target interface; and/or
Acquiring historical actual request information of the target interface, wherein the historical request information comprises the historical actual request information, the historical actual request information comprises a plurality of historical actual request parameter sets of the target interface and corresponding parameter values, and each historical actual request parameter set is combined into a parameter set which is actually used when the target interface requests the target service.
3. The method of claim 1, wherein the determining, according to the historical request information, a parameter value of a request parameter in the first request parameter set to obtain target test data comprises:
searching request parameters matched with the request parameters in the first request parameter set in the historical request information;
and determining the parameter value of the request parameter in the first request parameter set according to the searched request parameter to obtain the target test data.
4. The method of claim 3, wherein the searching for the request parameter matching the request parameter in the first set of request parameters in the historical request information comprises:
respectively acquiring parameters of each history request parameter set and the first request parameter set to obtain N sub-parameter sets, wherein N is the number of the history request parameter aggregates and is a natural number greater than 1, and each sub-parameter set comprises parameters of each history request parameter set and the first request parameter set;
and determining the request parameters matched with the request parameters in the first request parameter set according to the N sub-parameter sets.
5. The method according to claim 4, wherein the obtaining parameters of each of the historical request parameter set and the first request parameter set respectively to obtain N sub-parameter sets comprises:
obtaining an ith sub-parameter set of the N sub-parameter sets by:
serializing parameter names of parameters in the ith historical request parameter set into an ith character string;
comparing the ith character string with a target character string to obtain a sub-character string of the ith character string and the target character string which are the same, wherein the target character string is a character string formed by serializing the parameter names of the parameters in the first request parameter set;
and determining the ith sub-parameter set as parameters corresponding to the same sub-character strings in the ith historical request parameter set.
6. The method of claim 4, wherein the determining the request parameters matching the request parameters in the first request parameter set according to the N sub-parameter sets comprises:
determining a target historical request parameter set from the N historical request parameter sets according to the number of parameters in each sub-parameter set;
and determining request parameters matched with the request parameters in the first request parameter set according to the target historical request parameter set.
7. The method of claim 6, wherein determining a target historical request parameter set from the N historical request parameter sets according to the number of parameters in each of the sub-parameter sets comprises:
determining the target historical request parameter set from the N historical request parameter sets according to the number of parameters in each sub-parameter set;
wherein, in the N historical request parameter sets, the number of parameters in the sub-parameter set corresponding to the target historical request parameter set is the largest, or
The result of the target service request corresponding to the target historical request parameter set is success, and in M historical request parameter sets of the N historical request parameter sets, the number of parameters in the sub-parameter set corresponding to the target historical request parameter set is the largest, wherein the result of the target service request corresponding to each historical request parameter set of the M historical request parameter sets is success, and M is less than or equal to N.
8. The method of claim 6, wherein determining the request parameters that match the request parameters in the first set of request parameters according to the target historical set of request parameters comprises:
in the event that the target historical set of request parameters includes all of the request parameters in the first set of request parameters, determining request parameters that match the request parameters in the first set of request parameters to be equal to the all of the request parameters included in the target historical set of request parameters; and/or
Under the condition that the target historical request parameter set comprises a first part of request parameters in the first request parameter set, searching request parameters matched with a second part of request parameters in the historical request information, wherein the second part of request parameters are request parameters in the first request parameter set except the first part of request parameters; determining request parameters that match request parameters in the first set of request parameters to include: the first part of request parameters included in the target historical request parameter set and the searched request parameters matched with the second part of request parameters.
9. The method of claim 8, wherein the searching for the request parameter matching the second partial request parameter in the historical request information comprises:
under the condition that the second part of request parameters are one request parameter, P historical request parameter sets comprising the one request parameter are determined in the N historical request parameter sets, wherein P is smaller than or equal to N; selecting one request parameter included in one historical request parameter set from the P historical request parameter sets as the request parameter matched with the second part of request parameters; and/or
In the case that the second part of request parameters are a plurality of request parameters, determining Q historical request parameter sets comprising the plurality of request parameters in the N historical request parameter sets, wherein Q is less than or equal to N; and selecting the plurality of request parameters included in one historical request parameter set from the Q historical request parameter sets as the request parameters matched with the second part of request parameters.
10. The method of claim 8, further comprising:
and under the condition that the request parameters matched with the second part of request parameters cannot be searched in the historical request information, setting corresponding parameter values for the second part of request parameters in the first request parameter set within a preset value range.
11. The method according to claim 3, wherein the determining a parameter value of a request parameter in the first request parameter set according to the found request parameter to obtain the target test data includes:
and setting the parameter value of the request parameter in the first request parameter set to be equal to the parameter value of the searched request parameter.
12. The method according to any one of claims 1 to 11, further comprising at least one of:
testing the request of the target service through the target interface by using the target test data;
generating a test file comprising the target test data;
and printing the target test data.
13. An apparatus for generating test data, comprising:
a first obtaining module, configured to obtain a first request parameter set of a target interface, where the first request parameter set is used to request a target service through the target interface of the target service;
a second obtaining module, configured to obtain historical request information of the target interface, where the historical request information includes multiple historical request parameter sets of the target interface and corresponding parameter values, and each historical request parameter set is used to request the target service through the target interface;
a determining module, configured to determine, according to the historical request information, a parameter value of a request parameter in the first request parameter set, to obtain target test data, where the target test data includes the first request parameter set and a corresponding parameter value, and the target test data is used to test a request of the target service through the target interface.
14. A computer-readable storage medium, characterized in that it comprises a stored program, wherein the program is executable by a terminal device or a computer to perform the method of any one of claims 1 to 12.
15. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 12 by means of the computer program.
CN202011401768.1A 2020-12-03 2020-12-03 Test data generation method and device, storage medium and electronic equipment Pending CN113391992A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011401768.1A CN113391992A (en) 2020-12-03 2020-12-03 Test data generation method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011401768.1A CN113391992A (en) 2020-12-03 2020-12-03 Test data generation method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN113391992A true CN113391992A (en) 2021-09-14

Family

ID=77616607

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011401768.1A Pending CN113391992A (en) 2020-12-03 2020-12-03 Test data generation method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN113391992A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114218069A (en) * 2021-11-16 2022-03-22 北京百度网讯科技有限公司 Regression testing method, device, electronic equipment and storage medium
CN114860575A (en) * 2022-03-31 2022-08-05 中国电信股份有限公司 Test data generation method and device, storage medium and electronic equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114218069A (en) * 2021-11-16 2022-03-22 北京百度网讯科技有限公司 Regression testing method, device, electronic equipment and storage medium
US11669672B1 (en) 2021-11-16 2023-06-06 Beijing Baidu Netcom Science Technology Co., Ltd. Regression test method, electronic device and storage medium
CN114860575A (en) * 2022-03-31 2022-08-05 中国电信股份有限公司 Test data generation method and device, storage medium and electronic equipment
CN114860575B (en) * 2022-03-31 2023-10-03 中国电信股份有限公司 Test data generation method and device, storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN110597991B (en) Text classification method and device, computer equipment and storage medium
US20210073527A1 (en) Multi-person pose recognition method and apparatus, electronic device, and storage medium
US11907675B2 (en) Generating training datasets for training neural networks
US20080159622A1 (en) Target object recognition in images and video
JP2019514117A (en) System and method for searching and matching content across social networks associated with an individual
CN115064020B (en) Intelligent teaching method, system and storage medium based on digital twin technology
CN103678637A (en) Method and device for acquiring test question information
CN113391992A (en) Test data generation method and device, storage medium and electronic equipment
CN109783624A (en) Answer generation method, device and the intelligent conversational system in knowledge based library
CN113392270A (en) Video processing method, video processing device, computer equipment and storage medium
CN111401193B (en) Method and device for acquiring expression recognition model, and expression recognition method and device
CN110427864B (en) Image processing method and device and electronic equipment
CN114398973B (en) Media content tag identification method, device, equipment and storage medium
CN113705276A (en) Model construction method, model construction device, computer apparatus, and medium
KR20190109669A (en) Artificial intelligence based part search system
CN113822114A (en) Image processing method, related equipment and computer readable storage medium
CN108959488A (en) Safeguard the method and device of Question-Answering Model
CN111651989B (en) Named entity recognition method and device, storage medium and electronic device
CN110516153B (en) Intelligent video pushing method and device, storage medium and electronic device
CN114531334A (en) Intention processing method and device, electronic equipment and readable storage medium
CN107733709A (en) Date storage method, device and electronic equipment
CN110585730A (en) Rhythm sensing method and device for game and related equipment
CN113239190B (en) Document classification method, device, storage medium and electronic equipment
CN113822790B (en) Image processing method, device, equipment and computer readable storage medium
CN115328786A (en) Automatic testing method and device based on block chain and storage medium

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