CN107294808B - Interface test method, device and system - Google Patents
Interface test method, device and system Download PDFInfo
- Publication number
- CN107294808B CN107294808B CN201710543989.4A CN201710543989A CN107294808B CN 107294808 B CN107294808 B CN 107294808B CN 201710543989 A CN201710543989 A CN 201710543989A CN 107294808 B CN107294808 B CN 107294808B
- Authority
- CN
- China
- Prior art keywords
- interface
- parameter
- modified
- server
- client
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/50—Testing arrangements
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/72—Code refactoring
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer And Data Communications (AREA)
- Debugging And Monitoring (AREA)
Abstract
The embodiment of the invention provides a method, a device and a system for testing an interface. The method comprises the following steps: after receiving a parameter modification request input by a user, determining a parameter to be modified and a receiver of the modified parameter according to the parameter modification request; the receiver comprises a client or a server, and the parameters to be modified comprise interface parameters in an interface request acquired from the client or interface return parameters in an interface response acquired from the server; and modifying the parameters to be modified according to the parameter modification request, and sending the modified parameters to a receiver. The method of the invention reduces the code capability requirement and the test difficulty of the interface test for the tester, improves the test efficiency, and also avoids the potential safety hazard caused by repeatedly modifying the code logic to the project in the prior art.
Description
Technical Field
The present invention relates to communications technologies, and in particular, to a method, an apparatus, and a system for interface testing.
Background
In large software projects, subtle imperfections can also cause fatal impacts to the project. In a conventional flow, a tester usually only pays attention to the normal function of user side software, but the function test cannot cover various complex conditions in a formal operation environment, and the test of an interface between a client and a server is a crucial link for data interaction in a software project. Common interfaces are classified into two major categories, HyperText Transfer Protocol (HTTP) and Transmission Control Protocol (TCP). When a TCP interface is tested, although a third-party packet capturing tool can capture binary stream data of the TCP interface, the captured data usually needs to be decrypted, and a user cannot manually modify transmission parameters, so that a test target of whether the bilateral performance of a server and a client is normal and stable under different interface parameters is difficult to achieve. To address this problem, the prior art proposes two test methods:
a) the script is adopted to replace the client to connect the server, and various interface requests of the client are simulated by modifying the local code logic of the script. After the script is modified and run, the verification of the interface request parameter corresponding to the interface can be completed by judging the performance of the server, and various conditions of the interface request parameter test can be covered by repeated operation for many times. The method aims to determine the stability of the server through interface test.
b) And manually modifying local code logic of the server, and simulating various returns of the server interface by specifying interface return parameters sent by the server to the client. The interface return parameters of the server are modified for many times, and then the performance of the client is checked, so that various conditions of the interface return parameter test can be covered. The method aims at determining the stability of the client by another method of interface testing.
However, in the two methods, the modification of local code logic requires code authority, so that the method has certain requirements on the code capability of testers, and has small test application range and higher difficulty; moreover, repeated modifications to the code logic may introduce new security risks to the project.
Disclosure of Invention
The embodiment of the invention provides a method, a device and a system for interface testing, which aim to solve the problems that local code logic needs to be modified when interface testing is carried out in the prior art, certain requirements are required on the code capability of testers, the test application range is small, and the difficulty is high; moreover, the technical problem that new potential safety hazards are brought into the project by repeatedly modifying the code logic is solved.
In a first aspect, an embodiment of the present invention provides an interface testing method, including:
after receiving a parameter modification request input by a user, determining a parameter to be modified and a receiver of the modified parameter according to the parameter modification request; the receiving party comprises the client or the server, and the parameters to be modified comprise interface parameters in an interface request acquired from the client or interface return parameters in an interface response acquired from the server;
and modifying the parameters to be modified according to the parameter modification request, and sending the modified parameters to the receiver.
In a second aspect, an embodiment of the present invention provides an interface testing apparatus, including: the device comprises a transmission module, a determination module and a modification module;
the determining module is used for determining the parameters to be modified and the receivers of the modified parameters according to the parameter modification requests after the transmission module receives the parameter modification requests input by the user; the receiving party comprises the client or the server, and the parameter to be modified comprises an interface parameter in an interface request acquired by the transmission module from the client, or an interface return parameter in an interface response acquired by the transmission module from the server;
the modification module is used for modifying the parameters to be modified according to the parameter modification request;
and the transmission module is used for sending the modified parameters to the receiving party.
In a third aspect, an embodiment of the present invention provides an interface test system, including: the system comprises a client, a server, a transfer server and a display end;
the transit server is configured to execute the method provided by the first aspect.
According to the method, the device and the system for interface testing provided by the embodiment of the invention, a user only needs to input a parameter modification request through a GUI (graphical user interface), namely only needs to inform the transfer server of what type of parameters are modified and why the type of parameters are modified, and the transfer server can assist in completing the interface testing between the client and the server based on the parameter modification request input by the user, so that the judgment of the bilateral stability of the client and the server is realized. According to the scheme, a user does not need to modify local code logic of the client or the server, the code capability requirement and the test difficulty of an interface test on a tester are reduced, the application range of the interface test personnel is improved, and potential safety hazards caused by repeated modification of the code logic on projects in the prior art are avoided. On the other hand, as can be seen from the above description of the technical solutions, in the embodiments of the present invention, the script is not needed to simulate the communication between the client and the server, but the actual client is used, and the user can not only learn the performance of the server through the interface response sent by the relay server to the display, but also learn the performance of the client when receiving the interface response of the server through the actual client.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic structural diagram of an interface test system according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a first method of interface testing according to an embodiment of the present invention;
fig. 3 is a signaling flowchart of a second embodiment of a method for testing an interface according to the present invention;
fig. 4 is a signaling flowchart of a third embodiment of a method for testing an interface according to the present invention;
FIG. 5 is a flowchart illustrating a fourth method for testing an interface according to the present invention;
FIG. 6 is a schematic structural diagram of a first apparatus for interface testing according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a second apparatus for interface testing according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, 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 for testing the interface provided by the embodiment of the invention can be applied to the interface testing system shown in fig. 1. As shown in fig. 1, the interface test system includes a client terminal 11, a transit server 12, a server terminal 13, and a GUI interface (or display terminal) 14. The client can be application software facing a user, and the server is a processing background of the application software. Optionally, the client, the server, the relay server, and the GUI interface may be respectively disposed on different hardware devices, for example, the client may be integrated on a mobile phone, the server may be integrated on a computer, the relay server may be integrated on another computer, and the GUI interface may be integrated on one display end; optionally, the client and the server may be integrated on one device, and the transit server and the GUI interface may be integrated on another device. The embodiment of the present invention does not limit the hardware devices integrated by the client, the server, the relay server, and the GUI interface, and it should be noted that all the devices integrated by the client, the server, the relay server, and the GUI interface in the embodiment of the present invention belong to the scope of protection of the present invention.
Further, the transit server may include a task scheduling module 31, a data parsing module 32, a data transmission module 33, a script recording module 34, an automation testing module 35, and an exception handling module 36. The transit server may perform the following method embodiments, with particular reference to the description of the following method embodiments.
The task scheduling module is mainly responsible for coordinating tasks submitted by users through a GUI interface, where the tasks may be parameter modification requests in the following embodiments, or may be automated test instructions in the following embodiments. The task scheduling module adopts Celery to perform task management. For example, when a user submits multiple parameter modification requests at one time, the task scheduling module automatically collects the task queue in order, that is, sorts the multiple parameter modification requests. After the transfer server executes one parameter modification request, the task scheduling module automatically activates the next parameter modification request. Through task scheduling processing, the transfer server can be ensured to execute tasks orderly, and the pressure on the aspect of multi-task processing is effectively reduced.
When the client and the server communicate through the TCP interface, data communicated between the client and the server are encrypted, and the data analysis module is mainly responsible for capturing binary data streams communicated between the client and the server. Optionally, the binary data stream includes the interface request and other data sent by the client to the server. Optionally, the binary data stream may also contain interface responses and other data sent by the server to the client. After the data analysis module captures the binary data stream, the binary stream data is analyzed into a data format that can be identified and processed by the transit server based on the communication protocol of the client and the server (i.e., the rule followed by the data interaction agreement between the client and the server). Because the structure of the encrypted data stream is complex, optionally, the data analysis module can only concern the interface request or the interface response in the data stream, and only extract and analyze the bytes corresponding to the interface request or the interface response, thereby greatly reducing the difficulty of data analysis.
And the data transmission module is mainly responsible for transmitting the data obtained by the data analysis module to a client or a server after the data is modified according to a parameter modification request input by a user through a GUI (graphical user interface). When the transfer server executes a parameter modification request, the data transmission module modifies the obtained data according to the specified parameter modification value in the parameter modification request, and after the data modification is completed, the data transmission module encrypts the data again (for example, the data is encrypted into a format which can be recognized by the client or the server), and then the data can be continuously sent to the client or the server. The module can conveniently realize the increase, deletion, modification and check of interface data, thereby realizing the modification test of directivity.
The script recording module and the automatic testing module are inseparable, and the two modules mainly relate to the automatic testing process in the following embodiment. The script recording module is mainly responsible for recording interface requests sent from the client to the server according to sending time, each recorded execution script can correspond to one or more expected test results, and the test results are interface responses of the server. The automatic test module sends the interface request in the recorded execution script to the server according to the sending time interval of each interface request in the execution script, and the transit server checks whether the interface response sent by the server meets the expected interface response after the data is sent, and gives a conclusion whether the performance of the server is stable.
The exception handling module is mainly responsible for capturing exceptions and reporting the exceptions in time. The system adopts a mode of integrating the instant messaging alarm robot, and when a certain module operates abnormally, a preset alarm prompt can be sent to a user. The exception handling module can automatically skip exceptions caused by errors in the task information submitted by the user, and ensures that other tasks submitted by the user can be executed as usual when the system is in the exceptions.
Before executing the following embodiments, the transit server needs to detect whether the connection between the transit server and the client or the server is normal, that is, whether the connection between the transit server and the client or the server is normal or not; firstly, starting a transfer server, and checking whether the connection between the transfer server and a server is normal or not by the transfer server; then the client connects with the transfer server, and the transfer server checks whether the client can normally communicate with the server through the transfer server. After confirming that the client and the server can normally communicate through the transit server, the following method embodiments are performed.
In the prior art, when an interface test is carried out, a user is often required to modify local code logic in a script of a simulation client or modify local code logic of a server, so that certain requirements are imposed on code capability of testers, the test application range is small, and the difficulty is high; moreover, repeated modifications to the code logic may introduce new security risks to the project. Further, in the prior art, the bilateral stability of the client and the server is obtained through interface testing, two different testing methods are often required, and the testing efficiency is low.
The method for testing the interface provided by the embodiment of the invention aims to solve the technical problems in the prior art. Optionally, the interface testing method provided in the embodiment of the present invention may be used for testing a TCP interface between a client and a server.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 2 is a schematic flowchart of a first embodiment of a method for testing an interface according to the present invention. The embodiment relates to a specific process that a user can carry out interface test only by inputting a parameter modification request to a transit server by arranging the transit server between a client and a server. Optionally, the execution subject in the embodiment of the present invention may be a transit server, and may also be other processing devices. The following embodiments take a transit server as an example to explain the whole technical solution. As shown in fig. 2, the method comprises the steps of:
s101; after receiving a parameter modification request input by a user, the transfer server determines parameters to be modified of the transfer server and a receiver of the modified parameters according to the parameter modification request.
The receiving party comprises the client or the server, and the parameter to be modified comprises an interface parameter in an interface request acquired by the transit server from the client, or an interface return parameter in an interface response acquired by the transit server from the server.
Specifically, in combination with the interface testing system shown in fig. 1, a user may input a parameter modification request through the GUI interface, and then the GUI interface may send the parameter modification request to the transit server. Optionally, the user may also input the parameter modification request by voice, for example, a voice control is displayed on the GUI interface, and the user may input the parameter modification request by voice by clicking the voice control.
After the transit server interfaces the parameter modification request, the parameters to be modified of the transit server can be determined according to the content in the parameter modification request, that is, which parameters are to be modified by the transit server and what parameter values the parameters are modified. Optionally, the transit server may further obtain a receiver of the modified parameter according to the parameter modification request, that is, the transit server determines to which object in the interface test system the modified parameter should be sent. Optionally, the parameter modification request may include an identifier of the parameter to be modified and a modification value corresponding to the parameter to be modified. Optionally, the receiver of the modified parameter may include a client or a server, and the parameter to be modified may include an interface parameter in an interface request acquired by the relay server from the client, or an interface return parameter in an interface response acquired by the relay server from the server.
S102: the transfer server modifies the parameters to be modified according to the parameter modification request and sends the modified parameters to the receiver.
Specifically, after the transfer server determines the parameter to be modified and the receiver of the modified parameter, the transfer server modifies the parameter to be modified according to the content of the parameter modification request, and sends the modified parameter to the determined receiver.
Optionally, the transit server may further send the modified parameter to the display end, so that the display end can display the modified parameter to the user. Optionally, the modified parameter may be an interface parameter in the modified interface request, or may be an interface return parameter in the modified interface response.
Optionally, the transfer server may further send the performance of the receiver to the display end for displaying, where the performance of the receiver may include at least one of an interface response of the server end and a performance of the client end. For example, if the interface response of the server is to the modified interface parameter, the relay server sends the received interface response to the display, so that the user can know whether the performance of the server is stable through the GUI interface. For another example, if the interface response of the server is to the interface parameter in the original interface request, the relay server will also send the interface response received from the server to the display for displaying. For another example, if the relay server modifies the interface return parameter in the interface response of the server, the relay server will send the modified interface return parameter to the client and the display, the client will have corresponding performance for the modified interface return parameter, and the relay server will also send the performance of the client to the display for display, where the performance of the client may be implemented in various ways such as corresponding function performance executed when the client receives different interface responses, duration and stability of processing the interface response, and the performance of the client may be directly obtained from the client or indirectly obtained from a log, and the like, and this is not limited here. Therefore, the user can not only know whether the performance of the client is stable through the client, but also know whether the performance of the client is stable through the GUI.
As can be seen from the above description, in the embodiment of the present invention, a user only needs to input a parameter modification request through a GUI interface, that is, only needs to inform the relay server what type of parameter is modified and why the type of parameter is modified, and the relay server can assist in completing an interface test between the client and the server based on the parameter modification request input by the user, so as to determine the stability of both sides of the client and the server. According to the scheme, a user does not need to modify local code logic of the client or the server, the code capability requirement and the test difficulty of an interface test on a tester are reduced, the application range of the interface test personnel is improved, and potential safety hazards caused by repeated modification of the code logic on projects in the prior art are avoided. On the other hand, as can be seen from the above description of the technical solutions, in the embodiments of the present invention, the script is not needed to simulate the communication between the client and the server, but the actual client is used, so that the user can not only know whether the performance of the server is stable by sending the performance of the receiver to the display through the relay server, but also know whether the performance of the client is stable when receiving the interface response of the server through the actual client or the performance of the receiver displayed by the display. Therefore, the embodiment of the invention can realize the detection of the stability of the both sides of the client and the server in the interface test by a test mode, thereby greatly improving the test efficiency.
Fig. 3 is a signaling flowchart of a second method for testing an interface according to the present invention. The embodiment relates to a specific process of realizing interface test of a client and a server by a transit server when parameters to be modified are interface parameters in an interface request. As shown in fig. 3, the method comprises the steps of:
s201: the client sends an interface request to the transfer server, and the interface request carries interface parameters.
Optionally, the interface parameter may be a length of a message transmitted by the client, a type of the message transmitted, and the like.
S202: the transfer server receives the interface request, and analyzes the interface request acquired from the client to obtain the interface parameters.
In this step, since the relay server predicts the communication protocol between the client and the server, the relay server analyzes the interface request sent by the client according to the communication protocol, converts the interface request into a processing format that can be recognized by the relay server, and obtains the interface parameters in the interface request. Optionally, the step may be performed by a data parsing module in the interface test system.
S203: the transfer server receives a parameter modification request input by a user through a GUI interface, determines the parameter to be modified of the transfer server as the interface parameter according to the identifier of the parameter to be modified in the parameter modification request, and determines a receiver of the modified interface parameter as a server.
Specifically, the user may input a parameter modification request through the GUI interface, and then the GUI interface sends the parameter modification request to the transit server. The parameter modification request carries an identifier of the parameter to be modified and a modification value corresponding to the parameter to be modified, so that the relay server can know that the parameter to be modified is an interface parameter in the interface request according to the parameter modification request and determine that a receiver of the modified interface parameter is a server, that is, the relay server knows that the interface parameter in the interface request should be modified and knows how to modify the interface parameters, and knows to send the modified interface parameter to the server.
In addition, as described above, the transit server monitors the interface request of the client first, and performs parameter modification only when monitoring the target interface request that needs to be modified.
S204: the transfer server modifies the interface parameters according to the modified values of the parameters to be modified, and carries the modified interface parameters in a new interface request to send the new interface request to the server.
In this step, the interface parameters in the interface request sent by the client to the server are modified, which is actually to detect the performance of the server under different interface parameters of the server, so as to determine whether the server is stable. Optionally, the performance of the server may include: the server side crashes, the server side sends normal interface response, and the server side sends abnormal interface response (namely, the interface return parameter in the interface response is abnormal).
Optionally, the step may be performed by a data transmission module in the interface test system.
S205: and the server receives the new interface request sent by the relay server and sends an interface response to the relay server according to the new interface request.
The interface response carries interface return parameters.
S206: and the transit server receives the interface response sent by the server.
Optionally, after the relay server receives the interface response of the server, the relay server may send the interface response to the display terminal for displaying, that is, displaying on the GUI interface of the display terminal, so that the user may know the interface return parameters in the interface response of the server, and further determine whether the performance of the server is stable.
Optionally, after the relay server receives the interface response of the server, the relay server may further send the received interface response to the client, and then the user obtains the stability of the client by detecting the performance of the client. Optionally, the transit server further sends the representation of the client to the display terminal. That is, the method of this embodiment does not need to use a script to simulate the communication between the client and the server, but uses an actual client, and the user can not only learn the performance of the server through the interface response sent by the relay server to the display, but also learn the performance of the client when receiving the interface response of the server through the actual client or the display.
It should be noted that, when a user inputs a plurality of parameter modification requests on the GUI interface, the relay server may sequence the plurality of parameter modification requests, determine an execution sequence of each parameter modification request, and then execute a process corresponding to the parameter modification request according to the execution sequence of each parameter modification request, where the process is the process from S201 to S206 in the embodiment of the present invention, or may be the process from S301 to S306 in the following embodiment. The operation that the transit server will sequence the parameter modification requests may be performed by the task scheduling module of the interface test system. By the task scheduling processing, the transfer server can be ensured to execute the tasks orderly, and the pressure on the aspect of multi-task processing is effectively reduced.
In the interface testing method provided in the embodiment of the present invention, when the relay server receives the interface request sent by the client, the relay server determines, according to the parameter modification request input by the user, that the parameter to be modified is the interface parameter in the interface request, and determines that the receiver of the modified interface parameter is the server, so that the relay server modifies the interface parameter according to the parameter modification request, and sends the modified interface parameter to the server, thereby receiving the interface response sent by the server for the modified interface parameter, optionally, the relay server can send the interface response to the display for display, so that the user can visually know the performance of the server through the GUI interface of the display, and can send the interface response to the actual client or send the performance method made by the client for the interface response to the display, the user can check the performance of the client through the actual GUI interface of the client or the display end to determine the stability of the client. That is, the method of this embodiment does not need to use a script to simulate the communication between the client and the server, but uses an actual client, and the user can not only learn the performance of the server through the interface response sent by the relay server to the display, but also learn the performance of the client when receiving the interface response of the server through the actual client. Furthermore, the embodiment of the invention does not need a user to modify the local code logic of the client or the server, and the user only needs to input a parameter modification request through a GUI interface, namely, only needs to inform the relay server of what type of parameters are modified and why the type of parameters are modified, so that the relay server can assist in completing the interface test between the client and the server based on the parameter modification request input by the user, thereby reducing the code capability requirement and the test difficulty of the interface test on testers, improving the application range of the interface test personnel, and avoiding the potential safety hazard caused by repeatedly modifying the code logic on projects in the prior art.
Fig. 4 is a signaling flowchart of a third embodiment of the interface testing method provided in the present invention. The embodiment relates to a specific process of realizing interface test of a client and a server through a transit server when parameters to be modified are interface return parameters in interface response. As shown in fig. 4, the method includes the steps of:
s301: the client sends an interface request to the transfer server, and the interface request carries interface parameters.
S302: the transfer server receives the interface request, and analyzes the interface request acquired from the client to obtain the interface parameters.
The specific processes of S301 and S302 may be referred to in S201 and S202, and are not described herein again.
Optionally, the step S302 may be an optional step, and after performing the following step S303, the transit server may determine not to modify the interface parameter in the interface request, so that the transit server may not need to perform an analysis action, so as to save the processing overhead of the transit server.
S303: the transfer server receives a parameter modification request input by a user through a GUI interface, determines the parameter to be modified of the transfer server as an interface return parameter in an interface response according to the identifier of the parameter to be modified in the parameter modification request, and determines a receiver of the modified interface return parameter as a client.
Specifically, the user may input a parameter modification request through the GUI interface, and then the GUI interface may transmit the parameter modification request to the transit server. The parameter modification request carries an identifier of the parameter to be modified and a modification value corresponding to the parameter to be modified, so that the relay server can know that the parameter to be modified is an interface return parameter in the interface response according to the parameter modification request, and determine that a receiver of the modified interface return parameter is a client, that is, the relay server knows that the interface return parameter in the interface response should be modified, knows how to modify the interface return parameters, and knows to send the modified interface return parameter to the client.
S304: and the transfer server sends the interface request acquired from the client to the server.
S305: and the transfer server receives the interface response sent by the server and modifies the interface return parameters in the interface response according to the modification value of the parameter to be modified.
Specifically, after receiving the interface response sent by the server, the relay server parses the interface response to obtain an interface return parameter in the interface response, and then modifies the interface return parameter in the interface response according to the result determined in the above step S203 to obtain a modified interface return parameter. Optionally, after receiving the interface response sent by the server, the relay server may also send the interface response to the display end, so that the user may know the performance of the server through the display end.
In this step, the interface return parameter in the interface response sent by the server to the client is modified, which is actually to detect the performance of the client under different interface return parameters of the client, so as to determine whether the client is stable.
In addition, as described above, the transit server monitors the interface request of the client and the interface response of the server, and performs parameter modification only when the target interface response that needs to be modified is monitored.
S306: and the transit server carries the modified interface return parameters in a new interface response and sends the new interface response to the client.
In this step, the relay server may carry the modified return parameter in a new interface response and send the new interface response to the client, optionally, the relay server may also send the modified interface return parameter to the display terminal for display, and optionally, the relay server may also send the performance of the client for the modified interface return parameter to the display terminal, so that the user may know the performance of the client through an actual client or a GUI interface of the display terminal.
Optionally, when the relay server identifies that the current parameter modification request is abnormal, the relay server may ignore the current parameter modification request and execute the next parameter modification request. This process may be performed by an exception handling module in the interface test system described above. The exception handling module is mainly responsible for capturing exceptions and reporting the exceptions to a user in time. The transfer server adopts a mode of integrating the instant messaging alarm robot, and when a certain module operates abnormally, the module can also send an appointed alarm prompt to a user in time.
In the interface testing method provided by the embodiment of the invention, when the relay server receives the interface request sent by the client, the relay server determines the parameter to be modified as the interface return parameter in the interface response according to the parameter modification request input by the user, and determines the receiver of the modified interface return parameter as the client, so that the relay server sends the interface request to the client, modifies the interface return parameter in the interface response after receiving the interface response sent by the server, and sends the modified interface return parameter to the client and/or the display, optionally, the relay server also sends the performance of the client for the modified interface return parameter to the display, so that the user can know whether the performance of the client is stable through the actual GUI interface of the client or the display, and acquiring the performance of the server through a GUI interface of the display end. That is, the method of this embodiment does not need to use a script to simulate the communication between the client and the server, but uses an actual client, and the user can not only learn the performance of the server through the interface response sent by the relay server to the display, but also learn the performance of the client when receiving the interface response of the server through the actual client. Furthermore, the embodiment of the invention does not need a user to modify the local code logic of the client or the server, and the user only needs to input a parameter modification request through a GUI interface, namely, only needs to inform the relay server of what type of parameters are modified and why the type of parameters are modified, so that the relay server can assist in completing the interface test between the client and the server based on the parameter modification request input by the user, thereby reducing the code capability requirement of the interface test on testers, improving the application range and the test difficulty of the interface test personnel, and avoiding the potential safety hazard caused by repeatedly modifying the code logic to the project in the prior art.
Fig. 5 is a schematic flowchart of a fourth method for testing an interface according to the present invention. In this embodiment, the automation implementation process of the embodiment shown in fig. 3 is involved, that is, in this embodiment, a user does not need to input a parameter modification request through a GUI interface, and the transfer server can complete an interface test only by inputting an automation test instruction through the GUI interface. As shown in fig. 5, the method includes the steps of:
s401: the transfer server sends an interface request to the server according to the sending time of the interface request in at least one preset execution script; wherein, the execution script comprises an interface request sent by at least one client.
Optionally, before S401, the relay server may obtain at least one execution script from communication data of the client and the server according to a preset interface request attention rule. The interface request attention rule represents an identifier of an interface request which should be attended by the transit server, or a characteristic of the interface request which should be attended by the transit server.
When the client and the server are in normal communication, the transfer server only monitors at least one interface request sent to the server by the client, and does not modify interface parameters. However, the transit server may predict which execution scripts it wants to record according to the monitored interface request according to a preset interface request attention rule. When the execution script is recorded, the transfer server records the interface request sent by the client to the server according to the sending time, and a plurality of interface requests within a predefined time length can form the execution script. Each execution script may correspond to one or more first interface responses, and an execution script includes at least one interface request. For example, it is assumed that the transit server learns the change of the interface request 5 that it should pay attention to according to a preset interface request attention rule. It is assumed that the first 5s interface request sent by the client to the server includes interface request 1, interface request 2, interface request 3, interface request 4, and interface request 5 (the value of interface parameter a in the interface request 5 is assumed to be X), and the second 5s interface request includes interface request 1, interface request 2, interface request 3, interface request 4, and interface request 6 (the interface parameter in the interface request 6 is also interface parameter a, and the value of a is assumed to be Y, that is, it can be considered that the interface parameter a changes from X to Y). That is, in each execution script recorded by the relay server, the value of the interface parameter of the interface request concerned by the relay server is different in different execution scripts. Taking interface request 5 and interface request 6 as examples, these two interface requests belong to different execution scripts, which actually reflect different values of the same interface parameter. Therefore, when the relay server sends the interface request in each execution script to the server, the at least one execution script recorded by the relay server is equivalent to testing the performance of the server under different interface parameters. Therefore, it can also achieve the purpose of interface testing.
Therefore, the transit server can send the interface request to the server according to the sending time of the interface request in the at least one pre-recorded execution script.
S402: the transfer server receives the interface response sent by the server, judges whether the received response is the same as a preset first interface response or not, and obtains a judgment result; and the first interface response is a preset response corresponding to the interface request.
S403: and the transfer server sends the judgment result to a display end.
Specifically, each execution script in the transit server may correspond to one or more first interface responses. Therefore, after the transit server receives the interface response of the server, whether the interface response is the same as the preset first interface response is judged. If the two are the same, the server is judged to be normal, and if the two are different, the server is judged to be abnormal. The user can visually acquire the performance of the server through the judgment result sent to the display end by the transfer server, so that the stability of the server is determined, and the purpose of interface testing is achieved.
As can be seen from the above description, the interface testing method provided in this embodiment greatly reduces repeated interface testing work through an automated implementation process, and a user does not need to input a parameter modification request on a GUI interface, thereby improving testing efficiency.
Fig. 6 is a schematic structural diagram of a first apparatus for interface testing according to an embodiment of the present invention. The interface testing device can be integrated on the transit server, and can be realized by software, hardware or a combination of software and hardware. As shown in fig. 6, the apparatus includes: a transmission module 21, a determination module 22 and a modification module 23;
a determining module 22, configured to determine, after the transmitting module 21 receives a parameter modification request input by a user, a parameter to be modified and a receiver of the modified parameter according to the parameter modification request; the receiving party includes the client or the server, and the parameter to be modified includes an interface parameter in an interface request acquired by the transmission module 21 from the client, or an interface return parameter in an interface response acquired by the transmission module 21 from the server;
a modification module 23, configured to modify the parameter to be modified according to the parameter modification request;
and the transmission module 21 is configured to send the modified parameters to the receiving party.
Optionally, the transmission module 21 is further configured to send the modified parameters and the performance of the receiving party to a display end; the performance of the recipient includes: at least one of an interface response of the server and a performance of the client.
Optionally, the parameter modification request carries an identifier of the parameter to be modified and a modification value corresponding to the parameter to be modified.
Optionally, the transmission module 21 and the modification module 23 in the embodiment of the present invention may be data transmission modules in the interface test system shown in fig. 1. Optionally, the determining module 22 may be a data parsing module in the interface testing system shown in fig. 1.
The device for testing the interface provided by the embodiment of the invention can execute the method embodiment, has similar realization principle and technical effect, and is not repeated herein.
As a possible implementation manner of the present invention, if the identifier of the parameter to be modified is the identifier of the interface parameter in the interface request; the determining module 22 is specifically configured to determine, according to the identifier of the parameter to be modified, that the parameter to be modified is the interface parameter, and determine that a receiver of the modified interface parameter is the server. Accordingly, on the basis of the embodiment shown in fig. 6, referring to fig. 7, the apparatus for testing an interface may further include: a parsing module 24;
the analysis module 24 is configured to analyze the interface request obtained from the client to obtain the interface parameter;
the modification module 23 is specifically configured to modify the interface parameter according to a modification value of the parameter to be modified;
the transmission module 21 is specifically configured to carry the modified interface parameters in a new interface request and send the new interface request to the server; and receiving an interface response sent by the server.
Optionally, the transmission module 21 may be further configured to send the interface response and the modified interface parameter to the display end for displaying, and send the interface response to the client.
Alternatively, the parsing module 24 and the determining module 22 may correspond to the data parsing module in the interface test system.
As another possible implementation manner of the present invention, if the identifier of the parameter to be modified is an identifier of an interface return parameter in the interface response; the determining module 22 is specifically configured to determine, according to the identifier of the parameter to be modified, that the parameter to be modified is the interface return parameter in the interface response, and determine that a receiver of the modified interface return parameter is the client.
Correspondingly, the transmission module 21 is further configured to send the interface request obtained from the client to the server; receiving an interface response sent by the server;
the modification module 23 is specifically configured to modify the interface return parameter according to the modified value of the parameter to be modified;
the transmission module 21 is further configured to carry the modified interface return parameter in a new interface response and send the new interface response to the client.
Optionally, the transmission module 21 may be further configured to send the modified interface return parameter to a display end for displaying.
Optionally, with continued reference to fig. 7 above, the apparatus further comprises: a scheduling module 25;
the scheduling module 25 is configured to, when the transmission module 21 receives a plurality of parameter modification requests input by a user, sequence the plurality of parameter modification requests, and determine an execution sequence of each parameter modification request; and executing the process corresponding to the parameter modification request according to the execution sequence of each parameter modification request.
Optionally, with continued reference to fig. 7 above, the apparatus further comprises: an exception handling module 26;
the exception handling module 26 is configured to, when the current parameter modification request is identified as being abnormal, ignore the current parameter modification request, and execute a next parameter modification request.
Optionally, the scheduling module 25 may correspond to a task scheduling module in the interface testing system shown in fig. 1, and the exception handling module 26 may correspond to an exception handling module in the interface testing system shown in fig. 1.
The device for testing the interface provided by the embodiment of the invention can execute the method embodiment, has similar realization principle and technical effect, and is not repeated herein.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
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 units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods 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.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
Claims (11)
1. A method for interface testing is applied to a transit server, and comprises the following steps:
after receiving a parameter modification request input by a user, determining a parameter to be modified and a receiver of the modified parameter according to the parameter modification request; the receiving party comprises a client or a server, and the parameters to be modified comprise interface parameters in an interface request acquired from the client or interface return parameters in an interface response acquired from the server;
modifying the parameter to be modified according to the parameter modification request, and sending the modified parameter to the receiver;
if the identifier of the parameter to be modified is the identifier of the interface return parameter in the interface response; the determining, according to the parameter modification request, the parameter to be modified and the receiver of the modified parameter specifically include:
determining the parameter to be modified as an interface return parameter in the interface response according to the identifier of the parameter to be modified, and determining a receiver of the modified interface return parameter as the client;
sending the modified parameters and the performance of the receiver to a display end; the performance of the recipient includes: a performance of the client;
wherein, the parameter modification request carries the identifier of the parameter to be modified and the modification value corresponding to the parameter to be modified;
if the identifier of the parameter to be modified is the identifier of the interface parameter in the interface request; the determining, according to the parameter modification request, the parameter to be modified and the receiver of the modified parameter specifically include:
determining the parameter to be modified as the interface parameter according to the identifier of the parameter to be modified, and determining a receiver of the modified interface parameter as the server;
modifying the parameter to be modified according to the parameter modification request, and sending the modified parameter to the receiver, which specifically includes:
analyzing the interface request acquired from the client to obtain the interface parameters;
modifying the interface parameters according to the modified values of the parameters to be modified, and carrying the modified interface parameters in a new interface request to send to the server;
and receiving an interface response sent by the server.
2. The method of claim 1,
the performance of the recipient further comprises: and the interface of the server side responds.
3. The method according to claim 1, wherein modifying the parameter to be modified according to the parameter modification request, and sending the modified parameter to the receiving party, specifically includes:
sending the interface request acquired from the client to the server;
receiving an interface response sent by the server, and modifying an interface return parameter in the interface response according to the modification value of the parameter to be modified;
and carrying the modified interface return parameters in a new interface response and sending the new interface response to the client.
4. The method according to any one of claims 1-3, further comprising:
if a plurality of parameter modification requests input by a user are received, sequencing the parameter modification requests, and determining the execution sequence of each parameter modification request;
and executing the process corresponding to the parameter modification request according to the execution sequence of each parameter modification request.
5. The method of claim 4, further comprising:
and when the current parameter modification request is identified to be abnormal, ignoring the current parameter modification request and executing the next parameter modification request.
6. An interface testing device, which is applied to a transit server, includes: the device comprises a transmission module, a determination module and a modification module;
the determining module is used for determining the parameters to be modified and the receivers of the modified parameters according to the parameter modification requests after the transmission module receives the parameter modification requests input by the user; the receiving party comprises a client or a server, and the parameter to be modified comprises an interface parameter in an interface request acquired by the transmission module from the client, or an interface return parameter in an interface response acquired by the transmission module from the server;
the modification module is used for modifying the parameters to be modified according to the parameter modification request;
the transmission module is used for sending the modified parameters to the receiving party;
if the identifier of the parameter to be modified is the identifier of the interface return parameter in the interface response; the determining module is specifically configured to determine, according to the identifier of the parameter to be modified, that the parameter to be modified is an interface return parameter in the interface response, and determine that a receiver of the modified interface return parameter is the client;
the transmission module is further used for sending the modified parameters and the performance of the receiving party to a display end; the performance of the recipient includes: a performance of the client;
wherein, the parameter modification request carries the identifier of the parameter to be modified and the modification value corresponding to the parameter to be modified;
if the identifier of the parameter to be modified is the identifier of the interface parameter in the interface request; the determining module is specifically configured to determine, according to the identifier of the parameter to be modified, that the parameter to be modified is the interface parameter, and determine that a receiver of the modified interface parameter is the server;
the device further comprises: an analysis module;
the analysis module is used for analyzing the interface request acquired from the client to obtain the interface parameter;
the modification module is specifically configured to modify the interface parameter according to a modification value of the parameter to be modified;
the transmission module is specifically configured to carry the modified interface parameters in a new interface request and send the new interface request to the server; and receiving an interface response sent by the server.
7. The apparatus of claim 6, wherein the performance of the recipient comprises: and the interface of the server side responds.
8. The apparatus of claim 6, wherein the transmission module is further configured to send the interface request obtained from the client to the server; receiving an interface response sent by the server;
the modification module is specifically configured to modify an interface return parameter in the interface response according to the modification value of the parameter to be modified;
and the transmission module is further used for carrying the modified interface return parameters in a new interface response and sending the new interface response to the client.
9. The apparatus according to any one of claims 6-8, further comprising: a scheduling module;
the scheduling module is used for sequencing the parameter modification requests when the transmission module receives the parameter modification requests input by a user and determining the execution sequence of each parameter modification request; and executing the process corresponding to the parameter modification request according to the execution sequence of each parameter modification request.
10. The apparatus of claim 9, further comprising: an exception handling module;
and the exception handling module is used for ignoring the current parameter modification request and executing the next parameter modification request when the current parameter modification request is identified to be abnormal.
11. An interface test system, comprising: the system comprises a client, a server, a transfer server and a display end;
the transit server for performing the method of any of the preceding claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710543989.4A CN107294808B (en) | 2017-07-05 | 2017-07-05 | Interface test method, device and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710543989.4A CN107294808B (en) | 2017-07-05 | 2017-07-05 | Interface test method, device and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107294808A CN107294808A (en) | 2017-10-24 |
CN107294808B true CN107294808B (en) | 2020-11-24 |
Family
ID=60100021
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710543989.4A Active CN107294808B (en) | 2017-07-05 | 2017-07-05 | Interface test method, device and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107294808B (en) |
Families Citing this family (16)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107861870B (en) * | 2017-11-02 | 2020-07-24 | 平安科技(深圳)有限公司 | Interface test and test data generation method, device, terminal and storage medium |
CN109871312B (en) * | 2017-12-05 | 2022-08-12 | 航天信息股份有限公司 | Interface testing method, device, equipment and readable storage medium |
CN108519883A (en) * | 2018-03-26 | 2018-09-11 | 平安普惠企业管理有限公司 | Parameter amending method, device, terminal device and storage medium |
CN108536484A (en) * | 2018-03-26 | 2018-09-14 | 平安普惠企业管理有限公司 | Parameter amending method, device, terminal device and storage medium |
CN108551410B (en) * | 2018-03-27 | 2021-06-15 | 平安普惠企业管理有限公司 | Interface returning method and terminal equipment |
CN108519873A (en) * | 2018-04-16 | 2018-09-11 | 中国科学院昆明植物研究所 | A kind of Efficient Programming method automatically processing parameter |
CN110875858B (en) * | 2018-08-31 | 2023-06-27 | 北京京东尚科信息技术有限公司 | Application test data grabbing method, system, equipment and storage medium |
CN110908888B (en) * | 2018-09-17 | 2023-06-30 | 百度在线网络技术(北京)有限公司 | Server testing method and device |
CN110008074B (en) * | 2019-04-11 | 2020-07-07 | 苏州浪潮智能科技有限公司 | Method, device and equipment for automatically testing and inquiring upper-layer interface of hardware information |
CN110196813B (en) * | 2019-06-06 | 2023-05-02 | 北京百度网讯科技有限公司 | Interface test method, device, equipment and medium |
CN110287039A (en) * | 2019-06-26 | 2019-09-27 | 网易无尾熊(杭州)科技有限公司 | Analog interface configuration method, medium, device and calculating equipment |
CN110851208A (en) * | 2019-11-08 | 2020-02-28 | 京东数字科技控股有限公司 | Interface parameter and response data modification method and device |
CN111104323A (en) * | 2019-12-17 | 2020-05-05 | 广州品唯软件有限公司 | Function test method, system, proxy server and storage medium of application program |
CN111352610A (en) * | 2020-03-03 | 2020-06-30 | 五八有限公司 | Interface return value modification method and device, electronic equipment and storage medium |
CN111953775A (en) * | 2020-08-12 | 2020-11-17 | 吉林亿联银行股份有限公司 | Data transmission method and device |
CN113206755A (en) * | 2021-04-20 | 2021-08-03 | 北京异乡旅行网络科技有限公司 | Method and device for problem location |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103312551A (en) * | 2012-03-12 | 2013-09-18 | 腾讯科技(深圳)有限公司 | Test method and test device of common gateway interface |
CN105354143A (en) * | 2015-12-02 | 2016-02-24 | 北京奇虎科技有限公司 | Test method and device for application programs |
CN106126417A (en) * | 2016-06-17 | 2016-11-16 | 深圳开源互联网安全技术有限公司 | Interactive application safety detecting method and system thereof |
CN106354634A (en) * | 2016-08-25 | 2017-01-25 | 青岛海信传媒网络技术有限公司 | Interface testing method and device |
CN106815150A (en) * | 2017-01-19 | 2017-06-09 | 网易(杭州)网络有限公司 | Service end interface test system and method |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7730352B2 (en) * | 2006-06-28 | 2010-06-01 | Microsoft Corporation | Testing network applications without communicating over a network layer communication link |
US8271837B2 (en) * | 2010-06-07 | 2012-09-18 | Salesforce.Com, Inc. | Performing asynchronous testing of an application occasionally connected to an online services system |
-
2017
- 2017-07-05 CN CN201710543989.4A patent/CN107294808B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103312551A (en) * | 2012-03-12 | 2013-09-18 | 腾讯科技(深圳)有限公司 | Test method and test device of common gateway interface |
CN105354143A (en) * | 2015-12-02 | 2016-02-24 | 北京奇虎科技有限公司 | Test method and device for application programs |
CN106126417A (en) * | 2016-06-17 | 2016-11-16 | 深圳开源互联网安全技术有限公司 | Interactive application safety detecting method and system thereof |
CN106354634A (en) * | 2016-08-25 | 2017-01-25 | 青岛海信传媒网络技术有限公司 | Interface testing method and device |
CN106815150A (en) * | 2017-01-19 | 2017-06-09 | 网易(杭州)网络有限公司 | Service end interface test system and method |
Also Published As
Publication number | Publication date |
---|---|
CN107294808A (en) | 2017-10-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107294808B (en) | Interface test method, device and system | |
CN107436844B (en) | Method and device for generating interface use case aggregate | |
CN107241229B (en) | Service monitoring method and device based on interface testing tool | |
CN106484611B (en) | Fuzzy test method and device based on automatic protocol adaptation | |
CN107370806A (en) | HTTP conditional codes monitoring method, device, storage medium and electronic equipment | |
CN104765678A (en) | Method and device for testing applications on mobile terminal | |
CN111198797B (en) | Operation monitoring method and device and operation analysis method and device | |
CN113495820B (en) | Anomaly information collecting and processing method and device and anomaly monitoring system | |
CN108134708B (en) | Method and device for monitoring third-party interface | |
CN111190755B (en) | Application program function exception handling method and device | |
CN107168844B (en) | Performance monitoring method and device | |
CN107896172A (en) | Monitor fault handling method and device, storage medium and electronic equipment | |
WO2021120544A1 (en) | Method and apparatus for debugging device | |
CN113179194B (en) | OPC protocol gateway test system and method | |
CN110806965A (en) | Automatic test method, device, equipment and medium | |
CN107257290B (en) | Test method and system for open SOA service-oriented architecture | |
CN113448795B (en) | Method, apparatus and computer program product for obtaining system diagnostic information | |
KR20130063866A (en) | Diagonosis system for m2m device and the method thereof | |
CN103338382B (en) | A kind of method of remote monitoring digital TV terminal, device and digital television system | |
KR20120071175A (en) | Mobile phone loading web-platform, method for offering log information using the same mobile phone, verification system and method for web-platform | |
CN109587349B (en) | Multimedia agent line testing method and device, electronic equipment and storage medium | |
CN111431739A (en) | QualNet-oriented dynamic fault setting method and interface for simulation communication network | |
CN116662193A (en) | Page testing method and device | |
WO2015176516A1 (en) | Method and apparatus for tracking service process | |
CN110795330A (en) | Monkey pressure testing method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |