Nothing Special   »   [go: up one dir, main page]

CN113342353B - Mock data generation method and device - Google Patents

Mock data generation method and device Download PDF

Info

Publication number
CN113342353B
CN113342353B CN202110749141.3A CN202110749141A CN113342353B CN 113342353 B CN113342353 B CN 113342353B CN 202110749141 A CN202110749141 A CN 202110749141A CN 113342353 B CN113342353 B CN 113342353B
Authority
CN
China
Prior art keywords
target
function
mock data
custom function
mock
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.)
Active
Application number
CN202110749141.3A
Other languages
Chinese (zh)
Other versions
CN113342353A (en
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.)
China Ums Co ltd
Original Assignee
China Ums 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 China Ums Co ltd filed Critical China Ums Co ltd
Priority to CN202110749141.3A priority Critical patent/CN113342353B/en
Publication of CN113342353A publication Critical patent/CN113342353A/en
Application granted granted Critical
Publication of CN113342353B publication Critical patent/CN113342353B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a mock data generation method and device, wherein the method comprises the following steps: receiving a mock data acquisition request initiated by a service system, determining a target response template according to the mock data acquisition request, generating mock data according to the target response template, and transmitting the generated mock data to the service system. The mock data generating method and the mock data generating device can generate the mock data capable of simulating the logic of the third party system and send the generated mock data to the service system, so that the service system is developed and tested based on the generated mock data, and the development and test efficiency of the service system is improved.

Description

