CN111124873A - Method and device for returning Mock data - Google Patents

Method and device for returning Mock data Download PDF

Info

Publication number
CN111124873A
CN111124873A CN201811290252.7A CN201811290252A CN111124873A CN 111124873 A CN111124873 A CN 111124873A CN 201811290252 A CN201811290252 A CN 201811290252A CN 111124873 A CN111124873 A CN 111124873A
Authority
CN
China
Prior art keywords
mock
scene
target
interface
mock data
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
CN201811290252.7A
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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201811290252.7A priority Critical patent/CN111124873A/en
Publication of CN111124873A publication Critical patent/CN111124873A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention provides a method and a device for returning Mock data, which relate to the technical field of data processing, and the method comprises the following steps: acquiring a Mock interface rule under the condition of receiving a Mock data request sent by a client; the Mock data request comprises: mock interface rules and scene parameters; determining a target Mock interface according to the Mock interface rule, and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters; and receiving the target Mock data returned by the target Mock interface, and sending the target Mock data to the client. By changing scene parameters, the same Mock interface can adapt to different scene requirements, and in the development and test process, developers do not need to set different Mock interfaces for each scene, so that the workload of the developers is reduced, and the test efficiency is improved.

Description

Method and device for returning Mock data
Technical Field
The invention relates to the technical field of data processing, in particular to a Mock data return method and a Mock data return device.
Background
In the development process, a front-end development unit needs to be tested to find errors and repair the errors in time, so that the correctness and stability of a developed program are ensured. In the process of testing the front-end development unit, an interface is generally required to receive data returned by the server, but if the data of the server is not ready, the front-end development unit cannot be tested, the front-end development progress is affected, and the development time is increased.
At present, Mock data is test data required by returning to a front-end development unit through a forged Mock interface, so that the front-end development unit does not depend on the development progress of a server. One Mock interface needs to define one interface rule, and each interface rule corresponds to one data.
The inventor finds that the prior art proposal has the following disadvantages in the process of studying the prior art: if the same Mock interface rule is requested for many times under different situations, the returned data are the same, the same Mock interface rule cannot adapt to the requirements of different scenes, different Mock interfaces need to be set if different scenes need different data in the development and test process, and developers are inconvenient to operate and low in test efficiency.
Disclosure of Invention
The invention provides a Mock data return method and a Mock data return device, and aims to solve the problems that the same Mock interface rule cannot adapt to different situation requirements, so that developers are inconvenient to operate and the testing efficiency is low.
In a first aspect, an embodiment of the present invention provides a method for returning Mock data, where the method includes:
acquiring a Mock interface rule under the condition of receiving a Mock data request sent by a client; the Mock data request comprises: mock interface rules and scene parameters;
determining a target Mock interface according to the Mock interface rule, and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters;
and receiving the target Mock data returned by the target Mock interface, and sending the target Mock data to the client.
Optionally, the target Mock interface is determined according to the Mock interface rule, and the Mock data request is pushed to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning the target Mock data corresponding to the scene parameters, and the method also comprises the following steps:
and generating target Mock data corresponding to the scene parameters.
Optionally, the scene parameters include: a scene module parameter and a scene method parameter; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters, and comprises the following steps:
the target Mock interface is used for analyzing the Mock data request, acquiring scene module parameters and scene method parameters, and returning target Mock data corresponding to the scene module parameters and the scene method parameters.
Optionally, the generating target Mock data corresponding to the scene parameter includes:
generating target Mock data corresponding to the scene parameters according to a preset function; the preset function is positioned under a preset programming module, and the preset programming module is a programming module corresponding to the scene module parameter; the preset function is a function corresponding to the scene method parameter under the preset programming module.
Optionally, before acquiring the Mock interface rule when the Mock data request sent by the client is received, the method further includes:
setting a Mock data request format; the Mock data request format comprises: the Mock interface rule format and the scene parameter format;
sending the Mock data request format to the client;
the acquiring a Mock interface rule under the condition of receiving a Mock data request sent by a client comprises the following steps:
and acquiring a Mock interface rule under the condition of receiving a Mock data request which is sent by a client and is matched with the Mock data request format.
In a second aspect, an embodiment of the present invention further provides a Mock data return device, where the Mock data return device includes:
the Mock interface rule acquisition module is used for acquiring a Mock interface rule under the condition of receiving a Mock data request sent by a client; the Mock data request comprises: mock interface rules and scene parameters;
the target Mock interface determining module is used for determining a target Mock interface according to the Mock interface rule and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters;
and the target Mock data returning module is used for receiving the target Mock data returned by the target Mock interface and sending the target Mock data to the client.
Optionally, the apparatus further comprises:
and the target Mock data generation module is used for generating target Mock data corresponding to the scene parameters.
Optionally, the scene parameters include: a scene module parameter and a scene method parameter; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters, and comprises the following steps:
the target Mock interface is used for analyzing the Mock data request, acquiring scene module parameters and scene method parameters, and returning target Mock data corresponding to the scene module parameters and the scene method parameters.
Optionally, the target Mock data generating module includes:
the target Mock data generation unit is used for generating target Mock data corresponding to the scene parameters according to a preset function; the preset function is positioned under a preset programming module, and the preset programming module is a programming module corresponding to the scene module parameter; the preset function is a function corresponding to the scene method parameter under the preset programming module.
Optionally, the apparatus further comprises:
the Mock data request format setting module is used for setting the Mock data request format; the Mock data request format comprises: the Mock interface rule format and the scene parameter format;
the Mock data request format sending module is used for sending the Mock data request format to the client;
the Mock interface rule obtaining module comprises:
and the Mock interface rule obtaining unit is used for obtaining the Mock interface rule under the condition of receiving a Mock data request which is sent by the client and is matched with the Mock data request format.
In a third aspect, an embodiment of the present invention further provides a terminal, where the terminal includes a processor, a memory, and a computer program that is stored in the memory and is executable on the processor, and when the computer program is executed by the processor, the step of the Mock data return method according to the present invention is implemented.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the Mock data return method according to the present invention are implemented.
According to the embodiment of the invention, under the condition of receiving a Mock data request sent by a client, a Mock interface rule is obtained; the Mock data request comprises: mock interface rules and scene parameters; determining a target Mock interface according to the Mock interface rule, and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters; and receiving the target Mock data returned by the target Mock interface, and sending the target Mock data to the client. Namely, the Mock data request not only comprises a Mock interface rule, but also comprises scene parameters, after the Mock data request is analyzed by the target Mock interface, the target Mock data corresponding to the scene parameters are returned, namely the same Mock interface rule, only the scene parameters in the Mock data request need to be changed, so that different scene requirements can be adapted, the same Mock interface rule corresponds to the same Mock interface, and then the same Mock interface can adapt to different scene requirements.
Drawings
Fig. 1 shows a flowchart of a Mock data return method provided in a first embodiment of the present invention;
fig. 2 shows a flowchart of a Mock data return method provided in the second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a Mock data return device according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of another Mock data return device according to the third embodiment.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. 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.
Example one
Referring to fig. 1, a flowchart of a Mock data returning method provided in a first embodiment of the present invention is shown, where the method may be applied to a Mock platform, which may be a terminal or a program module capable of providing Mock data for a client, and the method is not limited in this embodiment of the present invention.
The Mock data return method specifically comprises the following steps:
step 101, acquiring a Mock interface rule under the condition of receiving a Mock data request sent by a client; the Mock data request comprises: mock interface rules and scene parameters.
In the embodiment of the present invention, the client may be a terminal or the like that needs Mock data, that is, counterfeit data, for example, a terminal or the like where the development test unit is located. In the embodiment of the present invention, this is not particularly limited.
In the embodiment of the present invention, the Mock platform may be a program module located on the client, and the like, which is not particularly limited in the embodiment of the present invention.
In the embodiment of the invention, the Mock platform obtains the Mock interface rule under the condition of receiving the Mock data request sent by the client, wherein the Mock data request comprises the following components: mock interface rules and scene parameters. The Mock interface rule can be an identifier corresponding to the Mock interface. For example, if a certain Mock interface corresponds to an identifier: "/common/query", the Mock interface rule may be: "/common/query". In the embodiment of the present invention, this is not particularly limited.
In the embodiment of the invention, the scene parameters can be corresponding different Mock data structure parameters and the like under different scene requirements. Or, the scene parameter may be a function name or the like for acquiring or generating corresponding different Mock data structure parameters under different scene requirements. In the embodiment of the present invention, this is not particularly limited.
For example, in scenario 1, if the required Mock data structure parameters are: name, age, gender, the scene parameters may be: name, age, gender, obtaining or generating Mock data structure parameters: getuserinfo, the scene parameters may also be: getuserinfo. For another example, in scenario 2, if the required Mock data structure parameters are: product name, price, quantity, the scenario parameter may be: product name, price, quantity, obtain or generate Mock data structure parameter: getgoods, the scene parameters may also be: getgoods. For another example, in scene 3, if the required Mock data structure parameters are: date, temperature, wind speed, rainfall, the scene parameters may be: date, temperature, wind speed, rainfall, acquisition or generation of Mock data structure parameters: getweather, the scene parameters may also be: getweather.
In the embodiment of the invention, the Mock platform can acquire the Mock interface rule according to a preset analysis rule and the like under the condition of receiving the Mock data request sent by the client. In the embodiment of the present invention, this is not particularly limited.
Step 102, determining a target Mock interface according to the Mock interface rule, and pushing the Mock data request to the target Mock interface; and the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters.
In the embodiment of the invention, the Mock platform can comprise 1 or more Mock interfaces, and each Mock interface has a corresponding Mock interface rule. The above-mentioned respective Mock interface rules may be used to distinguish different Mock interfaces. Each Mock interface may store 1 or more kinds of target Mock data corresponding to the scene parameters, or the Mock platform may have a database, where the database may store 1 or more kinds of target Mock data corresponding to the scene parameters, and the target Mock interface may search the target Mock data corresponding to the scene parameters from the database. Or, the target Mock interface is provided with a function for acquiring or generating the target Mock data, and the like. Each Mock interface may be a virtual interface. In the embodiment of the present invention, this is not particularly limited.
In the embodiment of the invention, the Mock platform can determine the corresponding target Mock interface according to the Mock interface rule. The Mock platform can push the Mock data request to the target Mock interface, and the target Mock interface can analyze the Mock data request, acquire the scene parameters and return the target Mock data corresponding to the scene parameters.
Specifically, the target Mock platform can analyze the Mock data request according to preset analysis rules and the like to obtain the scene parameters, and the scene parameters can be corresponding different Mock data structure parameters and the like under different scene requirements. The target Mock data corresponding to the scene parameter may be Mock data corresponding to a Mock data structure parameter of the scene, or the like. In the embodiment of the present invention, this is not particularly limited.
For example, if the scene parameters are: name, age, and gender, the target Mock data corresponding to the scene parameter may be: zhangsan, 28, male. For another example, if the scene parameters are: the product name, price, and quantity, the target Mock data corresponding to the scene parameter may be: spring men's clothing, 120, 1000. For another example, if the scene parameters are: date, temperature, wind speed, and rainfall, the target Mock data corresponding to the scene parameter may be: year 2018, month 5, 20 days, 24, 3 and 2.
In the example of the present invention, the client may set a unit or the like corresponding to each Mock data in the development test unit, or the Mock data returned by the target Mock data interface may be accompanied by a corresponding unit or the like. For example, if the unit of the wind speed is set in the development test unit of the client: m/s, the target Mock data: 20 days, 24 days, 3 days and 2 days in 5 months in 2018, and the wind speed is 3m/s in a development test unit of the client. In the embodiment of the present invention, this is not particularly limited.
In the embodiment of the present invention, optionally, if only 1 kind of Mock data is stored in a certain Mock interface, or only one kind of Mock data acquisition or generation function is set in the Mock interface, if the Mock interface is a target Mock interface, the target Mock interface may directly determine the Mock data as the target Mock data without analyzing the Mock data request, and directly return the Mock data to the Mock platform. And further the return efficiency of the target Mock data can be improved. In the embodiment of the present invention, this is not particularly limited.
And 103, receiving the target Mock data returned by the target Mock interface, and sending the target Mock data to the client.
In the embodiment of the invention, the Mock platform can receive the target Mock data returned by the target Mock interface and send the target Mock data to the client. The client can test the terminal of the development test unit based on the target Mock data. In the embodiment of the present invention, this is not particularly limited.
When the Mock platform is positioned on the client, the steps of the Mock data returning method, such as the steps of obtaining a Mock interface rule, determining a target Mock interface, receiving Mock data returned by the target Mock interface, sending the target Mock data to the client and the like, can be completed on one side of the client, without participation of other server sides, without delay caused by network transmission, so that the Mock data is more flexible and convenient to return, and the deployment cost is lower.
According to the embodiment of the invention, under the condition of receiving a Mock data request sent by a client, a Mock interface rule is obtained; the Mock data request comprises: mock interface rules and scene parameters; determining a target Mock interface according to the Mock interface rule, and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters; and receiving the target Mock data returned by the target Mock interface, and sending the target Mock data to the client. Namely, the Mock data request not only comprises a Mock interface rule, but also comprises scene parameters, after the Mock data request is analyzed by the target Mock interface, the target Mock data corresponding to the scene parameters are returned, namely the same Mock interface rule, only the scene parameters in the Mock data request need to be changed, so that different scene requirements can be adapted, the same Mock interface rule corresponds to the same Mock interface, and then the same Mock interface can adapt to different scene requirements.
Example two
Referring to fig. 2, a flowchart of a Mock data returning method provided in the second embodiment of the present invention is shown, and the method may be applied to a Mock platform, and for the description of the Mock platform, reference is made to the related description in the first embodiment, and details are not repeated here. The method specifically comprises the following steps:
step 201, setting a Mock data request format; the Mock data request format comprises: the Mock interface rule format and the scene parameter format.
In the embodiment of the invention, the Mock platform can set the Mock data request format. The Mock data request format may include: the Mock interface rule format and the scene parameter format. The Mock data request format may be the number of bits occupied by the Mock interface rule, the number of bits occupied by the scene parameter, the start bit of the scene parameter, and the like in the Mock data request, which is not specifically limited in the embodiment of the present invention.
In the embodiment of the present invention, optionally, the format of the scene parameter and the like may be set in the Mock data request in the form of http request parameters, and the format of the scene parameter may be json format and the like, which is not specifically limited in the embodiment of the present invention.
Step 202, sending the Mock data request format to the client.
In the embodiment of the invention, after the Mock platform sets the Mock data request format, the Mock data request format can be sent to the client. And informing the client to send the Mock data request to the Mock platform through the Mock data request format.
Step 203, acquiring a Mock interface rule under the condition of receiving a Mock data request which is sent by a client and is matched with the Mock data request format; the Mock data request comprises: mock interface rules and scene parameters.
In the embodiment of the present invention, step 203 may refer to step 101 described above, and is not described herein again to avoid repetition. It should be noted that the Mock platform may send the set Mock data request format to the client, and the client may send a Mock data request matching the Mock data request format to the Mock platform according to the Mock data request format. And under the condition of receiving a Mock data request which is sent by the client and is matched with the Mock data request format, the Mock platform can analyze the Mock data request according to the set Mock data request format to obtain a Mock interface rule. In the embodiment of the present invention, this is not particularly limited.
In the embodiment of the invention, the Mock interface rule is obtained under the condition of receiving the Mock data request which is sent by the client and is matched with the Mock data request format, on one hand, the Mock data request format is specified, and only if the Mock data request which is matched with the Mock data request format is received, the subsequent operation is executed, so that the misoperation is effectively avoided; on the other hand, the method is beneficial to improving the efficiency of analyzing the Mock data request.
And 204, generating target Mock data corresponding to the scene parameters.
In the embodiment of the invention, the target Mock data corresponding to the scene parameter can be generated in advance. And further, the target Mock data corresponding to the scene parameter can be returned to the client under the condition of receiving the Mock data request. Specifically, target Mock data and the like corresponding to the scene parameters may be generated by the Mock platform in advance, or a function and the like for generating the target Mock data and the like corresponding to the scene parameters may be stored by the Mock platform in advance, or a function and the like for generating the target Mock data and the like corresponding to the scene parameters may be generated by the target Mock interface in advance, or a function and the like for generating the target Mock data and the like corresponding to the scene parameters may be stored by the target Mock interface, and the target Mock data corresponding to the scene parameters may be generated by the function. In the embodiment of the present invention, this is not particularly limited.
For example, for the above example, the target Mock interface may be generated and stored in advance, and the parameter structure is: target Mock data for name, age, gender, such as: zhangsan, 28, male.
In this embodiment of the present invention, optionally, the generating target Mock data corresponding to the scene parameter may include: generating target Mock data corresponding to the scene parameters according to a preset function; the preset function is positioned under a preset programming module, and the preset programming module is a programming module corresponding to the scene module parameter; the preset function is a function corresponding to the scene method parameter under the preset programming module. Specifically, a developer may set a programming module corresponding to a scene module parameter in advance in a Mock platform or a target Mock interface, where the scene module parameter may be a scene programming module parameter, and a function corresponding to a scene method parameter is set in the programming module. The scene method parameter may be a scene function parameter, and the preset function may generate or obtain target Mock data corresponding to the scene parameter. In the embodiment of the present invention, this is not particularly limited.
Specifically, a developer may generate a programming module corresponding to the scene module parameter in advance in a Mock platform or a target Mock interface, and generate a function capable of generating or acquiring a corresponding target Mock data structure parameter in advance under the programming module. For example, if the scene parameters are: getUserInfo, if the user is a scene module parameter, and if getUserInfo is a scene method parameter, the developer can be: and in the Mock platform or the target Mock interface, a user programming module is set or generated in advance, and the getUserInfo function is set or generated in advance under the user programming module. The user programming module may be a programming module corresponding to a scene module parameter user, and the getUserInfo function may be a function corresponding to a scene method parameter getUserInfo in the user programming module. The getUserInfo function under the user can generate Mock data structure parameters as follows: target Mock data for name, age, gender such as: zhangsan, 28, male.
Step 205, the scene parameters include: a scene module parameter and a scene method parameter; determining a target Mock interface according to the Mock interface rule, and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene module parameters and scene method parameters, and returning target Mock data corresponding to the scene module parameters and the scene method parameters.
In this embodiment of the present invention, the scene parameter may include: a scene module parameter and a scene method parameter. The scene module parameter can be the name of a programming module where the function of the corresponding different Mock data structure parameters is located and the like under different scene requirements. The scene method parameter may be a function name that can obtain or generate corresponding different Mock data structure parameters under the programming module, and the like. In the embodiment of the present invention, this is not particularly limited.
For example, in scenario 1, if the required Mock data structure parameters are: name, age, gender, if the Mock data structure parameters are obtained or generated: getuserinfo, the scene parameters may be: getuserinfo. The user in the context module can be a context module parameter in the context parameter, and the user programming module can be provided with a function getUserInfo for acquiring names, ages and sexes of Mock data structure parameters, and the getUserInfo can be a context parameter in the context parameter. Through the getUserInfo function in the user programming module, the Mock data structure parameter can be obtained or generated: the target Mock data corresponding to name, age and gender are as follows: zhangsan, 28, male.
For another example, in scenario 2, if the required Mock data structure parameters are: product name, price, quantity, if get Mock data structure parameter: getgoods, the scene parameters may be: getgoods. The goods in the context parameter may be a context module parameter in the context parameter, the goods programming module may be provided with a getGoods function for acquiring or generating Mock data structure parameters, such as product name, price, and quantity, and the getGoods may be a context parameter in the context parameter. The Mock data structure parameter may be obtained or generated by the getGoods function in the goods programming module: the target Mock data corresponding to the product name, price and quantity are as follows: spring men's clothing, 120, 1000.
For another example, in scene 3, if the required Mock data structure parameters are: date, temperature, wind speed, rainfall, if acquire Mock data structure parameter: getweather, the scene parameters may be: getweather. The weather in the above may be a scene module parameter in the scene parameters, and the weather programming module may be configured to acquire a Mock data structure parameter: the functions getWeather of date, temperature, wind speed, rainfall, getWeather may be the scene method parameter among the scene parameters. Through the getWeather function in the weather programming module, the Mock data structure parameter can be obtained: the target Mock data corresponding to date, temperature, wind speed and rainfall are as follows: year 2018, month 5, 20 days, 24, 3 and 2.
In the embodiment of the invention, the target Mock interface can analyze the Mock data request, acquire the scene module parameter and the scene method parameter, and return the target Mock data corresponding to the scene module parameter and the scene method parameter to the Mock platform. For example, for the above example, if the scene parameters are: getuserinfo, the target Mock interface may parse the Mock data request, and the obtained scene module parameter may be: the user, the obtained scene method parameter may be: getUserInfo, and returns the parameters of the scene module to the Mock platform: user, and scene method parameters: getUserInfo, corresponding target Mock data: zhangsan, 28, male.
And step 206, receiving the target Mock data returned by the target Mock interface, and sending the target Mock data to the client.
In the embodiment of the present invention, step 206 may refer to step 103, and is not described herein again to avoid repetition.
According to the embodiment of the invention, under the condition of receiving a Mock data request sent by a client, a Mock interface rule is obtained; the Mock data request comprises: mock interface rules and scene parameters; determining a target Mock interface according to the Mock interface rule, and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters; and receiving the target Mock data returned by the target Mock interface, and sending the target Mock data to the client. Namely, the Mock data request not only comprises a Mock interface rule, but also comprises scene parameters, after the Mock data request is analyzed by the target Mock interface, the target Mock data corresponding to the scene parameters are returned, namely the same Mock interface rule, only the scene parameters in the Mock data request need to be changed, so that different scene requirements can be adapted, the same Mock interface rule corresponds to the same Mock interface, and then the same Mock interface can adapt to different scene requirements.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the embodiments are not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the embodiments of the application.
EXAMPLE III
Referring to fig. 3, which is a schematic structural diagram of a Mock data returning device according to a third embodiment of the present invention, the device may be applied to a Mock platform, and reference may be made to the foregoing description for the Mock platform, so that details are not repeated herein to avoid redundancy. The apparatus 300 may include:
a Mock interface rule obtaining module 303, configured to obtain a Mock interface rule when a Mock data request sent by a client is received; the Mock data request comprises: mock interface rules and scene parameters;
a target Mock interface determining module 305, configured to determine a target Mock interface according to the Mock interface rule, and push the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters;
and a target Mock data returning module 306, configured to receive the target Mock data returned by the target Mock interface, and send the target Mock data to the client.
Optionally, as shown in fig. 4, on the basis of fig. 3, the apparatus may further include:
and a target Mock data generation module 304, configured to generate target Mock data corresponding to the scene parameter.
Optionally, the scene parameters include: a scene module parameter and a scene method parameter; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters, and comprises the following steps:
the target Mock interface is used for analyzing the Mock data request, acquiring scene module parameters and scene method parameters, and returning target Mock data corresponding to the scene module parameters and the scene method parameters.
Optionally, the target Mock data generating module 304 may include:
a target Mock data generating unit 3041, configured to generate target Mock data corresponding to the scene parameter according to a preset function; the preset function is positioned under a preset programming module, and the preset programming module is a programming module corresponding to the scene module parameter; the preset function is a function corresponding to the scene method parameter under the preset programming module.
Optionally, the apparatus may further include:
a Mock data request format setting module 301, configured to set a Mock data request format; the Mock data request format comprises: the Mock interface rule format and the scene parameter format;
a Mock data request format sending module 302, configured to send the Mock data request format to the client;
the Mock interface rule obtaining module 303 includes:
a Mock interface rule obtaining unit 3031, configured to obtain a Mock interface rule when a Mock data request sent by a client is received, where the Mock data request is matched with the Mock data request format.
The Mock data return device provided by the embodiment of the invention can realize each process realized by the terminal in the method embodiments of fig. 1 to fig. 2, and is not described again for avoiding repetition.
According to the embodiment of the invention, under the condition of receiving a Mock data request sent by a client, a Mock interface rule is obtained; the Mock data request comprises: mock interface rules and scene parameters; determining a target Mock interface according to the Mock interface rule, and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters; and receiving the target Mock data returned by the target Mock interface, and sending the target Mock data to the client. Namely, the Mock data request not only comprises a Mock interface rule, but also comprises scene parameters, after the Mock data request is analyzed by the target Mock interface, the target Mock data corresponding to the scene parameters are returned, namely the same Mock interface rule, only the scene parameters in the Mock data request need to be changed, so that different scene requirements can be adapted, the same Mock interface rule corresponds to the same Mock interface, and then the same Mock interface can adapt to different scene requirements.
Preferably, an embodiment of the present invention further provides a terminal, which includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, where the computer program, when executed by the processor, implements each process of the above embodiment of the Mock data return method, and can achieve the same technical effect, and details are not repeated here to avoid repetition.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the above embodiment of the Mock data return method, and can achieve the same technical effect, and in order to avoid repetition, the detailed description is omitted here. The computer-readable storage medium may be a read-Only memory (R11ad-Only M11 memory, ROM for short), a Random access memory (Random access memory 11ssM11 memory, RAM for short), a magnetic disk or an optical disk.
It should be noted that, in this document, 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 an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (10)

