CN115220822A - Method and device for realizing interface baffle - Google Patents

Method and device for realizing interface baffle Download PDF

Info

Publication number
CN115220822A
CN115220822A CN202210623242.0A CN202210623242A CN115220822A CN 115220822 A CN115220822 A CN 115220822A CN 202210623242 A CN202210623242 A CN 202210623242A CN 115220822 A CN115220822 A CN 115220822A
Authority
CN
China
Prior art keywords
interface
template
scene
information
acquiring
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
CN202210623242.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.)
Boc Financial Technology Co ltd
Original Assignee
Boc Financial Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Boc Financial Technology Co ltd filed Critical Boc Financial Technology Co ltd
Priority to CN202210623242.0A priority Critical patent/CN115220822A/en
Publication of CN115220822A publication Critical patent/CN115220822A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention provides a method and a device for realizing an interface baffle, wherein the method comprises the following steps: after receiving an interface calling request, analyzing the calling request to obtain corresponding scene information; acquiring interface configuration parameters corresponding to a scene from a pre-configured interface configuration file according to the scene information, and acquiring a target template corresponding to the scene from a pre-configured template file according to the scene information; and acquiring a data packet corresponding to the interface calling request from the target template according to the calculation result of the interface configuration parameters. According to the method, the data packet corresponding to the interface calling request is obtained from the target template according to the calculation result of the interface configuration parameters, so that a user can realize the baffle function in a template configuration mode, the complexity of realizing the baffle function is reduced, and the baffle application efficiency is improved. The functions of some complex template files can be realized by customizing each template in the template files, so that the function of customized return information of the baffle is stronger.

Description