Mock data generation method and device
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a mock data generating method and apparatus.
Background
When the service system is developed and tested, the service system can be in butt joint with a third party system so as to develop and test the service system through normal logic and abnormal logic generated by the third party system.
However, the third party system is uncontrollable, so that the development and test efficiency of the service system are low, for example, the third party system has no test environment, or the third party system has not developed corresponding functions, or the third party system has difficulty in simulating some abnormal logic, so that the development and test of the service system are blocked, and the efficiency is low.
The inter-system decoupling sum can be realized by means of the mock means, namely, the business system is developed and tested through mock data capable of simulating normal logic and abnormal logic of the third party system, but no generation method of the mock data capable of simulating the normal logic and the abnormal logic of the third party system exists at present.
Disclosure of Invention
In view of this, the present application provides a method and apparatus for generating mock data, which are used for generating mock data capable of simulating logic of a third party system, and the technical scheme is as follows:
a mock data generation method comprising:
receiving a mock data acquisition request initiated by a service system, wherein the mock data acquisition request is used for requesting mock data capable of simulating logic of a third party system;
determining a target response template according to the mock data acquisition request, wherein the target response template comprises information for generating an objective function capable of simulating mock data of logic of a third party system and/or at least part of fields in the mock data acquisition request;
and generating mock data according to the target response template, and sending the generated mock data to a service system.
Optionally, determining the target response template according to the mock data acquisition request includes:
and determining a response template corresponding to the mock data acquisition request as a target response template according to the mock data acquisition request and the corresponding relation between the pre-established request and the response template.
Optionally, receiving a mock data acquisition request initiated by the service system includes:
and receiving a mock data acquisition request initiated by the service system through the specific mock port, wherein the corresponding relation between the request and the response template is positioned in a mock service initiated by the user through the specific mock port.
Optionally, the target function is a target custom function, the information of the target function includes a function name and a parameter value of the target custom function, and the target custom function is a custom function which is written based on logic of a third party system and can return mock data.
Optionally, the target response template includes information of a target custom function, and generating mock data according to the target response template includes:
calling the target custom function according to the function name and the parameter value of the target custom function;
transmitting the parameter value of the target custom function to obtain a return value of the target custom function;
and filling the target response template based on the returned value, and generating mock data.
Optionally, calling the target custom function according to the function name and the parameter value of the target custom function, including:
determining an API interface corresponding to the target custom function according to the function name and the parameter value of the target custom function and the corresponding relation between the function name and the parameter of the custom function and the API interface corresponding to the custom function, wherein the API interface corresponding to each custom function in the corresponding relation is determined according to the function name and the parameter of the custom function, the function name and the parameter of the custom function are obtained by carrying out reflection analysis on a target class corresponding to the custom function, and the target class is obtained by compiling and loading source codes of the custom function;
and calling the target custom function based on the API interface corresponding to the target custom function.
A mock data generating device comprising: the device comprises a request receiving module, a target response template determining module, a mock data generating module and a mock data transmitting module;
the request receiving module is used for receiving a mock data acquisition request initiated by the service system, wherein the mock data acquisition request is used for requesting mock data capable of simulating logic of the third party system;
a target response template determination module for determining a target response template according to the mock data acquisition request, wherein the target response template comprises information for generating a target function of mock data capable of simulating logic of a third party system and/or at least part of fields in the mock data acquisition request;
the mock data generation module is used for generating mock data according to the target response template;
and the mock data sending module is used for sending the generated mock data to the service system.
Optionally, the target response template determining module is specifically configured to determine, as the target response template, a response template corresponding to the mock data acquisition request according to the mock data acquisition request and a corresponding relationship between the pre-established request and the response template.
Optionally, the target function is a target custom function, the information of the target function includes a function name and a parameter value of the target custom function, and the target custom function is a custom function which is written based on logic of a third party system and can return mock data.
Optionally, when the target response template includes information of the target custom function, the mock data generating module includes: the function call module, the function return value determining module and the mock data generating sub-module;
the function calling module is used for calling the target custom function according to the function name and the parameter value of the target custom function;
the function return value determining module is used for transmitting the parameter value of the target custom function to the target custom function so as to obtain the return value of the target custom function;
and the mock data generation sub-module is used for filling the target response template based on the return value and generating mock data.
According to the technical scheme, the mock data generation method provided by the application comprises the steps of firstly receiving a mock data acquisition request initiated by a service system, then determining a target response template according to the mock data acquisition request, finally generating mock data according to the target response template, and sending the generated mock data to the service system. The mock data generation method provided by the invention can generate the mock data which can simulate the logic of the third party system, and send the generated mock data to the service system, so that the service system is developed and tested based on the generated mock data, and the development and test efficiency of the service system are improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings may be obtained according to the provided drawings without inventive effort to a person skilled in the art.
Fig. 1 is a flow chart of a mock data generating method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a mock rule according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a mock data generating device according to an embodiment of the present application;
fig. 4 is a hardware structure block diagram of the mock data generating device provided in the embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
In view of the fact that there is no generation method of mock data capable of simulating the logic of the third party system, the inventor of the present application conducted intensive research and finally proposed a generation method of mock data, which can be applied to a mock system, and by docking the mock system with a service system, mock data capable of simulating the logic of the third party system generated by the mock system can be sent to the service system for development and testing of the service system. Next, the mock data generating method provided in the present application will be described in detail through the following embodiments.
Referring to fig. 1, a flow chart of a mock data generating method provided in an embodiment of the present application is shown, where the method may include:
step S10, a mock data acquisition request initiated by a service system is received.
Wherein the mock data acquisition request is for requesting mock data capable of emulating logic of a third party system.
When the service system is developed and tested, if mock data capable of simulating the logic of the third party system is required to be used, a mock data acquisition request can be initiated to the mock system, and optionally, the service system can initiate the mock data acquisition request through a specific mock port.
And S11, determining a target response template according to the mock data acquisition request.
Wherein the target response template comprises information for generating an objective function capable of modeling mock data of the logic of the third party system and/or at least part of fields in a mock data acquisition request.
It should be noted that, the user may input a plurality of mock rules in advance, and then start the mock service at a specific mock port, so that the mock service includes a plurality of mock rules input by the user.
In an alternative embodiment, the mock rule includes a correspondence between the request and the response template, and in this regard, the response template corresponding to the mock data acquisition request may be determined as the target response template according to the mock data acquisition request and the correspondence between the request and the response template.
Optionally, the specific implementation form of the correspondence between the request and the response template may be a request path, a request format, a request method, a correspondence between fields in the request and the response template, so that the step needs to determine the format of the mock data acquisition request, then analyze the mock data acquisition request based on information such as an analysis rule corresponding to the format of the mock data acquisition request, to obtain the fields in the mock data acquisition request, and then match the request path of the mock data acquisition request, the format of the mock data acquisition request, a request method of the mock data acquisition request, the fields in the mock data acquisition request with the correspondence between each request and the response template one by one, so as to obtain the target response template corresponding to the mock data acquisition request.
Referring to one of the mock rules shown in fig. 2, if the format of the mock data acquisition request is json and the path of the mock data acquisition request is/debug and the body- > transType field of the mock data acquisition request is equal to CC, it is determined that the mock data acquisition request matches the mock rule successfully, then the target response template is the response template shown in the return body part of fig. 2, and it can be seen that the target response template includes information for generating a test function of the mock data capable of emulating the logic of the third party system and the transType field in the mock data acquisition request.
Of course, in this embodiment, the specific implementation form of the correspondence between the request and the response template is not limited to the correspondence between the request path, the request format, the request method, the fields in the request and the response template, but may be other correspondence between the fields, such as the request header and the request body, of the request and the response template.
It should be further noted that, the mock system in this embodiment may parse the mock data acquisition requests in various formats, for example, the mock system supports http, https, tcp, iso8583 protocol, and supports the mock data acquisition requests in xml, json, separator message, etc., so the solution is more universal.
And step S12, generating mock data according to the target response template, and sending the generated mock data to the service system.
This step may generate mock data from the target response template. Specifically, if the target response template includes information of the target function but does not include a field in the mock data acquisition request, the target function may be called according to the information of the target function, and mock data may be generated based on a return value of the called target function. Referring to fig. 2, if the target response template includes information of the test function but does not include a field in the mock data acquisition request (i.e., includes only the second line of data but does not include the third line of data shown in the return body portion of fig. 2), the mock data may be generated based on the return value of the called test function.
If the target response template includes at least a portion of the fields in the mock data acquisition request but does not include information of the target function, generating mock data based on at least a portion of the fields in the mock data acquisition request. Referring to fig. 2, if the target response template includes a transType field in the mock data acquisition request but does not include information of the target function (i.e., includes only the third line of data but does not include the second line of data shown in the return body portion of fig. 2), the mock data is generated based on the transType field in the mock data acquisition request.
If the target response template includes information of the target function and at least a portion of fields in the mock data acquisition request, generating mock data based on the return value of the target function and at least a portion of fields in the mock data acquisition request. Referring to fig. 2, if the target response template includes information of the test function and a transType field in the mock data acquisition request (i.e., includes both the second line of data and the third line of data shown in the returned body portion of fig. 2), then mock data is generated based on the returned value of the test function and the transType field in the mock data acquisition request.
The step sends the generated mock data to the service system, and in fact assembles a return message based on the generated mock data, and sends the return message to the service system. Specifically, if the target response template includes information of the target function but does not include a field in the mock data acquisition request, assembling a return message based on a return value of the target function, and sending the return message to the service system; if the target response template only comprises at least part of fields in the mock data acquisition request but does not comprise information of the target function, assembling a return message based on at least part of fields in the mock data acquisition request, and sending the return message to the service system; if the target response template comprises the information of the target function and at least part of fields in the mock data acquisition request, a return message is assembled based on the return value of the target function and at least part of fields in the mock data acquisition request, and the return message is sent to the service system.
It should be noted that, the target custom function of this embodiment may return dynamic mock data, or may return static mock data, and the dynamic mock data may be obtained according to at least some fields in the mock data obtaining request, so this embodiment is more versatile.
According to the mock data generation method, a mock data acquisition request initiated by a service system is received, a target response template is determined according to the mock data acquisition request, mock data is generated according to the target response template, and the generated mock data is sent to the service system. The mock data generation method provided by the invention can generate the mock data which can simulate the logic of the third party system, and send the generated mock data to the service system, so that the service system is developed and tested based on the generated mock data, and the development and test efficiency of the service system are improved.
In an alternative embodiment, the present embodiment may develop a general custom function on a mock system, so that a user may implement a dynamic compiling and dynamic loading process of the custom function on the mock system, specifically, the present embodiment allows the user to write source codes (for example, java codes) of the custom function capable of simulating mock data of logic of a third party system based on logic of the third party system on the mock system, and upload the dependency package of the source codes to the mock system when a dependency package is needed to be used (the requirement of the custom function for different service systems may upload different dependency packages, which is not specifically limited in this application), and then the user may trigger the mock system to compile, generate a byte code file (.class file), and load the byte codes into a memory, so as to obtain a target class (Java class) corresponding to the custom function.
The embodiment also realizes a custom function management module to manage the target class corresponding to each custom function written by the user, and the custom function can be searched by the custom function management module and also can be called. Optionally, the embodiment may perform reflection analysis on the target class corresponding to the custom function in the custom function management module, obtain a function name and a parameter of the custom function (the parameter is a shape parameter of the custom function), and then set an API interface corresponding to the custom function based on the obtained function name and parameter of the custom function and expose the set API interface, so that when the mock system needs to generate mock data based on the custom function, call of the custom function can be implemented based on the API interface.
Based on the above description, the objective function in the present embodiment may be an objective custom function, and the information of the objective function in step S11 may be a function name and a parameter value of the objective custom function (the parameter value is a real parameter of the objective custom function, and the real parameter is associated with a shape parameter of the custom function, it may be understood that the related information of the real parameter and the shape parameter are consistent, for example, the shape parameter and the real parameter of a custom function are the same, and the parameter types are the same).
In order to make the process of generating mock data based on the target custom function more understood by those skilled in the art, the process of generating mock data according to the target response template in step S12 will be described in detail below, taking the information that the target response template includes the target custom function as an example.
In this embodiment, step S12 may call, by a template engine of the universal mock system, a target custom function corresponding to the target response template to obtain mock data, and based on this, optionally, the process of generating the mock data according to the target response template in step S12 may include:
step S121, calling the target custom function according to the function name and the parameter value of the target custom function.
It will be appreciated that at least one of the function names and parameters of different custom functions are different, for example, the function names of two custom functions are different, but the number of parameters and the type of parameters are the same, for example, the function names of two custom functions are the same, but the number of parameters are different, for example, the function names of two custom functions and the number of parameters are the same, but the type of parameters are different. Therefore, the target custom function in the custom function management module can be searched and called according to the function name and the parameter value of the target custom function contained in the target response template.
Optionally, in this embodiment, the API interface corresponding to the custom function may be set based on the function name and the parameter of the custom function, so when the target custom function is called according to the function name and the parameter value of the target custom function, the API interface corresponding to the target custom function may be determined specifically according to the function name and the parameter value of the target custom function, and then the target custom function is called based on the API interface corresponding to the target custom function.
The corresponding relation between the function name and the parameter of the custom function and the API interface corresponding to the custom function can be pre-established in the mock system, so that when the API interface corresponding to the target custom function is determined according to the function name and the parameter value of the target custom function, the API interface corresponding to the target custom function can be determined according to the function name and the parameter value of the target custom function and the corresponding relation between the function name and the parameter of the pre-established custom function and the API interface corresponding to the custom function.
Step S122, the parameter value of the target custom function is transferred to the target custom function to obtain the return value of the target custom function.
And step S123, filling the target response template based on the return value, and generating mock data.
Specifically, if the target response template includes information of the target custom function but does not include a field in the mock data acquisition request, the target response template may be populated based on a return value of the target custom function to generate mock data.
If the target response template includes information of the target custom function and at least a portion of fields in the mock data acquisition request, the mock data may be generated based on the return value of the target custom function and the at least a portion of fields in the mock data acquisition request to populate the target response template.
For example, if the mock data acquisition request is a signature request, the target response template may be determined according to the signature request, and a target custom function in the target response template may be called to complete the signature logic, and the target response template may be filled in based on the signature field returned by the target custom function, so as to generate dynamic mock data.
According to the embodiment, the custom function is developed in the mock system, and the custom function management module is realized, so that a user can develop a plurality of custom functions in the mock system based on the logic of the third party system, after the dynamic compiling and dynamic loading flow of the custom functions are executed, the call of the custom functions can be realized through the general template engine, and the target response template is filled based on the return value of the custom functions, so that dynamic mock data is generated, and the method is more general.
In addition, the dynamic compiling and dynamic loading process of the custom function and the call process of the custom function (i.e. step S12) can run in different threads and are mutually independent, so that the two processes can run in parallel, all operations in the dynamic compiling and dynamic loading process of the custom function can be performed and modified in the running process, namely, the mock system modifies the web page of the mock system for the custom function in the running process, and then compiling, loading and reflection analysis are performed again, thereby realizing the update of the logic of the custom function, restarting the mock system in the modification process is not needed, thereby not affecting the business continuity of the mock system, and the development and test efficiency of the business system is also improved.
The embodiment of the application also provides a mock data generating device, which is described below, and the mock data generating device described below and the mock data generating method described above can be referred to correspondingly.
Referring to fig. 3, a schematic structural diagram of a mock data generating device provided in an embodiment of the present application is shown, and as shown in fig. 3, the mock data generating device may include: a request receiving module 31, a target response template determining module 32, a mock data generating module 33 and a mock data transmitting module 34.
The request receiving module 31 is configured to receive a mock data acquisition request initiated by the service system, where the mock data acquisition request is used for requesting mock data capable of simulating logic of the third party system.
A target response template determination module 32 for determining a target response template from the mock data acquisition request, wherein the target response template comprises information for generating a target function capable of emulating mock data of logic of a third party system and/or at least part of fields in the mock data acquisition request.
And the mock data generating module 33 is configured to generate mock data according to the target response template.
And the mock data sending module 34 is configured to send the generated mock data to the service system.
The mock data generating device provided by the application firstly receives a mock data acquisition request initiated by a service system, then determines a target response template according to the mock data acquisition request, finally generates mock data according to the target response template, and sends the generated mock data to the service system. The mock data generating device provided by the application can generate the mock data capable of simulating the logic of the third-party system and send the generated mock data to the service system so as to develop and test the service system based on the generated mock data, thereby improving the development and test efficiency of the service system.
In one possible implementation manner, the target response template determining module 32 may be specifically configured to determine, as the target response template, a response template corresponding to the mock data acquisition request according to the mock data acquisition request and a pre-established correspondence between the request and the response template.
In a possible implementation manner, the request receiving module 31 may be specifically configured to receive a mock data acquisition request initiated by a service system through a specific mock port, where a correspondence between a request and a response template is located in a mock service initiated by a user through the specific mock port.
In one possible implementation manner, the objective function in the objective response template determining module 32 may be an objective custom function, where the information of the objective function may include a function name and a parameter value of the objective custom function, and the objective custom function is a custom function written based on logic of a third party system and capable of returning mock data.
In one possible implementation manner, if the target response template includes information of a target custom function, the mock data generating module may include: the system comprises a function calling module, a function return value determining module and a mock data generating sub-module.
And the function calling module is used for calling the target custom function according to the function name and the parameter value of the target custom function.
And the function return value determining module is used for transmitting the parameter value of the target custom function to the target custom function so as to obtain the return value of the target custom function.
And the mock data generation sub-module is used for filling the target response template based on the return value and generating mock data.
In one possible implementation manner, the function calling module may include: the API interface determination module and the function call sub-module.
The API interface determining module is used for determining the API interface corresponding to the target custom function according to the function name and the parameter value of the target custom function and the corresponding relation between the function name and the parameter of the custom function and the API interface corresponding to the custom function, wherein the API interface corresponding to each custom function in the corresponding relation is determined according to the function name and the parameter of the custom function, the function name and the parameter of the custom function are obtained by carrying out reflection analysis on the target class corresponding to the custom function, and the target class is obtained by compiling and loading the source code of the custom function.
And the function calling sub-module is used for calling the target custom function based on the API interface corresponding to the target custom function.
The embodiment of the application also provides a mock data generation device. Alternatively, fig. 4 shows a block diagram of a hardware structure of the mock data generating apparatus, and referring to fig. 4, the hardware structure of the mock data generating apparatus may include: at least one processor 401, at least one communication interface 402, at least one memory 403, and at least one communication bus 404;
in the embodiment of the present application, the number of the processor 401, the communication interface 402, the memory 403 and the communication bus 404 is at least one, and the processor 401, the communication interface 402 and the memory 403 complete communication with each other through the communication bus 404;
processor 401 may be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement embodiments of the present invention, etc.;
the memory 403 may include a high-speed RAM memory, and may further include a non-volatile memory (non-volatile memory), etc., such as at least one magnetic disk memory;
wherein the memory 403 stores a program, the processor 401 may call the program stored in the memory 403, the program being for:
receiving a mock data acquisition request initiated by a service system, wherein the mock data acquisition request is used for requesting mock data capable of simulating logic of a third party system;
determining a target response template according to the mock data acquisition request, wherein the target response template comprises information for generating an objective function capable of simulating mock data of logic of a third party system and/or at least part of fields in the mock data acquisition request;
and generating mock data according to the target response template, and sending the generated mock data to a service system.
Alternatively, the refinement function and the extension function of the program may be described with reference to the above.
The embodiment of the application also provides a readable storage medium, on which a computer program is stored, which when executed by a processor, implements the mock data generation method as described above.
Alternatively, the refinement function and the extension function of the program may be described with reference to the above.
Finally, it is further noted that relational terms such as second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (5)