1. A Mock data return method is characterized by comprising the following steps:
acquiring a Mock interface rule under the condition of receiving a Mock data request sent by a client; the Mock data request comprises: mock interface rules and scene parameters;
determining a target Mock interface according to the Mock interface rule, and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters;
and receiving the target Mock data returned by the target Mock interface, and sending the target Mock data to the client.
2. The method according to claim 1, wherein the determining a target Mock interface according to the Mock interface rule and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning the target Mock data corresponding to the scene parameters, and the method also comprises the following steps:
and generating target Mock data corresponding to the scene parameters.
3. The method of claim 2, wherein the scene parameters comprise: a scene module parameter and a scene method parameter; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters, and comprises the following steps:
the target Mock interface is used for analyzing the Mock data request, acquiring scene module parameters and scene method parameters, and returning target Mock data corresponding to the scene module parameters and the scene method parameters.
4. The method according to claim 3, wherein the generating target Mock data corresponding to the scene parameter comprises:
generating target Mock data corresponding to the scene parameters according to a preset function; the preset function is positioned under a preset programming module, and the preset programming module is a programming module corresponding to the scene module parameter; the preset function is a function corresponding to the scene method parameter under the preset programming module.
5. The method according to claim 1, wherein before acquiring the Mock interface rule in case of receiving a Mock data request sent by a client, the method further comprises:
setting a Mock data request format; the Mock data request format comprises: the Mock interface rule format and the scene parameter format;
sending the Mock data request format to the client;
the acquiring a Mock interface rule under the condition of receiving a Mock data request sent by a client comprises the following steps:
and acquiring a Mock interface rule under the condition of receiving a Mock data request which is sent by a client and is matched with the Mock data request format.
6. A Mock data return apparatus, characterized in that said apparatus comprises:
the Mock interface rule acquisition module is used for acquiring a Mock interface rule under the condition of receiving a Mock data request sent by a client; the Mock data request comprises: mock interface rules and scene parameters;
the target Mock interface determining module is used for determining a target Mock interface according to the Mock interface rule and pushing the Mock data request to the target Mock interface; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters;
and the target Mock data returning module is used for receiving the target Mock data returned by the target Mock interface and sending the target Mock data to the client.
7. The apparatus of claim 6, further comprising:
and the target Mock data generation module is used for generating target Mock data corresponding to the scene parameters.
8. The apparatus of claim 7, wherein the scene parameters comprise: a scene module parameter and a scene method parameter; the target Mock interface is used for analyzing the Mock data request, acquiring scene parameters and returning target Mock data corresponding to the scene parameters, and comprises the following steps:
the target Mock interface is used for analyzing the Mock data request, acquiring scene module parameters and scene method parameters, and returning target Mock data corresponding to the scene module parameters and the scene method parameters.
9. A terminal comprising a processor, a memory, and a computer program stored on the memory and executable on the processor, the computer program when executed by the processor implementing the steps of the Mock data return method according to any of claims 1 to 5.
10. A computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the Mock data return method according to any of claims 1 to 5.
CN201811290252.7A 2018-10-31 2018-10-31 Method and device for returning Mock data Pending CN111124873A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811290252.7A CN111124873A (en) 2018-10-31 2018-10-31 Method and device for returning Mock data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811290252.7A CN111124873A (en) 2018-10-31 2018-10-31 Method and device for returning Mock data

