CN112667508A - Mock method, system and device based on user-defined Mock platform and storage medium - Google Patents

Mock method, system and device based on user-defined Mock platform and storage medium Download PDF

Info

Publication number
CN112667508A
CN112667508A CN202011594829.0A CN202011594829A CN112667508A CN 112667508 A CN112667508 A CN 112667508A CN 202011594829 A CN202011594829 A CN 202011594829A CN 112667508 A CN112667508 A CN 112667508A
Authority
CN
China
Prior art keywords
information
mock
platform
simulation
request
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
CN202011594829.0A
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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202011594829.0A priority Critical patent/CN112667508A/en
Publication of CN112667508A publication Critical patent/CN112667508A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention relates to data information simulation, and provides a Mock method, a Mock system, a Mock device and a storage medium based on a user-defined Mock platform, wherein the method comprises the following steps: establishing a simulation information database according to known information to be simulated; the information to be simulated comprises request information and return information; initializing a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform; simulating returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform. The technical scheme provided by the invention can solve the problem of poor protocol applicability of the conventional MOCK tool.

Description

Mock method, system and device based on user-defined Mock platform and storage medium
Technical Field
The invention relates to the technical field of data information simulation, in particular to a Mock method, a Mock system, a Mock device and a storage medium based on a user-defined Mock platform.
Background
In the testing process of computer software, for one software, because the scenes used by the software are various, in order to ensure that the software is adaptive to various scenes when being online, the software needs to be tested to cover different scenes.
However, to test the software in multiple required scenes, test data corresponding to the required scenes needs to be prepared, and the most difficult problem in the process of manufacturing the data is that the manufacturing number (i.e. the preparation and acquisition process of the test data in various scenes) is not time-consuming, but the appropriate data in various scenes cannot be manufactured under the existing conditions or due to environmental obstruction.
In addition, when testing one system in a group of associated systems, in order to ensure the testing efficiency of the system, the system needs to be independently tested from a plurality of associated systems in the group, and data testing needs to be performed by using data of all other associated systems in the group for support in order to ensure the testing accuracy of the system.
The existing method for solving the two problems is to use a MOCK tool to simulate data, and the MOCK tool can artificially simulate data in any desired scene or associated system in the using process.
However, currently existing MOCK tools can only support http protocol in terms of access protocol. None of these existing MOCK tools are often adaptable when custom protocols are present within a company. For example, if the communication protocol between the systems in the company is ESG, the existing MOCK tool cannot be used to perform MOCK of data and interface, that is, data under a desired scene or associated system cannot be simulated. In addition, when the existing MOCK tool is used to perform MOCK operation on existing tools, software and the like, the request address needs to be modified additionally at other places (such as an auxiliary application system) to achieve the effect of the MOCK. The method of modifying the request address on other application systems and then performing the MOCK operation has certain inconvenience in operation.
Based on this, a method capable of solving the poor protocol applicability of the existing MOCK tool and improving the operation efficiency is needed.
Disclosure of Invention
The invention provides a Mock method, a Mock system, an electronic device and a computer storage medium based on a user-defined Mock platform, and mainly aims to solve the problem that the protocol applicability of the existing Mock tool is poor.
In order to achieve the purpose, the invention provides a Mock method based on a self-defined Mock platform, which comprises the following steps:
establishing a simulation information database according to known information to be simulated; the information to be simulated comprises request information and return information;
initializing a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform;
simulating the returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
Preferably, the process of establishing the simulation information database according to the information to be simulated includes:
associating request information in the information to be simulated with corresponding return information through request participation;
and storing the request information, the return information and the request parameter association into a preset database to form the simulation information database.
Preferably, the MOCK platform is matched with the simulation information database to simulate return information of real-time request information acquired in a self-test system; and the process of transmitting the simulation result of the ESG type to the test system after being transferred through the ESG service administration platform and transmitting the simulation result of the HTTP type to the test system directly through the MOCK platform comprises the following steps:
searching the simulation information database according to the real-time request information and the request access parameters thereof to obtain return information corresponding to the real-time request, and recording the return information as return simulation information;
judging the protocol type of the returned simulation information based on the MOCK platform;
if the protocol type of the returned simulation information is the ESG type, transferring the returned simulation information to the test system through the ESG service administration platform; and if the protocol type of the returned simulation information is the HTTP type, directly sending the returned simulation information to the test system.
Preferably, the preset simulation platform framework further comprises an associated system platform, and a MOCK switch is arranged in the MOCK platform; before the process of retrieving the simulation information database according to the real-time request information and the request entry thereof to obtain the return information corresponding to the real-time request, the method further comprises the following steps:
judging whether the MOCK switch needs to be started or not according to the real-time request information;
if the MOCK switch is judged to need to be started, searching the simulation information database according to the real-time request information and the request entry participation thereof so as to obtain return information corresponding to the real-time request and marking the return information as the return simulation information; and if the MOCK switch is judged not to be started, sending the real-time request information and the request entry parameter thereof to the associated system platform to obtain associated system return information, and recording the associated system return information as the return simulation information.
Preferably, the simulation information database is retrieved according to the real-time request information and the request entry thereof to obtain the return information corresponding to the real-time request, and the process of recording as the return simulation information includes:
searching all return information associated with the real-time request information from the simulation information database;
and selecting corresponding return information from all the return information associated with the real-time request information based on the request participation of the real-time request information, and recording the corresponding return information as the return simulation information.
Preferably, based on the request participation of the real-time request information, selecting corresponding return information from all return information associated with the real-time request information, and recording as the return simulation information includes:
matching and checking the request participation of the real-time request information with the request participation of all the return information according to a preset checking and matching rule;
and if the request participation of the real-time request information is matched with the request participation of the return information, recording the return information as the return simulation information.
Preferably, the ESG service administration platform and the associated system platform are connected to the MOCK platform in a batch registration link.
On the other hand, the invention also provides a Mock system based on the self-defined Mock platform, which is characterized by comprising the following components:
the database establishing unit is used for establishing a simulation information database according to the known information to be simulated; the information to be simulated comprises request information and return information;
the platform initialization unit is used for initializing a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform;
the information simulation unit is used for simulating returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
In another aspect, the present invention also provides an electronic device, including: the system comprises a memory, a processor and a Mock program based on a custom Mock platform, wherein the Mock program based on the custom Mock platform is stored in the memory and can run on the processor, and when being executed by the processor, the Mock program based on the custom Mock platform realizes the following steps:
establishing a simulation information database according to known information to be simulated; the information to be simulated comprises request information and return information;
initializing a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform;
simulating the returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
In addition, the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores a Mock program based on the user-defined Mock platform, and the step of the Mock method based on the user-defined Mock platform is realized when the Mock program based on the user-defined Mock platform is executed by a processor.
The Mock method, the electronic device and the computer readable storage medium based on the user-defined Mock platform provided by the invention can classify different scenes of each request according to the input parameters and store the different scenes into the simulation information database, so as to help testers to understand the return data corresponding to each scene, and can be used as the basis of the test logic of the testers subsequently. In addition, the Mock method based on the custom Mock platform not only supports the http protocol, but also supports the custom protocol of the ESG, and is suitable for the work among various different protocols. The Mock method based on the user-defined Mock platform provides a Mock switch switching function, does not need to modify a request IP of a test system to determine whether to request the Mock platform or an actual correlation system, can directly operate on the Mock platform to determine whether to need Mock data, and enables switching operation to be simpler, more convenient and faster. The Mock method based on the user-defined Mock platform can be used for checking the correctness of actual input parameters, if the actual input parameters are not expected, prompts of lack of input parameters exist, troubles (time, errors and the like) caused by manual verification removal and filling of input parameters for checking are reduced, and three checking modes are provided.
Drawings
FIG. 1 is a flow chart of a preferred embodiment of a Mock method based on a custom Mock platform according to an embodiment of the present invention;
FIG. 2 is a logic diagram of data transmission in a Mock method based on a custom Mock platform according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of an electronic device according to an embodiment of the invention;
FIG. 4 is a schematic diagram of the internal logic of a Mock program based on a custom Mock platform according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
In the following description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of one or more embodiments. It may be evident, however, that such embodiment(s) may be practiced without these specific details.
Specific embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Example 1
In order to explain the Mock method based on the custom Mock platform provided by the invention, fig. 1 shows the flow of the Mock method based on the custom Mock platform provided by the invention, and fig. 2 shows the data transmission logic in the Mock method based on the custom Mock platform.
Shown together with fig. 1 and fig. 2, the Mock method based on the custom Mock platform provided by the invention comprises the following steps:
s110: and acquiring all known information to be simulated, and establishing a simulation information database according to the information to be simulated.
It should be noted that all the information to be simulated in a system can be determined according to the historical simulation requirements, and the information to be simulated is collected.
In addition, for the convenience of carrying out data simulation according to a preset Mock platform in the later stage, all information to be simulated can be classified firstly, and specifically, the process of establishing the simulation information database according to the information to be simulated comprises the following steps: classifying the information to be simulated to divide the information to be simulated into request information and return information; wherein the request information is associated with the return information by requesting participation; and storing the request information, the return information and the request into a preset database to form the simulation information database. For example, the information to be simulated may be divided into two parts, i.e. request information and return information according to the information source or the information content, wherein the request information includes: request url, request protocol, request mode, MOCK switch, original request application domain name and description; the return message contains response data (i.e., expected desired response data) and the entries. The request information and the return information are associated by using the request ID and the request entry, one request ID corresponds to a plurality of returns, because one request entry is different, the corresponding returns may also be different, and the corresponding response data can be specified according to the different entry of the request as the application (which can be regarded as the corresponding test case) of the different test scenes of the request at the later stage.
Specifically, one request message may participate in different return messages according to different requests, that is, the same request message may have different return messages; for example, one interface a needs to input a correct mobile phone number for judgment, if yes, Y is returned, and if no, N is returned; then Y is returned if the incoming parameter is set to 1589872120 and N is returned if the incoming parameter is abcdefgf. If the data storage is large enough, all return scenarios of interface A can be simulated, thus realizing coverage to all test scenarios.
In addition, partition storage can be performed in the simulation information database according to different application systems, so that the later information acquisition efficiency is improved.
Furthermore, it is emphasized that to further ensure the privacy and security of the above-mentioned information to be emulated, the emulated information database may be stored in a node of the blockchain.
S120: and initializing a preset simulation platform framework according to the simulation information database.
It should be noted that, the preset simulation platform framework includes a preset MOCK platform and an ESG service administration platform, and the preset MOCK platform needs to be docked with the ESG service administration platform in advance, and the ESG service administration platform is used as a transfer platform to transmit the return information of the ESG protocol to the test system in the later stage, and the specific docking mode adopts a batch registration link form, and the principle is as follows: when the spirngboot of the MOCK platform is initialized, adding a configuration class, wherein the configuration class has the following implementation functions: firstly, defining some information appointed with an ESG service administration platform and putting the information into an object, namely an object A, comprising a URL (uniform resource locator), a subsidiary company code, a system code, an IP (Internet protocol), a port and the like; then, receiving an object A by using a setProperties method in EsgConfigUtil to generate a specific ESG instance; and finally, taking the URL set of the request information in the ESG protocol format in the information to be simulated and the service code of the corresponding request service under the MOCK platform from the inside of the simulation information database, putting the URL set and the service code into a container, adding all the containers into a queue by using an export method in autoDriveUtils, and sequentially registering the service into a Zookeeper by the queue, thereby realizing the butt joint between the preset MOCK platform and the ESG service governance platform.
In addition, it should be noted that a request service related to the request information in the simulation information database is provided in the MOCK platform, and in the initialization process, it is necessary to perform request protocol determination on all the request information stored in the simulation information database, and if the request protocol is an ESG protocol, the request service and the request information corresponding thereto are registered to the ESG service administration platform, and if the request protocol is http, registration is not required.
In addition, according to the system requirements, if the simulation information database has the newly added request information of the ESG protocol type, corresponding request information and request service need to be added in the ESG service administration platform again.
In addition, for the request service in the traditional MOCK platform, one request message needs to correspond to one request service, and at the moment, a large amount of request services need to be set in the MOCK platform, so that the data occupation space of the MOCK platform is obviously increased, and the working efficiency of the MOCK platform is seriously influenced. To solve this problem, the present application proposes two methods, a filtering method and a matching method.
Specifically, for all the request messages in the simulation information database, although all the fields of the request messages are not completely the same, they are the same in nature, that is (instead, the returned messages corresponding to the request messages are the same), at this time, the request messages with the same nature can be filtered out in a filtering manner, specifically, the request filtering rule: and matching the URL prefix appsvr of the request information, filtering the request information with the same prefix, and starting a filtering mechanism by adopting an interceptor, namely intercepting the request before the system processes the request and processing the request.
The matching method is to generate a matching rule to generate a combined request through a request, wherein the rule comprises a request header, a request URL, a request method, a request parameter, a consumable MIME matching condition and a generated MIME matching condition, namely the information is used for matching. Specifically, the request generation principle: the method is realized by adopting a reflection mechanism, combined filtering and priority ordering. The specific implementation logic is as follows: defining a target method, a target request type, and if the request method is GET, namely, the requestType is equal to 'GET', giving a specified GET object to the target method, wherein the object comprises a method name, a parameter type and a return type; otherwise, the target method is given a designated POST object. Then putting the request URL and the request method value (if the request parameter or the back parameter is added together) into the request matching condition, namely assembling the request URL and the request method value into an object which can be matched and mapped and can be called as a combined matching condition object, then locking the register to prevent other objects from reading and writing when the object is added into the processing method mapper and the path method solver through the register, then creating a method processor according to the matching object, judging whether the method processor exists or is unique (judging a container according to the method processor) after creation, if the method processor does not exist, continuously putting the method processor into the container, automatically generating a name according to a name strategy (a non-renaming strategy) according to the method processor and the matching object, and storing the name and the name into the mapping container; and then performing cross-domain configuration, skipping if configuration is not required, putting the configuration and method processor into a cross-domain inspection container if configuration is required, finally putting all the information into a register to represent that the registration is finished, and performing unlocking processing after the registration is finished, thereby realizing the combination of the request information.
S130: simulating returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
Specifically, the MOCK platform is matched with the simulation information database to simulate return information of real-time request information acquired in a self-test system; and, the process of transmitting the simulation result of the ESG type to the test system after being transferred through the ESG service administration platform, and directly transmitting the simulation result of the HTTP type to the test system through the MOCK platform includes:
searching the simulation information database according to the real-time request information and the request access parameters thereof to obtain return information corresponding to the real-time request, and marking the return information as return simulation information;
judging the protocol type of the returned simulation information based on the MOCK platform;
if the protocol type of the returned simulation information is the ESG type, the returned simulation information is sent to the ESG service management platform for transfer and then sent to the test system; and if the protocol type of the returned simulation information is the HTTP type, directly sending the returned simulation information to the test system.
In addition, the preset simulation platform framework also comprises a correlation system platform, and a MOCK switch is arranged in the MOCK platform; and before entering the process of searching the simulation information database according to the real-time request information and the request thereof to acquire the return information corresponding to the real-time request,
firstly, judging whether the MOCK switch needs to be started or not according to the real-time request information;
if the MOCK switch is judged to need to be started, searching the simulation information database according to the real-time request information and the request access participation thereof so as to obtain return information corresponding to the real-time request and marking the return information as the return simulation information; and if the MOCK switch is judged not to be started, the real-time request information and the request entry parameter thereof are sent to the associated system platform to obtain associated system return information and are recorded as the return simulation information.
It should be noted that, in the actual testing process, when the test system needs to use corresponding simulation information, the MOCK platform needs to send the real-time request information to first, and the MOCK platform first determines whether to turn on the MOCK switch according to the URL of the real-time request (i.e., whether to perform simulation in the MOCK platform, because some return information of the real-time request is not recorded into the simulation information database, at this time, an external associated system needs to be used for performing corresponding real-time simulation).
Specifically, if the MOCK switch is determined to be on (Y), the corresponding response information is searched in the simulation information database according to the URL requested in real time and the corresponding entry parameter, and the data return process is performed. In the process of data return, the protocol type of the real-time request needs to be judged, if the protocol type is the ESG type request, the protocol type is firstly returned to the ESG service management platform, and then the ESG platform returns to the test system; and if the request is an http request, directly returning to the test system. Thereby realizing the return of the simulation response information of the test system (a first simulation path).
And if the MOCK switch is judged to be closed (N), forwarding the real-time request to an actual correlation system, receiving the return information of the correlation system, and then entering the data return process again. In the process of data return, the protocol type of the real-time request needs to be judged, if the protocol type is the ESG type request, the protocol type is firstly returned to the ESG service management platform, and then the ESG platform returns to the test system; and if the request is an http request, directly returning to the test system. Thereby realizing the return of the simulation response information of the test system (a second simulation path).
Specifically, the puck switch may determine whether to turn on the real-time request according to the following determination rule: type indicates the request type, isMock indicates whether to use MOCK, and there are four paths: if type is http and isMock is Y, then go through http protocol channel and MOCK service; if type is esg and isMock is Y, then go esg channel and MOCK service; if type is http and isMock is N, then the http protocol channel and non-MOCK service are taken; if type is esg and isMock is n, then esg protocol channels and non-MOCK services are followed.
In addition, the simulation information database is searched according to the real-time request information and the request access participation thereof to obtain the return information corresponding to the real-time request, and the process of marking as the return simulation information comprises the following steps:
searching all return information associated with the real-time request information from the simulation information database;
and selecting corresponding return information from all the return information associated with the real-time request information based on the request participation of the real-time request information, and recording the corresponding return information as the return simulation information.
In addition, it should be noted that, for the first simulation path, when the corresponding response information is searched in the simulation information database according to the actual entry, in order to avoid the phenomenon of data missing, a matching check of the entry needs to be performed in advance. Specifically, based on the request entry of the real-time request information, selecting corresponding return information from all return information associated with the real-time request information, and recording as the return simulation information includes:
matching and checking the request participation of the real-time request information with the request participation of all the return information according to a preset checking and matching rule;
and if the request participation of the real-time request information is matched with the request participation of the return information, recording the return information as the return simulation information.
The first one is inclusion, that is, the actual input parameter (the request input parameter of the real-time request information) includes the preset expected input parameter (the request input parameter of the corresponding return information in the simulation information database), the inclusion relation check logic is relatively loose, as long as the character string A includes the character B, for example, the character "hello" includes the letter "e"; the second is equal, namely the actual parameter is equal to the preset expected parameter, and the equal relation is strict, such as "hello" is necessarily equal to "hello"; the third type is a regular expression, namely the actual input parameter can be regularly matched with the preset expected input parameter, the regular operation is more flexible, the function is more complete, the requirements of inclusion and equality can be simultaneously met, and other complex requirements can also be met. Regardless of the matching mode, if the matching is not achieved, the MOCK platform automatically returns a default return message to the test system to prompt that the actual entry is wrong.
In addition, it should be noted that the second simulation path is mainly caused by the fact that the information to be simulated recorded in the simulation information database is not complete, and therefore, after the simulation of the return information is completed using the second simulation path, the real-time request information and the return information corresponding to the real-time request information need to be recorded in the simulation information database. Therefore, when the system sends the same real-time request next time, the simulation information database can be directly used for simulating the returned information.
In addition, with the continuous use of the MOCK platform, more and more information is input into the simulation information database, and after all information to be simulated of the using system is input into the simulation information database, the simulation of all required information can be realized through the first path, so that the simulation efficiency of the system can be obviously improved.
In addition, it should be noted that the association system platform may also be interfaced with the MOCK platform in a batch registration link manner, and specifically, the interfacing process is the same as the interfacing manner of the ESG service administration platform, which is not described herein again.
According to the technical scheme, the Mock method based on the user-defined Mock platform can classify different scenes of each request according to the input parameters, and stores the classified scenes into the simulation information database to help testers understand the return data corresponding to each scene, and can be used as the basis of the test logic of the testers subsequently. In addition, the Mock method based on the custom Mock platform not only supports the http protocol, but also supports the custom protocol of the ESG, and is suitable for the work among various different protocols. The Mock method based on the user-defined Mock platform provides a Mock switch switching function, does not need to modify a request IP of a test system to determine whether to request the Mock platform or an actual correlation system, can directly operate on the Mock platform to determine whether to need Mock data, and enables switching operation to be simpler, more convenient and faster. The Mock method based on the user-defined Mock platform can be used for checking the correctness of actual input parameters, if the actual input parameters are not expected, prompts of lack of input parameters exist, troubles (time, errors and the like) caused by manual verification removal and filling of input parameters for checking are reduced, and three checking modes are provided.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Example 2
Corresponding to the method, the application also provides a Mock system based on the user-defined Mock platform, and the system comprises:
the database establishing unit is used for establishing a simulation information database according to the known information to be simulated; the information to be simulated comprises request information and return information;
the platform initialization unit is used for initializing a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform;
the information simulation unit is used for simulating returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
Example 3
The present invention also provides an electronic device 70. Referring to fig. 3, a schematic structural diagram of an electronic device 70 according to a preferred embodiment of the invention is shown.
In the embodiment, the electronic device 70 may be a terminal device having a computing function, such as a server, a smart phone, a tablet computer, a portable computer, or a desktop computer.
The electronic device 70 includes: a processor 71 and a memory 72.
The memory 72 includes at least one type of readable storage medium. At least one type of readable storage medium may be a non-volatile storage medium such as a flash memory, a hard disk, a multimedia card, a card-type memory, and the like. In some embodiments, the readable storage medium may be an internal storage unit of the electronic device 70, such as a hard disk of the electronic device 70. In other embodiments, the readable storage medium may be an external memory of the electronic device 1, such as a plug-in hard disk provided on the electronic device 70, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like.
In the present embodiment, the readable storage medium of the memory 72 is generally used for storing a custom Mock platform based Mock program 73 installed on the electronic device 70. The memory 72 may also be used to temporarily store data that has been output or is to be output.
Processor 72 may be, in some embodiments, a Central Processing Unit (CPU), microprocessor or other data Processing chip for executing program code stored in memory 72 or Processing data, such as Mock program 73 based on a custom Mock platform.
In some embodiments, the electronic device 70 is a terminal device of a smartphone, tablet, portable computer, or the like. In other embodiments, the electronic device 70 may be a server.
Fig. 3 shows only an electronic device 70 having components 71-73, but it is to be understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead.
Optionally, the electronic device 70 may further include a user interface, which may include an input unit such as a Keyboard (Keyboard), a voice input device such as a microphone (microphone) or other devices with voice recognition function, a voice output device such as a sound box, a headset, etc., and optionally may also include a standard wired interface, a wireless interface.
Optionally, the electronic device 70 may further include a display, which may also be referred to as a display screen or a display unit. In some embodiments, the display device may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an Organic Light-Emitting Diode (OLED) touch device, or the like. The display is used for displaying information processed in the electronic device 70 and for displaying a visualized user interface.
Optionally, the electronic device 70 may further include a touch sensor. The area provided by the touch sensor for the user to perform touch operation is referred to as a touch area. Further, the touch sensor here may be a resistive touch sensor, a capacitive touch sensor, or the like. The touch sensor may include not only a contact type touch sensor but also a proximity type touch sensor. Further, the touch sensor may be a single sensor, or may be a plurality of sensors arranged in an array, for example.
The area of the display of the electronic device 70 may be the same as or different from the area of the touch sensor. Optionally, the display is stacked with the touch sensor to form a touch display screen. The device detects touch operation triggered by a user based on the touch display screen.
Optionally, the electronic device 70 may further include a Radio Frequency (RF) circuit, a sensor, an audio circuit, and the like, which are not described in detail herein.
In the apparatus embodiment shown in FIG. 3, the memory 72, which is a type of computer storage medium, may include an operating system, and a custom Mock platform based Mock program 73; processor 71, when executing the custom Mock platform based Mock program 73 stored in memory 72, performs the following steps:
establishing a simulation information database according to known information to be simulated; the information to be simulated comprises request information and return information;
initializing a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform;
simulating returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
In this embodiment, fig. 4 is a schematic diagram of the internal logic of the Mock program based on the custom Mock platform according to the embodiment of the present invention, and as shown in fig. 4, the Mock program 73 based on the custom Mock platform can be further divided into one or more modules, and the one or more modules are stored in the memory 72 and executed by the processor 71, so as to complete the present invention. The modules referred to herein are referred to as a series of computer program instruction segments capable of performing specified functions. Referring to FIG. 3, a block diagram of a preferred embodiment of the custom Mock platform based Mock program 73 of FIG. 2 is shown. The custom Mock platform based Mock program 73 can be segmented into: a database building module 74, a platform initialization module 75, and an information modeling module 76. The functions or operational steps performed by the modules 74-76 are similar to those described above and will not be described in detail herein, as an example, wherein:
a database establishing module 74, configured to establish a simulation information database according to known information to be simulated; the information to be simulated comprises request information and return information;
a platform initialization module 75, configured to initialize a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform;
the information simulation module 76 is used for simulating returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
Example 4
The invention also provides a computer readable storage medium, wherein the Mock program 73 based on the user-defined Mock platform is stored in the computer readable storage medium, and when being executed by the processor, the Mock program 73 based on the user-defined Mock platform realizes the following operations:
establishing a simulation information database according to known information to be simulated; the information to be simulated comprises request information and return information;
initializing a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform;
simulating returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
The specific implementation of the computer-readable storage medium provided by the invention is substantially the same as the specific implementation of the user-defined Mock platform-based Mock method and the electronic device, and is not described herein again.
It should be noted that the blockchain in the present invention is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
It is further 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, apparatus, article, or method 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, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments. 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 device (such as a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A Mock method based on a user-defined Mock platform is applied to an electronic device, and is characterized by comprising the following steps:
establishing a simulation information database according to known information to be simulated; the information to be simulated comprises request information and return information;
initializing a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform;
simulating the returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
2. The Mock method based on the custom Mock platform according to claim 1, wherein the process of establishing a simulation information database according to the information to be simulated comprises:
associating request information in the information to be simulated with corresponding return information through request participation;
and storing the request information, the return information and the request parameter association into a preset database to form the simulation information database.
3. The Mock method based on the custom Mock platform according to claim 2, characterized in that the Mock platform cooperates with the simulation information database to simulate the return information of the real-time request information obtained from the self-test system; and the process of transmitting the simulation result of the ESG type to the test system after being transferred through the ESG service administration platform and transmitting the simulation result of the HTTP type to the test system directly through the MOCK platform comprises the following steps:
searching the simulation information database according to the real-time request information and the request access parameters thereof to obtain return information corresponding to the real-time request, and recording the return information as return simulation information;
judging the protocol type of the returned simulation information based on the MOCK platform;
if the protocol type of the returned simulation information is the ESG type, transferring the returned simulation information to the test system through the ESG service administration platform; and if the protocol type of the returned simulation information is the HTTP type, directly sending the returned simulation information to the test system.
4. The Mock method based on a custom Mock platform according to claim 3, wherein said preset simulation platform architecture further comprises an associated system platform, a Mock switch is provided in said Mock platform; before the process of retrieving the simulation information database according to the real-time request information and the request entry thereof to obtain the return information corresponding to the real-time request, the method further comprises the following steps:
judging whether the MOCK switch needs to be started or not according to the real-time request information;
if the MOCK switch is judged to need to be started, searching the simulation information database according to the real-time request information and the request entry participation thereof so as to obtain return information corresponding to the real-time request and marking the return information as the return simulation information; and if the MOCK switch is judged not to be started, sending the real-time request information and the request entry parameter thereof to the associated system platform to obtain associated system return information, and recording the associated system return information as the return simulation information.
5. The Mock method according to claim 4, wherein said simulation information database is retrieved according to said real-time request information and its request entry parameters to obtain the return information corresponding to said real-time request, said process of recording as said return simulation information comprises:
searching all return information associated with the real-time request information from the simulation information database;
and selecting corresponding return information from all the return information associated with the real-time request information based on the request participation of the real-time request information, and recording the corresponding return information as the return simulation information.
6. The Mock method according to claim 5, wherein the step of selecting corresponding return information from all the return information associated with the real-time request information based on the request parameter of the real-time request information, and the step of recording the corresponding return information as the return simulation information comprises the steps of:
matching and checking the request participation of the real-time request information with the request participation of all the return information according to a preset checking and matching rule;
and if the request participation of the real-time request information is matched with the request participation of the return information, recording the return information as the return simulation information.
7. The custom Mock platform based Mock method according to claim 6, wherein said ESG service administration platform and said associated system platform are interfaced with said Mock platform by means of a batch registration link.
8. A Mock system based on a custom Mock platform, the system comprising:
the database establishing unit is used for establishing a simulation information database according to the known information to be simulated; the information to be simulated comprises request information and return information;
the platform initialization unit is used for initializing a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform;
the information simulation unit is used for simulating returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
9. An electronic device, comprising: the system comprises a memory, a processor and a Mock program based on a custom Mock platform, wherein the Mock program based on the custom Mock platform is stored in the memory and can run on the processor, and when being executed by the processor, the Mock program based on the custom Mock platform realizes the following steps:
establishing a simulation information database according to known information to be simulated; the information to be simulated comprises request information and return information;
initializing a preset simulation platform framework according to the simulation information database; the preset simulation platform framework comprises a MOCK platform and an ESG service administration platform, and the ESG service administration platform is in butt joint with the MOCK platform;
simulating the returned information of the real-time request information acquired in the self-test system by matching the MOCK platform with the simulation information database; and the simulation result of the ESG type is transmitted to the test system after being transferred through the ESG service administration platform, and the simulation result of the HTTP type is directly transmitted to the test system through the MOCK platform.
10. A computer-readable storage medium, wherein a Mock program based on a custom Mock platform is stored in the computer-readable storage medium, and when the Mock program based on the custom Mock platform is executed by a processor, the steps in the Mock method based on the custom Mock platform according to any one of claims 1 to 7 are realized.
CN202011594829.0A 2020-12-29 2020-12-29 Mock method, system and device based on user-defined Mock platform and storage medium Pending CN112667508A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011594829.0A CN112667508A (en) 2020-12-29 2020-12-29 Mock method, system and device based on user-defined Mock platform and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011594829.0A CN112667508A (en) 2020-12-29 2020-12-29 Mock method, system and device based on user-defined Mock platform and storage medium

Publications (1)

Publication Number Publication Date
CN112667508A true CN112667508A (en) 2021-04-16

Family

ID=75411925

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011594829.0A Pending CN112667508A (en) 2020-12-29 2020-12-29 Mock method, system and device based on user-defined Mock platform and storage medium

Country Status (1)

Country Link
CN (1) CN112667508A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113472883A (en) * 2021-06-30 2021-10-01 平安国际智慧城市科技股份有限公司 Method, device and equipment for storing data based on block chain and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113472883A (en) * 2021-06-30 2021-10-01 平安国际智慧城市科技股份有限公司 Method, device and equipment for storing data based on block chain and storage medium

Similar Documents

Publication Publication Date Title
US10237295B2 (en) Automated event ID field analysis on heterogeneous logs
CN104040521B (en) Biological characteristic cloud communication and data move
CN106572173A (en) Method, apparatus and system for updating configuration information
EP2799995A1 (en) Information interaction test device and method based on automatic generation of associated test cases
CN113194004B (en) Network topology construction method and device, and network change processing method and device
CN107332750A (en) A kind of service deployment method, device and network element
CN108696511A (en) A kind of public notification of information method, apparatus and relevant device based on block chain
CN105827683A (en) Data synchronization method, server and electronic device
WO2021174877A1 (en) Processing method for smart decision-based target detection model, and related device
CN110535971A (en) Interface configuration processing method, device, equipment and storage medium based on block chain
CN104133765B (en) The test case sending method of network activity and test case server
US10594804B2 (en) Directory service discovery and/or learning
CN113268336B (en) Service acquisition method, device, equipment and readable medium
CN109493087A (en) A kind of method, computer installation and computer readable storage medium based on two dimensional code examination Immovable Property Registration information
CN109542757A (en) Interface testing environment determines method, apparatus, electronic equipment and storage medium
CN105786581A (en) Multistage server and method for network data operation
CN111224878B (en) Route forwarding method and device, electronic equipment and storage medium
CN112667508A (en) Mock method, system and device based on user-defined Mock platform and storage medium
CN108520481A (en) House type is quoted and the method, apparatus and computer storage media of house type partition
CN101847151A (en) Information processor, electronic file managing device, electronic file managing system, and method thereof
CN111538672A (en) Test case layered test method, computer device and computer-readable storage medium
CN111045928A (en) Interface data testing method, device, terminal and storage medium
CN110377811A (en) A kind of display methods of device name, device, storage medium and electronic equipment
CN110177096A (en) Client certificate method, apparatus, medium and calculating equipment
CN114968822A (en) Interface testing method and device, computer equipment and storage medium

Legal Events

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