1. A mock data generation method, comprising:
receiving a mock data acquisition request initiated by a service system, wherein the mock data acquisition request is used for requesting mock data capable of simulating logic of a third party system;
determining a target response template according to the mock data acquisition request, wherein the target response template comprises information for generating an objective function capable of simulating mock data of logic of the third party system and at least part of fields in the mock data acquisition request;
generating the mock data according to the target response template, and sending the generated mock data to the service system;
the target function is a target custom function, the information of the target function comprises a function name and a parameter value of the target custom function, and the target custom function is a custom function which is written based on the logic of the third party system and can return the mock data;
the target response template includes information of the target custom function, and the generating the mock data according to the target response template includes:
calling the target custom function according to the function name and the parameter value of the target custom function;
transmitting the parameter value of the target custom function to obtain a return value of the target custom function;
populating the target response template based on the return value, generating the mock data;
the calling the target custom function according to the function name and the parameter value of the target custom function comprises the following steps:
determining an API interface corresponding to the target custom function according to the function name and the parameter value of the target custom function and the corresponding relation between the function name and the parameter of the custom function and the API interface corresponding to the custom function, wherein the API interface corresponding to each custom function in the corresponding relation is determined according to the function name and the parameter of the custom function, the function name and the parameter of the custom function are obtained by carrying out reflection analysis on a target class corresponding to the custom function, and the target class is obtained by compiling and loading source codes of the custom function;
and calling the target custom function based on an API interface corresponding to the target custom function.
2. The mock data generating method of claim 1, wherein the determining a target response template according to the mock data acquisition request comprises:
and determining a response template corresponding to the mock data acquisition request as a target response template according to the mock data acquisition request and the corresponding relation between the pre-established request and the response template.
3. The mock data generating method of claim 2, wherein the receiving a mock data acquisition request initiated by a service system comprises:
receiving a mock data acquisition request initiated by a service system through a specific mock port;
the corresponding relation between the request and the response template is located in the mock service started by the user through the specific mock port.
4. A mock data generating device, comprising: the device comprises a request receiving module, a target response template determining module, a mock data generating module and a mock data transmitting module;
the request receiving module is used for receiving a mock data acquisition request initiated by the service system, wherein the mock data acquisition request is used for requesting mock data capable of simulating logic of a third party system;
the target response template determining module is used for determining a target response template according to the mock data acquisition request, wherein the target response template comprises information for generating a target function of mock data capable of simulating logic of the third party system and at least part of fields in the mock data acquisition request;
the mock data generation module is used for generating the mock data according to the target response template;
the mock data sending module is used for sending the generated mock data to the service system;
the target function is a target custom function, the information of the target function comprises a function name and a parameter value of the target custom function, and the target custom function is a custom function which is written based on the logic of the third party system and can return the mock data;
when the target response template includes information of the target custom function, the mock data generating module includes: the function call module, the function return value determining module and the mock data generating sub-module;
the function calling module is used for calling the target custom function according to the function name and the parameter value of the target custom function;
the function return value determining module is used for transmitting the parameter value of the target custom function to the target custom function so as to obtain the return value of the target custom function;
the mock data generation sub-module is used for filling the target response template based on the return value and generating the mock data;
the calling the target custom function according to the function name and the parameter value of the target custom function comprises the following steps:
determining an API interface corresponding to the target custom function according to the function name and the parameter value of the target custom function and the corresponding relation between the function name and the parameter of the custom function and the API interface corresponding to the custom function, wherein the API interface corresponding to each custom function in the corresponding relation is determined according to the function name and the parameter of the custom function, the function name and the parameter of the custom function are obtained by carrying out reflection analysis on a target class corresponding to the custom function, and the target class is obtained by compiling and loading source codes of the custom function;
and calling the target custom function based on an API interface corresponding to the target custom function.
5. The mock data generating apparatus of claim 4, wherein the target response template determining module is specifically configured to determine, as the target response template, a response template corresponding to the mock data acquisition request according to the mock data acquisition request and a correspondence between a request and a response template established in advance.
CN202110749141.3A 2021-07-01 2021-07-01 Mock data generation method and device Active CN113342353B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110749141.3A CN113342353B (en) 2021-07-01 2021-07-01 Mock data generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110749141.3A CN113342353B (en) 2021-07-01 2021-07-01 Mock data generation method and device