Publications (1)

Publication Number Publication Date
CN111124873A true CN111124873A (en) 2020-05-08

Family

ID=70494370

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811290252.7A Pending CN111124873A (en) 2018-10-31 2018-10-31 Method and device for returning Mock data

Country Status (1)

Country Link
CN (1) CN111124873A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111752625A (en) * 2020-06-23 2020-10-09 京东数字科技控股有限公司 Method and device for interface mock
CN112383434A (en) * 2020-11-17 2021-02-19 Oppo广东移动通信有限公司 Interface simulation method and device for network request, electronic equipment and storage medium
CN113760703A (en) * 2020-09-07 2021-12-07 北京沃东天骏信息技术有限公司 Method, device and equipment for generating Mock data and storage medium
CN113778871A (en) * 2021-09-07 2021-12-10 未鲲(上海)科技服务有限公司 Mock testing method, device, equipment and storage medium
CN113791971A (en) * 2021-08-13 2021-12-14 唯品会(广州)软件有限公司 Mock testing method, Mock testing device, Mock testing equipment and computer readable medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016192556A1 (en) * 2015-05-29 2016-12-08 北京金山安全软件有限公司 Interface invoking method, device and terminal
CN106610894A (en) * 2015-10-26 2017-05-03 阿里巴巴集团控股有限公司 Interface testing method and device
CN107122297A (en) * 2017-04-18 2017-09-01 上海雷腾软件股份有限公司 The method and apparatus that request message for test interface is generated
CN107329890A (en) * 2017-06-06 2017-11-07 北京金山安全软件有限公司 Test method and device based on Mock and server
CN108268372A (en) * 2017-07-24 2018-07-10 深圳壹账通智能科技有限公司 Mock test processing methods, device, storage medium and computer equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016192556A1 (en) * 2015-05-29 2016-12-08 北京金山安全软件有限公司 Interface invoking method, device and terminal
CN106610894A (en) * 2015-10-26 2017-05-03 阿里巴巴集团控股有限公司 Interface testing method and device
CN107122297A (en) * 2017-04-18 2017-09-01 上海雷腾软件股份有限公司 The method and apparatus that request message for test interface is generated
CN107329890A (en) * 2017-06-06 2017-11-07 北京金山安全软件有限公司 Test method and device based on Mock and server
CN108268372A (en) * 2017-07-24 2018-07-10 深圳壹账通智能科技有限公司 Mock test processing methods, device, storage medium and computer equipment

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111752625A (en) * 2020-06-23 2020-10-09 京东数字科技控股有限公司 Method and device for interface mock
CN113760703A (en) * 2020-09-07 2021-12-07 北京沃东天骏信息技术有限公司 Method, device and equipment for generating Mock data and storage medium
CN112383434A (en) * 2020-11-17 2021-02-19 Oppo广东移动通信有限公司 Interface simulation method and device for network request, electronic equipment and storage medium
CN112383434B (en) * 2020-11-17 2023-08-08 Oppo广东移动通信有限公司 Interface simulation method and device for network request, electronic equipment and storage medium
CN113791971A (en) * 2021-08-13 2021-12-14 唯品会(广州)软件有限公司 Mock testing method, Mock testing device, Mock testing equipment and computer readable medium
CN113778871A (en) * 2021-09-07 2021-12-10 未鲲(上海)科技服务有限公司 Mock testing method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111124873A (en) Method and device for returning Mock data
CN109901838B (en) Front-end development method, device, equipment and storage medium based on componentization
US20210326729A1 (en) Recommendation Model Training Method and Related Apparatus
JP7343568B2 (en) Identifying and applying hyperparameters for machine learning
CA2992563A1 (en) Method and system for applying probabilistic topic models to content in a tax environment to improve user satisfaction with a question and answer customer support system
CN109634605B (en) Simulation data generation method and system for web front end
CN110750433A (en) Interface test method and device
CN109167816A (en) Information-pushing method, device, equipment and storage medium
CN109598526B (en) Method and device for analyzing media contribution
CN110955409B (en) Method and device for creating resources on cloud platform
CN109710535B (en) Service verification method and system for voice conversation platform
CN104010035A (en) Method and system for application program distribution
CN109783752A (en) Page loading method and device, electronic equipment and computer readable storage medium
CN110795697A (en) Logic expression obtaining method and device, storage medium and electronic device
CN110866205B (en) Method and apparatus for storing information
CN111737443A (en) Answer text processing method and device and key text determining method
CN111209325A (en) Service system interface identification method, device and storage medium
CN111221711A (en) User behavior data processing method, server and storage medium
CN112965912B (en) Interface test case generation method and device and electronic equipment
CN110209780B (en) Question template generation method and device, server and storage medium
CN112882890A (en) Log collection method and device
CN116166533A (en) Interface testing method, device, terminal equipment and storage medium
CN115408606A (en) Insurance information pushing method and device, storage medium and computer equipment
CN114218259A (en) Multi-dimensional scientific information search method and system based on big data SaaS
CN113515436A (en) Interface testing method and device

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200508