Method and device for realizing interface baffle
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for realizing an interface baffle.
Background
In some cross-system performance test projects, due to the limitation of objective factors such as limited test hardware resources and coordination among multiple systems, a complete test environment cannot be built to complete the test work. At this time, we will generally build the system under test and then use a software program, which is generally called a baffle, to simulate the functions of other related systems.
In the application development testing stage, developers or testers often need to adjust background related interfaces, and due to the problems of environment, configuration and the like, a large amount of time and labor are consumed for preparation. The general baffle program needs a developer to write codes and perform targeted development, and has the defects of inflexibility, complex preparation, numerous baffles, difficulty in maintenance and management and the like.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a method and a device for realizing an interface baffle.
The invention provides a method for realizing an interface baffle, which comprises the following steps: after receiving an interface calling request, analyzing the calling request to obtain corresponding scene information; acquiring interface configuration parameters corresponding to a scene from a pre-configured interface configuration file according to the scene information, and acquiring a target template corresponding to the scene from a pre-configured template file according to the scene information; and acquiring a data packet corresponding to the interface calling request from the target template according to the calculation result of the interface configuration parameters.
According to the implementation method of the interface baffle, before the target template corresponding to the scene is obtained from the pre-configured template file, the method also comprises the steps of receiving the configuration content of each template to obtain the template file; wherein the configuration content includes success return information, failure return information, and timeout return information for each template.
According to the method for implementing an interface baffle provided by the present invention, before acquiring interface configuration parameters corresponding to a scene from a pre-configured interface configuration file, the method further comprises: receiving the configuration of each template interface configuration parameter to obtain the interface configuration file; the interface configuration parameters comprise success rate, failure rate, timeout rate and timeout time of each template.
According to the implementation method of the interface baffle provided by the invention, the acquiring a data packet corresponding to an interface calling request from the target template according to the calculation result of the interface configuration parameter comprises the following steps: and determining the returned information of the success, failure or overtime of the template according to the simulation results of the success rate, the failure rate and the overtime rate in the interface configuration parameters.
According to the method for implementing an interface baffle provided by the invention, the step of obtaining the target template corresponding to the scene from the pre-configured template file according to the scene information comprises the following steps: acquiring a candidate template corresponding to a scene from a pre-configured template file; and according to the scene information, under the condition that a user-defined function is determined to be required to be called, the user-defined function is called according to the candidate template, and then the target template is obtained.
According to the method for implementing the interface baffle provided by the invention, the scene information includes serial number configuration information, and correspondingly, the obtaining of the target template corresponding to the scene from the pre-configured template file includes: and acquiring a target template corresponding to the serial number configuration information from a pre-configured template file according to the serial number configuration information.
The invention also provides a device for realizing the interface baffle, which comprises: the request service module is used for analyzing the call request after receiving the interface call request to obtain corresponding scene information; the interface configuration module is used for acquiring interface configuration parameters corresponding to a scene from a pre-configured interface configuration file according to the scene information; the template loading module is used for acquiring a target template corresponding to a scene from a pre-configured template file according to the scene information; and the request service module is also used for acquiring a data packet corresponding to the interface calling request from the target template according to the calculation result of the interface configuration parameters.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the program to realize the implementation method of the interface baffle.
The invention also provides a non-transitory computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method of implementing an interface shutter as described in any one of the above.
The invention also provides a computer program product comprising a computer program which, when executed by a processor, implements a method of implementing an interface baffle as described in any one of the above.
According to the method and the device for realizing the interface baffle, the target template corresponding to the scene is obtained from the pre-configured template file, the data packet corresponding to the interface calling request is obtained from the target template according to the calculation result of the interface configuration parameter, so that a user can realize the baffle function in a template configuration mode, the complexity of realizing the baffle function is reduced, and the baffle application efficiency is improved. The functions of some complex template files can be realized by customizing each template in the template file, so that the function of customized return information of the baffle is stronger.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
FIG. 1 is a schematic flow chart of a method for implementing an interface shutter according to the present invention;
fig. 2 is one of the schematic structural diagrams of the implementation apparatus of the interface baffle provided by the present invention;
fig. 3 is a second schematic structural diagram of an implementation apparatus of an interface baffle provided by the present invention;
fig. 4 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The method and apparatus for implementing the interface barrier of the present invention are described below with reference to fig. 1-4. Fig. 1 is a schematic flow chart of an implementation method of an interface baffle provided by the present invention, and as shown in fig. 1, the implementation method of the interface baffle provided by the present invention includes:
101. after receiving an interface calling request, analyzing the calling request to obtain corresponding scene information.
And analyzing the received interface calling request, for example, analyzing according to the URL request in the interface test to obtain different scenes.
102. And acquiring interface configuration parameters corresponding to the scene from a pre-configured interface configuration file according to the scene information, and acquiring a target template corresponding to the scene from a pre-configured template file according to the scene information.
In the invention, different templates are respectively compiled in advance according to different scenes and stored in a template file. Each template can comprise different success return information, failure return information and overtime return information, and the success template, the failure template or the overtime template can be called according to different URL requests in the interface test, and the return information is generated and returned to a calling party.
In addition, the invention also configures interface configuration parameters of different templates according to different scenes. The interface configuration parameters are stored in an interface configuration file. And reading the interface configuration parameters from the interface configuration file according to the scene of the request information.
103. And acquiring a data packet corresponding to the interface calling request from the target template according to the calculation result of the interface configuration parameters.
Each interface template comprises a plurality of template information, such as successfully returned template information and unsuccessfully returned template information. And calculating according to the acquired interface configuration parameters to obtain template information which should be returned in the target template, generating a corresponding data packet according to the returned template information, and sending the data packet to the request.
According to the method for realizing the interface baffle, the target template corresponding to the scene is obtained from the pre-configured template file, the data packet corresponding to the interface calling request is obtained from the target template according to the calculation result of the interface configuration parameters, and the user can realize the baffle function in a template configuration mode, so that the complexity of realizing the baffle function is reduced, and the baffle application efficiency is improved. The functions of some complex template files can be realized by customizing each template in the template file, so that the function of customized return information of the baffle is stronger.
In an embodiment, before obtaining a target template corresponding to a scene from a pre-configured template file, the method further includes receiving configuration content of each template to obtain the template file; wherein the configuration content comprises successful return information, failed return information and overtime return information of each template.
Specifically, before 101, the configuration content of each template is configured in advance, and a template file is generated. The configuration content may include success return information, failure return information, serial number configuration, triggering failure return condition, interface URL, and the like.
In an embodiment, before the obtaining the interface configuration parameters corresponding to the scene from the pre-configured interface configuration file, the method further includes: receiving the configuration of each template interface configuration parameter to obtain the interface configuration file; the interface configuration parameters comprise success rate, failure rate, timeout rate and timeout time of each template.
Before 101, configuring parameters of each template interface in advance, including parameters such as success rate, failure rate, timeout time and the like.
In an embodiment, the obtaining a data packet corresponding to an interface invocation request from the target template according to the calculation result of the interface configuration parameter includes: and determining the returned information of the success, failure or overtime of the template according to the simulation results of the success rate, the failure rate and the overtime rate in the interface configuration parameters.
For example, if the success rate is 80%, a is generated by simulating the probability of a random number of 80%, and if the simulation result of this time is a, successful template information is returned. The same applies for the case of failure and timeout.
In an embodiment, the obtaining, according to the scene information, a target template corresponding to a scene from a pre-configured template file includes: acquiring a candidate template corresponding to a scene from a pre-configured template file; and according to the scene information, under the condition that a user-defined function is determined to be called, the user-defined function is called according to the candidate template, and then the target template is obtained.
According to the actual needs of users, the user-defined function can be compiled for calling in the template file. By the method, the diversity of the template is improved, and the function of customized baffle return information is stronger.
In an embodiment, the scene information includes serial number configuration information, and accordingly, the obtaining a target template corresponding to a scene from a pre-configured template file includes: and acquiring a target template corresponding to the serial number configuration information from a pre-configured template file according to the serial number configuration information.
The serial number configuration information is added to the request information, and the serial number configuration information is also added to each template in the template file. After the serial number configuration information in the request information is analyzed, the same serial number configuration information is searched according to the template file, and the target template corresponding to the requested scene can be obtained. By the method, the efficiency of searching the target template can be improved.
The following describes the implementation apparatus of the interface baffle provided by the present invention, and the implementation apparatus of the interface baffle described below and the implementation method of the interface baffle described above may be referred to correspondingly.
Fig. 2 is a schematic structural diagram of an implementation apparatus of an interface baffle provided in the present invention, and as shown in fig. 2, the implementation apparatus of the interface baffle includes: a first module 201 and a second module 202. The request service module 201 is configured to, after receiving an interface call request, analyze the call request to obtain corresponding scene information; the interface configuration module 202 is configured to obtain interface configuration parameters corresponding to a scene from a pre-configured interface configuration file according to the scene information; the template loading module 203 is configured to obtain a target template corresponding to a scene from a pre-configured template file according to the scene information; the request service module 201 is further configured to obtain a data packet corresponding to the interface call request from the target template according to the calculation result of the interface configuration parameter.
In an embodiment, the template loading module 203 is further configured to receive configuration content of each template, to obtain the template file; wherein the configuration content comprises successful return information, failed return information and overtime return information of each template.
In an embodiment, the interface configuration module 202 is further configured to receive an interface configuration parameter of each template, and obtain the interface configuration file; the interface configuration parameters comprise success rate, failure rate, timeout rate and timeout time of each template.
In one embodiment, the request service module 201 is further configured to: and determining the returned information of the success, failure or overtime of the template according to the simulation results of the success rate, the failure rate and the overtime rate in the interface configuration parameters.
Fig. 3 is a second schematic structural diagram of an implementation apparatus of an interface barrier provided by the present invention, as shown in fig. 3, in an embodiment, the second schematic structural diagram further includes a custom function module 204, and accordingly, the template loading module 203 is further configured to: acquiring a candidate template corresponding to a scene from a pre-configured template file; and according to the scene information, under the condition that the user-defined function is determined to be required to be called, calling the user-defined function of the user-defined function module 204 according to the candidate template to obtain the target template. Reference may be made to the above method embodiments, which are not described herein again.
In an embodiment, the scenario information includes serial number configuration information, and accordingly, the template loading module 203 is further configured to: and acquiring a target template corresponding to the serial number configuration information from a pre-configured template file according to the serial number configuration information.
The device embodiment provided in the embodiments of the present invention is for implementing the above method embodiments, and for details of the process and the details, reference is made to the above method embodiments, which are not described herein again.
The implementation principle and the technical effect of the implementation device of the interface baffle provided in the embodiment of the present invention are the same as those of the implementation method embodiment of the interface baffle, and for brief description, reference may be made to the corresponding content in the implementation method embodiment of the interface baffle where no part of the implementation device embodiment of the interface baffle is mentioned.
Fig. 4 is a schematic structural diagram of an electronic device provided in the present invention, and as shown in fig. 4, the electronic device may include: a processor (processor) 401, a communication Interface (Communications Interface) 402, a memory (memory) 403 and a communication bus 404, wherein the processor 401, the communication Interface 402 and the memory 403 communicate with each other through the communication bus 404. Processor 401 may call logic instructions in memory 403 to perform a method of implementing an interface barrier, the method comprising: after receiving an interface calling request, analyzing the calling request to obtain corresponding scene information; acquiring interface configuration parameters corresponding to a scene from a pre-configured interface configuration file according to the scene information, and acquiring a target template corresponding to the scene from a pre-configured template file according to the scene information; and acquiring a data packet corresponding to the interface calling request from the target template according to the calculation result of the interface configuration parameters.
In addition, the logic instructions in the memory 403 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, the computer program product comprising a computer program, the computer program being storable on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, a computer is capable of executing a method for implementing an interface shutter provided by the above methods, the method comprising: after receiving an interface calling request, analyzing the calling request to obtain corresponding scene information; acquiring interface configuration parameters corresponding to a scene from a pre-configured interface configuration file according to the scene information, and acquiring a target template corresponding to the scene from a pre-configured template file according to the scene information; and acquiring a data packet corresponding to the interface calling request from the target template according to the calculation result of the interface configuration parameters.
In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, the computer program being implemented by a processor to perform a method for implementing an interface barrier provided by the above methods, the method comprising: after receiving an interface calling request, analyzing the calling request to obtain corresponding scene information; acquiring interface configuration parameters corresponding to a scene from a pre-configured interface configuration file according to the scene information, and acquiring a target template corresponding to the scene from a pre-configured template file according to the scene information; and acquiring a data packet corresponding to the interface calling request from the target template according to the calculation result of the interface configuration parameters.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. An implementation method of an interface baffle, comprising:
after receiving an interface calling request, analyzing the calling request to obtain corresponding scene information;
acquiring interface configuration parameters corresponding to a scene from a pre-configured interface configuration file according to the scene information, and acquiring a target template corresponding to the scene from a pre-configured template file according to the scene information;
and acquiring a data packet corresponding to the interface calling request from the target template according to the calculation result of the interface configuration parameters.
2. The method for implementing an interface baffle according to claim 1, wherein before the target template corresponding to the scene is obtained from the pre-configured template file, the method further comprises receiving configuration content of each template to obtain the template file;
wherein the configuration content includes success return information, failure return information, and timeout return information for each template.
3. The method for implementing an interface baffle according to claim 1, wherein before the obtaining the interface configuration parameters corresponding to the scene from the pre-configured interface configuration file, the method further comprises:
receiving interface configuration parameters of each template to obtain the interface configuration file;
the interface configuration parameters comprise success rate, failure rate, timeout rate and timeout time of each template.
4. The method for implementing an interface mask according to claim 3, wherein the obtaining a data packet corresponding to an interface invocation request from the target template according to the calculation result of the interface configuration parameter includes:
and determining the returned information of the success, failure or overtime of the template according to the simulation results of the success rate, the failure rate and the overtime rate in the interface configuration parameters.
5. The method for implementing an interface baffle according to claim 1, wherein the obtaining a target template corresponding to a scene from a pre-configured template file according to the scene information comprises:
acquiring a candidate template corresponding to a scene from a pre-configured template file;
and according to the scene information, under the condition that a user-defined function is determined to be called, the user-defined function is called according to the candidate template, and then the target template is obtained.
6. The method for implementing an interface baffle according to claim 1, wherein the scene information includes serial number configuration information, and accordingly, the obtaining a target template corresponding to a scene from a pre-configured template file includes:
and acquiring a target template corresponding to the serial number configuration information from a pre-configured template file according to the serial number configuration information.
7. An interface baffle implementation apparatus, comprising:
the request service module is used for analyzing the calling request after receiving the interface calling request to obtain corresponding scene information;
the interface configuration module is used for acquiring interface configuration parameters corresponding to a scene from a pre-configured interface configuration file according to the scene information;
the template loading module is used for acquiring a target template corresponding to a scene from a pre-configured template file according to the scene information;
and the request service module is also used for acquiring a data packet corresponding to the interface calling request from the target template according to the calculation result of the interface configuration parameters.
8. An electronic 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 implementing an interface shutter according to any one of claims 1 to 6 when executing the program.
9. A non-transitory computer-readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the method of implementing an interface shutter according to any one of claims 1 to 6.
10. A computer program product comprising a computer program, wherein the computer program when executed by a processor implements a method of implementing an interface shutter according to any one of claims 1 to 6.
CN202210623242.0A 2022-06-01 2022-06-01 Method and device for realizing interface baffle Pending CN115220822A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210623242.0A CN115220822A (en) 2022-06-01 2022-06-01 Method and device for realizing interface baffle

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210623242.0A CN115220822A (en) 2022-06-01 2022-06-01 Method and device for realizing interface baffle