Publications (2)

Publication Number Publication Date
CN113342353A CN113342353A (en) 2021-09-03
CN113342353B true CN113342353B (en) 2023-05-23

Family

ID=77482290

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110749141.3A Active CN113342353B (en) 2021-07-01 2021-07-01 Mock data generation method and device

Country Status (1)

Country Link
CN (1) CN113342353B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102616183B1 (en) * 2022-11-29 2023-12-21 쿠팡 주식회사 Method for managing test information and electronic apparatus supporting thereof

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107748658A (en) * 2017-09-30 2018-03-02 银联商务股份有限公司 A kind of software development methodology, system, computer-readable recording medium and electronic equipment
CN112783513A (en) * 2021-03-18 2021-05-11 中国工商银行股份有限公司 Code risk checking method, device and equipment
CN112860356A (en) * 2021-02-10 2021-05-28 北京百度网讯科技有限公司 API call control method and device, electronic equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10909024B2 (en) * 2018-04-19 2021-02-02 Think Research Corporation System and method for testing electronic visual user interface outputs
CN108829584B (en) * 2018-05-24 2022-02-11 携程计算机技术(上海)有限公司 Service logic interface mock test method and system
US11157242B2 (en) * 2019-09-30 2021-10-26 Salesforce.Com, Inc. Systems, methods, and apparatuses for local web components development within a cloud based computing environment
CN110825641B (en) * 2019-11-08 2023-12-29 安徽继远检验检测技术有限公司 Micro-service application test system based on simulation data generator
CN111797020A (en) * 2020-07-03 2020-10-20 北京每日优鲜电子商务有限公司 Mock data method and device based on dynamic bytecode
CN113010411B (en) * 2020-12-15 2024-07-05 云智慧(北京)科技有限公司 Method and system for returning data based on mock service and simulation test method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107748658A (en) * 2017-09-30 2018-03-02 银联商务股份有限公司 A kind of software development methodology, system, computer-readable recording medium and electronic equipment
CN112860356A (en) * 2021-02-10 2021-05-28 北京百度网讯科技有限公司 API call control method and device, electronic equipment and storage medium
CN112783513A (en) * 2021-03-18 2021-05-11 中国工商银行股份有限公司 Code risk checking method, device and equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
秦子实 ; .企业内网环境中基于Mock.js的前端应用独立调试方法.电脑知识与技术.2018,(17),全文. *

