CN111679980A - Background data simulation method and device - Google Patents

Background data simulation method and device Download PDF

Info

Publication number
CN111679980A
CN111679980A CN202010495026.3A CN202010495026A CN111679980A CN 111679980 A CN111679980 A CN 111679980A CN 202010495026 A CN202010495026 A CN 202010495026A CN 111679980 A CN111679980 A CN 111679980A
Authority
CN
China
Prior art keywords
data
request
simulation
interaction request
data interaction
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
CN202010495026.3A
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.)
Bank of China Ltd
Original Assignee
Bank of China 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 Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202010495026.3A priority Critical patent/CN111679980A/en
Publication of CN111679980A publication Critical patent/CN111679980A/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/362Software debugging

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)
  • Debugging And Monitoring (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention provides a background data simulation method and a background data simulation device, wherein the method comprises the following steps: intercepting a data interaction request initiated to a background by a front-end module; determining whether the data interaction request is a simulation request or not by utilizing a preset false data set according to the data interaction request; wherein, the false data set records: whether the data interaction request is the identifier of the simulation request or not and the corresponding relation between the simulation request and the simulation data responding to the simulation request; under the condition that the data interaction request is determined to be a simulation request, simulation data corresponding to the data interaction request is determined according to the dummy data set; the analog data is sent to a front end module. The method realizes data simulation without background, thereby needing not to restart the background for many times and improving the efficiency of data simulation; and a reverse proxy server is not required to be built, so that the development cost is reduced.

Description

Background data simulation method and device
Technical Field
The invention relates to the technical field of application program development, in particular to a background data simulation method and device.
Background
Background data simulation is always an indispensable ring in the development process in the front-end development of an application program, and the current common method is to simulate business data through a background. However, this has the following problems:
when data needs to be modified according to debugging requirements, a front-end developer needs to modify a background used for simulating service data, and the front-end developer is generally not familiar with a technical stack front-end developer of the background;
after the background finishes data modification, the data can take effect only after being restarted, when the data needs to be adjusted continuously, the background needs to be restarted continuously, and the efficiency of data simulation is low;
when the front-end project is connected with the background simulation data, a reverse proxy server is required to be built for solving the cross-domain problem, but the environment building cost is high.
Disclosure of Invention
The embodiment of the invention provides a background data simulation method which can be completed only by a front end and has high efficiency and low cost, and the method comprises the following steps:
intercepting a data interaction request initiated to a background by a front-end module;
determining whether the data interaction request is a simulation request or not by utilizing a preset dummy data set according to the data interaction request; wherein, the false data set records: judging whether the data interaction request is a simulation request or not, and responding to the corresponding relation between the simulation request and simulation data responding to the simulation request;
under the condition that the data interaction request is determined to be a simulation request, simulation data corresponding to the data interaction request is determined according to the dummy data set;
and sending the analog data corresponding to the data interaction request to the front-end module.
The embodiment of the invention also provides a background data simulation device, which is used for providing a background data simulation method which can be completed only by a front end and has high efficiency and low cost, and the device comprises:
the request intercepting module is used for intercepting a data interaction request initiated to the background by the front-end module;
the request judging module is used for determining whether the data interaction request is a simulation request or not by utilizing a preset false data set according to the data interaction request; wherein, the false data set records: judging whether the data interaction request is a simulation request or not, and responding to the corresponding relation between the simulation request and simulation data responding to the simulation request;
the simulation data determining module is used for determining simulation data corresponding to the data interaction request according to the dummy data set under the condition that the data interaction request is determined to be a simulation request;
and the result feedback module is used for sending the analog data corresponding to the data interaction request to the front-end module.
The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the background data simulation method when executing the computer program.
An embodiment of the present invention also provides a computer-readable storage medium, where a computer program for executing the above background data simulation method is stored in the computer-readable storage medium.
In the embodiment of the invention, a data interaction request initiated to a background by a front-end module is intercepted; determining whether the data interaction request is a simulation request or not by utilizing a preset false data set according to the data interaction request; under the condition that the data interaction request is a simulation request, determining simulation data corresponding to the data interaction request according to the dummy data set; sending the analog data corresponding to the data interaction request to a front-end module; data simulation can be carried out without background, so that the background does not need to be restarted for many times, and the efficiency of data simulation is improved; and a reverse proxy server is not required to be built, so that the development cost is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic diagram of a background data simulation method according to an embodiment of the present invention.
Fig. 2 is a schematic diagram of a specific implementation method of step 102 in the embodiment of the present invention.
FIG. 3 is a diagram illustrating a background data simulation process implemented in accordance with an embodiment of the present invention.
Fig. 4 is a schematic diagram of a background data simulation apparatus according to an embodiment of the present invention.
Fig. 5 is a schematic structural diagram of an electronic device for background data simulation according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention provides a background data simulation method, which is used for providing a background data simulation method which can be completed only by a front end and has high efficiency and low cost, and as shown in figure 1, the method comprises the following steps:
step 101: intercepting a data interaction request initiated to a background by a front-end module;
step 102: determining whether the data interaction request is a simulation request or not by utilizing a preset false data set according to the data interaction request;
step 103: under the condition that the data interaction request is determined to be a simulation request, simulation data corresponding to the data interaction request is determined according to the dummy data set;
step 104: and sending the analog data corresponding to the data interaction request to the front-end module.
Wherein, the false data set records: judging conditions of whether the data interaction request is a simulation request or not, and corresponding relations between the simulation request and simulation data responding to the simulation request.
As can be known from the flow shown in fig. 1, in the embodiment of the present invention, a data interaction request initiated to a background by a front-end module is intercepted; determining whether the data interaction request is a simulation request or not by utilizing a preset false data set according to the data interaction request; under the condition that the data interaction request is a simulation request, determining simulation data corresponding to the data interaction request according to the dummy data set; sending the analog data to a front-end module; data simulation can be carried out without background, so that the background does not need to be restarted for many times, and the efficiency of data simulation is improved; and a reverse proxy server is not required to be built, so that the development cost is reduced.
When the method is specifically implemented, a data interaction request initiated to a background by a front-end module is intercepted first. Because the communication between the front end and the background is based on the XML Http Request, which is referred to as XHR hereinafter, in the embodiment of the present invention, the data interaction Request specifically refers to an XHR Request, which is used for interacting data with the server, is an object on which the ajax function is realized, and is a data communication method of the lowest layer of the browser.
After a data interaction request initiated to a background by a front-end module is intercepted, whether the data interaction request is a simulation request or not is determined by utilizing a preset false data set according to the data interaction request. Wherein, the false data set records: judging conditions of whether the data interaction request is a simulation request or not, and corresponding relations between the simulation request and simulation data responding to the simulation request. In a specific embodiment, the determining condition is a condition for determining whether the data interaction request is a simulation request, and specifically may be, for example, an identifier of the data interaction request, a source of the data interaction request, or an attribute of the data interaction request. In the embodiment of the present invention, a plurality of sets of dummy data are preset in a dummy data set, and each set of dummy data includes: the judgment condition of the simulation request corresponds to the simulation data corresponding to the simulation request. In the actual project development process, some dummy data are often used to facilitate debugging of the program, and in the specific embodiment of the invention, all return results of the background are simulated by rewriting XHR to obtain simulated data in the dummy data set.
In the embodiment of the present invention, the identifier may be, for example, a URL (Uniform resource locator) of the data interaction request or an upload parameter, for example, www.test.com/method1 belongs to the identifier of the simulation request, and www.test.com/method2 belongs to the identifier of the real request.
According to the data interaction request, determining whether the data interaction request is a simulation request by using a preset dummy data set, where the specific process is as shown in fig. 2 and includes:
step 201: in the false data set, searching whether false data with the identification of the simulation request consistent with the identification of the data interaction request exists;
step 202: if so, determining the data interaction request as a simulation request;
step 203: and if the data interaction request does not exist, determining that the data interaction request is a real request.
And under the condition that the data interaction request is determined to be a simulation request, determining simulation data corresponding to the data interaction request according to the dummy data set. In specific implementation, the simulation data corresponding to the data interaction request is determined from the dummy data found in step 201.
And sending the simulation data corresponding to the determined data interaction request to the front-end module to complete background data simulation.
A specific example is given below to illustrate how embodiments of the present invention perform background data simulation. The software program designed by applying the background data simulation method mainly comprises the following modules:
a front-end service module: for invoking an XHR request that initiates a data interaction to the background.
A false data module: multiple sets of dummy data are stored, each set of dummy data including an identification of a simulation request (e.g., matched by URL) and corresponding simulation data.
A request routing module: the module is used for calling the false data and judging whether the XHR request is a real request or a simulated request.
A request replacement module: the XHR request sending module is used for sending the XHR request to the background directly according to the returned result of the request routing module if the request is a real request; if the request is a simulation request, a dummy data module is called, and simulation data corresponding to the XHR request is returned.
A front-end service module: for receiving the returned data.
In order to realize non-invasive simulation of background requests, a full simulation of a data communication method XML Http Request module (XHR module) at the bottom layer of a browser is required, and a specific process is shown in fig. 3. Firstly, judging by a routing module, and directly calling the XHR module to initiate a data request to a background if a real request is requested; and if the simulation request is received, all methods of the XHR module need to be rewritten, and corresponding simulation data in the dummy data set is called to simulate all returned results of the XHR module, so as to realize the simulation of the dummy data.
Real XHR requests are proxied to the local by intercepting the XHR requests and simulating the returned results of the XHR requests through a pure front-end language, so that simulation data are returned without a real background, and simulation of the XHR requests can be realized through Javascript codes run by the front end. And the process is non-invasive to the code initiating the XHR request, and the simulation of the service data can be realized without modifying the original service code. Therefore, the simulation of false data can be realized without a background and by a pure front end; the modified data, that is, the Javascript (JS) code of the modified simulation data, can be updated only by refreshing the page.
The implementation of the above specific application is only an example, and the rest of the embodiments are not described in detail.
Based on the same inventive concept, embodiments of the present invention further provide a background data simulation apparatus, and since the principle of the problem solved by the background data simulation apparatus is similar to that of the background data simulation method, the implementation of the background data simulation apparatus can refer to the implementation of the background data simulation method, and the repeated parts are not repeated, and the specific structure is as shown in fig. 4:
a request intercepting module 401, configured to intercept a data interaction request initiated by a front-end module to a background;
a request determining module 402, configured to determine whether the data interaction request is a simulation request according to the data interaction request by using a preset dummy data set; wherein, the false data set records: judging whether the data interaction request is a simulation request or not, and responding to the corresponding relation between the simulation request and simulation data responding to the simulation request;
a simulation data determining module 403, configured to determine, according to the dummy data set, simulation data corresponding to the data interaction request when the data interaction request is determined to be a simulation request;
and a result feedback module 404, configured to send the analog data corresponding to the data interaction request to the front-end module.
In a specific embodiment, a plurality of sets of dummy data are preset in the dummy data set, and each set of dummy data in the plurality of sets of dummy data includes: the simulation request identifies simulation data corresponding to the simulation request.
In specific implementation, the request determining module 402 is specifically configured to:
searching whether false data with the identification of the simulation request consistent with the identification of the data interaction request exists in the false data set;
if so, determining the data interaction request as a simulation request;
and if not, determining that the data interaction request is a real request.
In a specific implementation, the analog data determining module 403 is specifically configured to:
and determining the corresponding simulation data in the searched dummy data as the simulation data corresponding to the data interaction request.
The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the background data simulation method when executing the computer program.
The embodiment of the invention also provides a computer readable storage medium, which stores a computer program for executing the background data simulation method.
An embodiment of the present invention further provides an electronic device, and specifically, the electronic device may specifically include an intercepting device 501, a processor 502, and a returning device 503, referring to a schematic structural diagram of the background data simulation electronic device provided in this embodiment of the present application and shown in fig. 5. The intercepting device 501 may be specifically configured to intercept a data interaction request initiated by the front-end module to the background. The processor 502 may be specifically configured to determine whether the data interaction request is a simulation request according to the data interaction request by using a preset dummy data set; and under the condition that the data interaction request is determined to be a simulation request, determining simulation data corresponding to the data interaction request according to the dummy data set. The return device 503 may be specifically configured to send the analog data corresponding to the data interaction request to the front-end module.
In summary, the background data simulation method and apparatus provided in the embodiments of the present invention have the following advantages:
intercepting a data interaction request initiated to a background by a front-end module; determining whether the data interaction request is a simulation request or not by utilizing a preset false data set according to the data interaction request; under the condition that the data interaction request is a simulation request, determining simulation data corresponding to the data interaction request according to the dummy data set; sending the analog data corresponding to the data interaction request to a front-end module; data simulation can be carried out without background, so that the background does not need to be restarted for many times, and the efficiency of data simulation is improved; and a reverse proxy server is not required to be built, so that the development cost is reduced.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes may be made to the embodiment of the present invention by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for background data simulation, comprising:
intercepting a data interaction request initiated to a background by a front-end module;
determining whether the data interaction request is a simulation request or not by utilizing a preset dummy data set according to the data interaction request; wherein, the false data set records: judging whether the data interaction request is a simulation request or not, and responding to the corresponding relation between the simulation request and simulation data responding to the simulation request;
under the condition that the data interaction request is determined to be a simulation request, simulation data corresponding to the data interaction request is determined according to the dummy data set;
and sending the analog data corresponding to the data interaction request to the front-end module.
2. The method of claim 1, wherein a plurality of sets of dummy data are preset in the dummy data set, and each set of dummy data in the plurality of sets of dummy data includes: the simulation request identifies simulation data corresponding to the simulation request.
3. The method of claim 2, wherein determining whether the data interaction request is a simulation request using a preset dummy data set according to the data interaction request comprises:
searching whether false data with the identification of the simulation request consistent with the identification of the data interaction request exists in the false data set;
if so, determining the data interaction request as a simulation request;
and if not, determining that the data interaction request is a real request.
4. The method of claim 3, wherein determining, based on the dummy data set, simulated data corresponding to the data interaction request comprises:
and determining the corresponding simulation data in the found fake data as the simulation data corresponding to the data interaction request.
5. A background data simulator, comprising:
the request intercepting module is used for intercepting a data interaction request initiated to the background by the front-end module;
the request judging module is used for determining whether the data interaction request is a simulation request or not by utilizing a preset false data set according to the data interaction request; wherein, the false data set records: whether the data interaction request is the identifier of the simulation request or not and the corresponding relation between the simulation request and the simulation data responding to the simulation request;
the simulation data determining module is used for determining simulation data corresponding to the data interaction request according to the dummy data set under the condition that the data interaction request is determined to be a simulation request;
and the result feedback module is used for sending the analog data to the front-end module.
6. The apparatus of claim 5, wherein a plurality of sets of dummy data are preset in the dummy data set, and each set of dummy data in the plurality of sets of dummy data comprises: the simulation request identifies simulation data corresponding to the simulation request.
7. The apparatus of claim 6, wherein the request determination module is specifically configured to:
searching whether false data consistent with the identification of the data interaction request exists in the false data set;
if so, determining the data interaction request as a simulation request;
and if not, determining that the data interaction request is a real request.
8. The apparatus of claim 7, wherein the analog data determination module is specifically configured to:
and determining the corresponding simulation data in the found fake data as the simulation data corresponding to the data interaction request.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 4 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for executing the method of any one of claims 1 to 4.
CN202010495026.3A 2020-06-03 2020-06-03 Background data simulation method and device Pending CN111679980A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010495026.3A CN111679980A (en) 2020-06-03 2020-06-03 Background data simulation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010495026.3A CN111679980A (en) 2020-06-03 2020-06-03 Background data simulation method and device

Publications (1)

Publication Number Publication Date
CN111679980A true CN111679980A (en) 2020-09-18

Family

ID=72434703

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010495026.3A Pending CN111679980A (en) 2020-06-03 2020-06-03 Background data simulation method and device

Country Status (1)

Country Link
CN (1) CN111679980A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106681922A (en) * 2016-12-27 2017-05-17 广州唯品会信息科技有限公司 Simulation server response method and system
CN108345543A (en) * 2018-03-02 2018-07-31 财付通支付科技有限公司 A kind of data processing method, device, equipment and storage medium
US20180285490A1 (en) * 2017-03-31 2018-10-04 Change Healthcare Holdings, Llc Method, apparatus, and computer program product for simulating client and application interface integration
CN110597709A (en) * 2019-08-13 2019-12-20 平安国际智慧城市科技股份有限公司 Interactive debugging method and device for mixed-mode mobile application and computer equipment
CN111159039A (en) * 2019-12-30 2020-05-15 中信百信银行股份有限公司 Service simulation method, system, device and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106681922A (en) * 2016-12-27 2017-05-17 广州唯品会信息科技有限公司 Simulation server response method and system
US20180285490A1 (en) * 2017-03-31 2018-10-04 Change Healthcare Holdings, Llc Method, apparatus, and computer program product for simulating client and application interface integration
CN108345543A (en) * 2018-03-02 2018-07-31 财付通支付科技有限公司 A kind of data processing method, device, equipment and storage medium
CN110597709A (en) * 2019-08-13 2019-12-20 平安国际智慧城市科技股份有限公司 Interactive debugging method and device for mixed-mode mobile application and computer equipment
CN111159039A (en) * 2019-12-30 2020-05-15 中信百信银行股份有限公司 Service simulation method, system, device and storage medium

Similar Documents

Publication Publication Date Title
CN108293081B (en) Deep linking of program playback to mobile application state through user interface events
US8898643B2 (en) Application trace replay and simulation systems and methods
US10831463B2 (en) Intelligent software deployment on an IaaS platform
EP1576487B1 (en) Web server hit multiplier and redirector
CN108427631A (en) A kind of application test systems, method, electronic equipment and readable storage medium storing program for executing
CN111078539B (en) Test method, device, system and computer readable storage medium
CN110858172A (en) Automatic test code generation method and device
US20170132023A1 (en) Monitoring And Actuation Of View Controller Parameters To Reach Deep States Without Manual Developer Intervention
CN108255708B (en) Method, device, storage medium and equipment for accessing production file in test environment
CN113704110B (en) Automatic testing method and device for user interface
CN110196809B (en) Interface testing method and device
CN108984202B (en) Electronic resource sharing method and device and storage medium
CN108111364B (en) Service system testing method and device
CN111026634A (en) Interface automation test system, method, device and storage medium
CN114115904B (en) Information processing method, device, server and storage medium
CN117632710A (en) Method, device, equipment and storage medium for generating test code
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN112988588B (en) Client software debugging method and device, storage medium and electronic equipment
CN114116509A (en) Program analysis method, program analysis device, electronic device, and storage medium
CN110209565A (en) A kind of metadata schema adjustment method and its device
CN112579447A (en) Browser testing method and device
CN113495723B (en) Method, device and storage medium for calling functional component
CN113434384A (en) Pressure testing method and device
CN111338928A (en) Chrome-based browser testing method and device
CN111679980A (en) Background data simulation 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: 20200918