Publications (1)

Publication Number Publication Date
CN115220822A true CN115220822A (en) 2022-10-21

Family

ID=83608868

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210623242.0A Pending CN115220822A (en) 2022-06-01 2022-06-01 Method and device for realizing interface baffle

Country Status (1)

Country Link
CN (1) CN115220822A (en)

Similar Documents

Publication Publication Date Title
CN112699034B (en) Virtual login user construction method, device, equipment and storage medium
CN113806037A (en) Service calling method and device, storage medium and electronic equipment
CN117056240B (en) Data element development and debugging method and system supporting offline Jar package
CN112650689A (en) Test method, test device, electronic equipment and storage medium
CN111309624A (en) Test method, device, equipment and storage medium
CN110248030A (en) Test method, device, equipment and the storage medium of short message compensation mechanism
US11368554B2 (en) Systems and methods for regulating service behavior
CN112860398A (en) Data processing method, device, equipment and medium based on rule engine
CN112561690A (en) Method, system, equipment and storage medium for testing credit card staging service interface
CN114895879B (en) Management system design scheme determining method, device, equipment and storage medium
CN115220822A (en) Method and device for realizing interface baffle
CN113452575B (en) Service test method, system, device and storage medium
CN114817024A (en) Use case generation method and device, equipment and storage medium
CN115576711A (en) Method and system for simulating returned data and computing equipment
CN114003500A (en) Software testing method and device
CN113760707A (en) Interface testing method, device, equipment and computer readable storage medium
CN112199092A (en) Application development method and device and electronic equipment
CN114116244A (en) Data processing method, device and system, electronic equipment and storage medium
CN113110830B (en) Component-based mobile application program generation method and device
CN111324368A (en) Data sharing method and server
CN114499729B (en) Virtual machine time synchronization method, device and storage medium
CN115994098B (en) Analysis method and system for software operation abnormality based on artificial intelligence
CN117331754B (en) Abnormality problem reduction method, abnormality problem reduction system, electronic device, and computer storage medium
CN117240746A (en) Method, system, equipment and medium for starting baffle based on contract test
CN118820079A (en) Software testing method, system, electronic 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