Also Published As

Publication number Publication date
CN113342353A (en) 2021-09-03

Similar Documents

Publication Publication Date Title
US20190324772A1 (en) Method and device for processing smart contracts
CN112306881B (en) Analog data generation method, device, equipment and storage medium
US10452522B1 (en) Synthetic data generation from a service description language model
CN111597110B (en) Page test method and device, electronic equipment and storage medium
CN110955409B (en) Method and device for creating resources on cloud platform
CN111026634A (en) Interface automation test system, method, device and storage medium
CN113227976A (en) Methods, systems, and computer readable media for data transformation using representational state transfer (REST) Application Programming Interfaces (APIs)
CN110865889A (en) Method and apparatus for transferring events between components
CN110888794B (en) Interface testing method and device
CN111797020A (en) Mock data method and device based on dynamic bytecode
CN111625225A (en) Program specified data output method and device
CN115599359A (en) Code generation method, device, equipment and medium
CN112769706A (en) Componentized routing method and system
CN113342353B (en) Mock data generation method and device
CN114610598A (en) Test method, test device, electronic equipment and computer readable storage medium
CN111597020B (en) Application programming interface API debugging method and debugging terminal
CN112732547B (en) Service testing method and device, storage medium and electronic equipment
CN112561690A (en) Method, system, equipment and storage medium for testing credit card staging service interface
CN116185806A (en) Digital currency system testing method and device
CN111400623B (en) Method and device for searching information
CN113656110B (en) Page loading method and device for front-end updating free cache
CN107291494B (en) Method and device for generating application program installation package
JP7580379B2 (en) Method, system and computer readable medium for data transformation using a representational state transfer (REST) application programming interface (API) - Patents.com
CN113901377B (en) Service calling method, device, storage medium and equipment of legacy system
CN109388405A (en) A kind of task processing method, device, electronic equipment and 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
GR01 Patent grant
GR01 Patent grant