CN113760719A - Interface testing method and tool - Google Patents

Interface testing method and tool Download PDF

Info

Publication number
CN113760719A
CN113760719A CN202011342511.3A CN202011342511A CN113760719A CN 113760719 A CN113760719 A CN 113760719A CN 202011342511 A CN202011342511 A CN 202011342511A CN 113760719 A CN113760719 A CN 113760719A
Authority
CN
China
Prior art keywords
request message
test
interface
log text
test log
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
CN202011342511.3A
Other languages
Chinese (zh)
Inventor
姜素瑶
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN202011342511.3A priority Critical patent/CN113760719A/en
Publication of CN113760719A publication Critical patent/CN113760719A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management

Abstract

The invention discloses an interface testing method and a tool, and relates to the technical field of computers. One embodiment of the method comprises: according to a request message to be sent to an interface, creating a test log text corresponding to the request message, wherein the test log text records the test context information and the request message; and sending the request message to the interface, updating the test log text according to a response result of the interface to the request message, and recording a test process, a test environment and test parameters while executing an interface test, so that the integrity of the test log text is improved, and a reference basis is provided for subsequent tests.

Description

Interface testing method and tool
Technical Field
The invention relates to the technical field of computers, in particular to an interface testing method and an interface testing tool.
Background
In the development of internet applications, the test interface is an important part of the development, and the interface request can be tested by using the existing testing tools such as PostMan, apiza, jmeter, etc.
Current test tools mainly test a single request, lacking a record of the context of the interface request and detailed information of the requested operation; thus, detailed information in the life cycle of the interface request operation cannot be completely recorded, and the detailed information is lack of archiving.
Disclosure of Invention
In view of this, embodiments of the present invention provide an interface testing method and a tool, which can record a testing process, a testing environment, and testing parameters while performing an interface test, improve the integrity of a test log text, and provide a reference for a subsequent test.
In order to achieve the above object, according to an aspect of an embodiment of the present invention, there is provided an interface testing method, including: according to a request message to be sent to an interface, creating a test log text corresponding to the request message, wherein the test log text records the test context information and the request message; and sending the request message to the interface, and updating the test log text according to a response result of the interface to the request message.
Optionally, the interface testing method is characterized in that,
before the test log text corresponding to the request message is created, determining whether the test log text exists, if not, creating the test log text corresponding to the request message; and if so, recording the context information of the test and the request message by using the existing test log text.
Optionally, the interface testing method is characterized in that,
the context information includes one or more of: test time, network information of the test environment.
Optionally, the interface testing method is characterized in that the recording, by the test log text, the request message includes: analyzing the request message to obtain a field and a field value related to the request message; the test log text records the request message in the form of a key-value pair, wherein the key-value pair is formed according to the field and the field value.
Optionally, the interface testing method is characterized in that the updating the test log text according to a response result of the interface to the request message includes: under the condition that a response message of the interface to the request message is received, updating the test log text according to the response message; in the event that a response message to the request message by the interface is not received, recording the test as not receiving a response in the test log text.
Optionally, the interface testing method is characterized in that the updating the test log text according to the response message includes: analyzing the response message to obtain a field and a field value related to the response message; the test log text records the response message in the form of a key-value pair, wherein the key-value pair is formed according to the field and the field value.
Optionally, the interface testing method is characterized in that,
creating or updating the test log text with a first thread; sending the request message to the interface with a second thread; the first thread communicates with the second thread to learn the response result of the interface to the request message.
Optionally, the interface testing method is characterized in that,
the request message is an HTTP request or an RPC request.
Optionally, the interface testing method is characterized in that,
and classifying and storing the test log texts according to the interface corresponding to the request message.
To achieve the above object, according to a second aspect of an embodiment of the present invention, there is provided an interface test tool, including: the test recording module and the test execution module; wherein the content of the first and second substances,
the test recording module is used for creating a test log text corresponding to a request message according to the request message to be sent to an interface, wherein the test log text records the test context information and the request message;
and the test execution module is used for sending the request message to the interface and updating the test log text according to the response result of the interface to the request message.
Optionally, the interface test tool, wherein,
before the test log text corresponding to the request message is created, determining whether the test log text exists, if not, creating the test log text corresponding to the request message; and if so, recording the context information of the test and the request message by using the existing test log text.
Optionally, the interface test tool, wherein,
the context information includes one or more of: test time, network information of the test environment.
Optionally, the interface testing tool, wherein the recording the request message by the test log text, includes: analyzing the request message to obtain a field and a field value related to the request message; the test log text records the request message in the form of a key-value pair, wherein the key-value pair is formed according to the field and the field value.
Optionally, the interface testing tool, where the updating the test log text according to the response result of the interface to the request message includes: under the condition that a response message of the interface to the request message is received, updating the test log text according to the response message; in the event that a response message to the request message by the interface is not received, recording the test as not receiving a response in the test log text.
Optionally, the interface testing tool is characterized in that the updating the test log text according to the response result includes: analyzing the response message to obtain a field and a field value related to the response message; the test log text records the response message in the form of a key-value pair, wherein the key-value pair is formed according to the field and the field value.
Optionally, the interface test tool, wherein,
creating or updating the test log text with a first thread; sending the request message to the interface with a second thread; the first thread communicates with the second thread to learn the response result of the interface to the request message.
Optionally, the interface test tool, wherein,
the request message is an HTTP request or an RPC request.
Optionally, the interface test tool, wherein,
and classifying and storing the test log texts according to the interface corresponding to the request message.
To achieve the above object, according to a third aspect of the embodiments of the present invention, there is provided an electronic device for interface test, including: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to carry out a method as claimed in any one of the methods of interface testing described above.
To achieve the above object, according to a fourth aspect of the embodiments of the present invention, there is provided a computer readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method as in any one of the above interface testing methods.
One embodiment of the above invention has the following advantages or benefits: the interface test can be executed, and simultaneously, the test process, the test environment and the test parameters are recorded, so that the integrity of the test log text is improved, and a reference basis is provided for the subsequent test; and the technical means of classified storage of the test log texts is utilized to overcome the problem of log archiving.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic flowchart of an interface testing method according to an embodiment of the present invention;
FIG. 2A is an exemplary diagram of an HTTP request message provided by one embodiment of the present invention;
FIG. 2B is an exemplary diagram of an HTTP response message provided by one embodiment of the present invention;
FIG. 3 is a schematic diagram of an interface test flow according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of an interface test tool according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 6 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
As shown in fig. 1, an embodiment of the present invention provides an interface request recording method, which may include the following steps:
step S101: and creating a test log text corresponding to the request message according to the request message to be sent to an interface, wherein the test log text records the test context information and the request message.
Specifically, the request message to be sent to the interface refers to a request message to be sent to the interface, which is prepared for verifying the function or performance of the interface, and the request message may be a request message based on various request types (e.g., GET request, POST request) of HTTP (Hyper Text Transfer Protocol), or a request based on RPC (Remote Procedure Call) Protocol, that is, the request message is an HTTP request or an RPC request.
Further, the test log text is used to record information corresponding to the test process, including context information of the test and the request message. The context information of the test includes sending request information, a timestamp of receiving a response result (i.e. test time) in the life cycle of the test, and network information of the test environment, such as: the IP address and the port number of an interface for receiving request information in the test, the IP address and the port number of a server where a test tool is located, a transmission protocol (TCP or UDP) used by the request and the response, a protocol version (IPv4 or IPv6) of the IP address, whether the proxy server and network information (such as the IP address and the port number of the proxy server) of the proxy server are used, and the like; that is, the context information includes one or more of the following: test time, network information of the test environment. It can be understood that by recording the context information of the test, the integrity of the test information in the test log text is improved.
Further, according to the request message, a test log text corresponding to the request message is created, wherein the test log text can be a text file, a database table and the like. It will be appreciated that to distinguish request messages, corresponding test log text may be created based on a unique identification associated with the request message, wherein the unique identification may be associated with the content of the request message; for example: if the request message is an order request for inquiring the product, the identifier of the product can be used as the unique identifier of the test log text to distinguish the test log text corresponding to each request message; before the test log text is created, whether the test log text exists can be judged according to the unique identifier; that is, before the test log text corresponding to the request message is created, determining whether the test log text exists, and if not, creating the test log text corresponding to the request message; and if so, recording the context information of the test and the request message by using the existing test log text.
For example: according to HTTP GET request messages for querying order detailsThe URL (uniform resource locator) is as follows: "https://details.jd.com/normal/item.action? orderid=132271953976&PassKey=8A7613699778DA79C4D7E64096F23D1A", the test log text corresponding to the request message is to be created as" item-details-id3976.txt ". If the test log text 'item-details-id 3976. txt' already exists, directly recording the context information of the test corresponding to the request information and the request message in the text; for example, when the interface corresponding to the request message is tested for the 10 th time, the test time (time stamp for sending the request information and receiving the response result) of the 10 times of test, the specific parameters of the request message, and the response result of the request message are sequentially recorded in the test log text "item-details-id 3976. txt. Accordingly, if the test log text "item-details-id 3976. txt" does not exist yet, the test log text is created, and the test time (time stamp for sending request information and receiving response result) of the test, the specific parameters of the request message, and the response result of the request message are recorded in the newly created test log text.
Further, the text recording the request message by the test log includes: analyzing the request message to obtain a field and a field value related to the request message; the fields and field values related to the request message are described below by taking the HTTP request message as an example; for example: when the field is "message type" of HTTP, the corresponding field value may be: GET, POST, DELTE, PUT, etc.; when the field is a field of the HTTP request header — for example: host, Accept, Connection, Content-length, etc., and the field value is a value corresponding to the field. In addition, the field may also be a "URL," such as: in the HTTP POST request message as shown in fig. 2A: asp is a field value corresponding to a field 'URL'; the fields may also be fields in the body of an HTTP request message; for example: in the example shown in fig. 2A, the field value corresponding to the field "host" is "abcdefg.com", the field value corresponding to the field "name 1" is "value 1", and so on.
Further, still taking the HTTP POST request message as shown in fig. 2A as an example, by parsing the keyword in the request message, the field and the field value related to the request message are obtained. That is, according to the request message shown in fig. 2A, by parsing the keyword in the request message, the fields and field values as shown in table 1 can be obtained:
TABLE 1 fields and field values of request messages
Field(s) Field value
Request type (request type) POST
Uniform Resource Locator (URL) /test/demo_form.asp
Domain (host) abcdefg.com
Custom field 1(name1) value1
Custom field 2(name2) value2
Further, the test log text records the request message in a form of a key-value pair, and records the request message in a form of a key-value pair according to fields and field values related to the request message described in table 1, and still taking the POST request message shown in fig. 2A as an example, after the request message is parsed to obtain the fields and the field values (as shown in table 1), records the key-value pair with a request type of POST in the test log text as follows: { "request type": POST "}; the key-value pair of the host address for which the request message is accessed is recorded as: { "host" - "abcdefg.com" }; recording the key value pair of the URL in the request message as { "URL": test/demo _ form. asp "}; the invention does not limit the specific format of the key-value pair form.
It will be appreciated that the test log text also includes contextual information that records the test in the form of key-value pairs, such as: the IP address and port number of the interface are recorded in the test log text in the form of key-value pairs { "IP": 123.123.123.123 "}, {" port ": 5050" }. That is, in the preferred embodiment, the key-value pairs are formed from the fields and field values.
Step S102: and sending the request message to the interface, and updating the test log text according to a response result of the interface to the request message.
Specifically, the request message is sent to the interface, and a response result of the interface to the request message is obtained; the description of the request message is consistent with step S101, and is not repeated here. Wherein the protocol used for the response result is generally identical to the protocol used for the request message. The response result may indicate whether the response message was received, and in the case of receiving the response message, the response result may contain a response code (e.g., 200OK indicates that the request was successful), response data (e.g., a return value for the request parameter in the request message), and so on. And further, updating the test log text according to the request message and the corresponding response result.
Preferably, the interface test (i.e., sending the request information) and the updating (or creating) of the test log text are performed by different threads, and it is understood that the operation of updating (or creating) the test log text can be enabled without affecting the operation of sending the request information by different independent threads sending the request information and updating (or creating) the test log text. That is, the test log text is created or updated with a first thread; sending the request message to the interface with a second thread; the first thread communicates with the second thread to learn the response result of the interface to the request message. The method for the first thread to communicate with the second thread may adopt an inter-thread communication method, for example: message mechanisms, signal mechanisms, and the like are utilized.
Further, updating the test log text according to a response message of the interface to the request message, further comprising: under the condition that a response message of the interface to the request message is received, updating the test log text according to the response message; in the event that a response message to the request message by the interface is not received, recording the test as not receiving a response in the test log text. The content and format of the specific text of 'no response received' are not limited by the invention. Further, in case of receiving the response message, the response message corresponding to the request message is written (i.e. updated) into the test log text of the request message, and at the same time, the timestamp (i.e. test time) of the received response message is written.
Further, in case of receiving a response message of the interface to the request message, parsing the response message to obtain the mutually corresponding field and field value of the response message. The test log text records the response message in the form of a key-value pair, wherein the key-value pair is formed according to the field and the field value.
Taking the HTTP response message shown in fig. 2B as an example, how to obtain the fields and field values related to the response message shown in table 2 by parsing the keywords in the HTTP response message shown in fig. 2B is described as follows:
TABLE 2 fields and field values of response messages
Figure BDA0002798924280000091
Figure BDA0002798924280000101
Specifically, the test log text records fields of the response message as shown in table 2 and corresponding field values in the form of key-value pairs, for example: the key-value pair that records the return Code in the test log file is { "status Code": "200 OK" }; the key value pair recording the time information of the response message is { "date": "Fri, 22May 200906: 07:21 GM" }; recording the key-value pair of the data Type of the response message as { "content-Type": "text/html" }; recording the key-value pair of the character set of the response message as { "charset": "UTF-8" }; record the key-value pair of the message body of the response message as { "body": "success" }; that is, the test log text records the response message in the form of a key-value pair formed according to the field and the field value.
Preferably, the test log texts are classified and stored according to an interface corresponding to the request message; for example: for the test of the unified interface, the first half of URL (e.g. https:// details. jd. com/normal/item. action) of different request messages is the same — the first half of URL usually indicates a specific interface, and the included request parameters (e.g. orderid. 132271953976& PassKey. 8a7613699778DA79C4D7E64096F23D1A) are different, so that different test log texts are created for recording the respective request messages, and based on the same URL part (i.e. interface), the test log texts corresponding to the respective request messages with the same interface can be sorted and stored, for example: and storing test log texts corresponding to different user names and passwords but corresponding to request messages of the same test interface in a directory for representing the interface so as to achieve the purpose of classified storage according to the interface.
As shown in fig. 3, an embodiment of the present invention provides a method for testing an interface, where the method may include the following steps:
step S301: a request message to be sent to an interface is received.
Specifically, the detailed description about the request message to be sent to the interface is consistent with step S101, and is not repeated here.
Step S302: and judging whether a test log text corresponding to the request message exists or not according to the request message to be sent to the interface.
Specifically, according to the request message to be sent to the interface, whether a test log text corresponding to the request message exists is judged, and if yes, step S304 is executed; if not, go to step S303. The specific description of determining whether the test log text exists is consistent with step S101, and is not repeated here.
Step S303: and creating a test log text corresponding to the request message according to the request message to be sent to the interface.
Specifically, the specific description about the request message and the creation of the test log text is consistent with step S101, and is not repeated here.
Step S304: recording context information of the test and the request message using existing test log text.
Specifically, the description about recording the context information of the test and the request message by using the test log text is consistent with S101, and is not repeated herein.
The description of step S301 to step S304 is: according to a request message to be sent to an interface, creating a test log text corresponding to the request message, determining whether the test log text exists before the test log text corresponding to the request message is created, and if not, creating the test log text corresponding to the request message; and if so, recording the context information of the test and the request message by using the existing test log text.
Step S305: and sending a request message, and judging whether a response message of the interface to the request message is received.
Specifically, whether a response message of the interface to the request message is received is judged; if yes, go to step S306; if not, go to step S307; the detailed description about the response message and the response result is consistent with the description of step S102, and is not repeated here.
Step S306: and updating the test log text according to the response result of the interface to the request message.
Specifically, the specific description about the acceptance response result and the updating of the test log text is consistent with the description of step S102, and is not repeated here.
Step S307: recording the test as not receiving a response in the test log text.
Specifically, the description about recording the test as a non-received response in the test log text is consistent with the description of step S102, and is not repeated here.
The description of step S305 to step S307 is: updating the test log text according to a response result of the interface to the request message, including: under the condition that a response message of the interface to the request message is received, updating the test log text according to the response message; in the event that a response message to the request message by the interface is not received, recording the test as not receiving a response in the test log text.
Further, creating or updating the test log text with a first thread; sending the request message to the interface with a second thread; the first thread communicates with the second thread to learn the response result of the interface to the request message.
As shown in fig. 4, an embodiment of the present invention provides an interface test tool 400, including: a test recording module 401 and a test execution module 402; wherein the content of the first and second substances,
the test recording module 401 is configured to create a test log text corresponding to a request message to be sent to an interface, where the test log text records context information of the test and the request message;
the test execution module 402 is configured to send the request message to the interface, and update the test log text according to a response result of the interface to the request message.
Optionally, the test recording module 401 is further configured to determine whether the test log text exists before the test log text corresponding to the request message is created, and if not, create the test log text corresponding to the request message; and if so, recording the context information of the test and the request message by using the existing test log text.
Optionally, the test recording module 401, including the context information, includes one or more of the following: test time, network information of the test environment.
Optionally, the test record module 401 is further configured to parse the request message to obtain a field and a field value related to the request message; the test log text records the request message in the form of a key-value pair, wherein the key-value pair is formed according to the field and the field value.
Optionally, the test execution module 402 is further configured to, when a response message to the request message from the interface is received, update the test log text according to the response message; in the case where a result of a response of the interface to the request message is not received, the test is recorded as a non-received response in the test log text.
Optionally, the test execution module 402 is further configured to parse the response result to obtain a field and a field value related to the response result; the test log text records the response result in the form of a key-value pair, wherein the key-value pair is formed according to the field and the field value.
Optionally, the interface test tool 400 is further configured to create or update the test log text with a first thread; sending the request message to the interface with a second thread; the first thread communicates with the second thread to learn the response result of the interface to the request message.
Optionally, the test recording module 401 includes: the request message is an HTTP request or an RPC request.
Optionally, the test recording module 401 is further configured to store the test log texts in a classified manner according to the interface corresponding to the request message.
An embodiment of the present invention further provides an electronic device for interface testing, including: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize the method provided by any one of the above embodiments.
Embodiments of the present invention further provide a computer-readable medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method provided in any of the above embodiments.
Fig. 5 illustrates an exemplary system architecture 500 to which the interface test method or interface test tool of embodiments of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 501, 502, 503 to interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may have various client applications installed thereon, such as an e-mall client application, a web browser application, a search-type application, an instant messaging tool, a mailbox client, and the like.
The terminal devices 501, 502, 503 may be various electronic devices having a display screen and equipped with the testing tool described in the present disclosure, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 505 may be a server that provides various services, such as a server that deploys interfaces for which users perform tests using the terminal devices 501, 502, 503. The server may process the received request message and record the offer response message.
It should be noted that the interface testing method provided by the embodiment of the present invention is generally executed by the terminal devices 501, 502, and 503, and accordingly, the interface testing tool is generally disposed in the terminal devices 501, 502, and 503.
It should be understood that the number of terminal devices, networks, and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, a block diagram of a computer system 600 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 601.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules and/or units described in the embodiments of the present invention may be implemented by software, and may also be implemented by hardware. The described modules and/or units may also be provided in a processor, and may be described as: a processor comprises a test recording module and a test execution module; the names of these modules do not constitute a limitation to the module itself in some cases, and for example, the test recording module may be further described as a "module that records context information of the test and the request message according to the request information and the response result".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: according to a request message to be sent to an interface, creating a test log text corresponding to the request message, wherein the test log text records the test context information and the request message; and sending the request message to the interface, and updating the test log text according to a response result of the interface to the request message.
By utilizing one embodiment of the invention, the test process, the test environment and the test parameters can be recorded while the interface test is executed, so that the integrity of the test log text is improved, and a reference basis is provided for the subsequent test.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. An interface testing method, comprising:
according to a request message to be sent to an interface, creating a test log text corresponding to the request message, wherein the test log text records the test context information and the request message;
and sending the request message to the interface, and updating the test log text according to a response result of the interface to the request message.
2. The method of claim 1,
before the test log text corresponding to the request message is created, determining whether the test log text exists, if not, creating the test log text corresponding to the request message; and if so, recording the context information of the test and the request message by using the existing test log text.
3. The method according to claim 1 or 2,
the context information includes one or more of: test time, network information of the test environment.
4. The method of claim 1 or 2, wherein the text logging of the request message comprises:
analyzing the request message to obtain a field and a field value related to the request message;
the test log text records the request message in the form of a key-value pair, wherein the key-value pair is formed according to the field and the field value.
5. The method of claim 1, wherein updating the test log text according to the response result of the interface to the request message comprises:
under the condition that a response message of the interface to the request message is received, updating the test log text according to the response message;
in the event that a response message to the request message by the interface is not received, recording the test as not receiving a response in the test log text.
6. The method of claim 5, wherein updating the test log text according to the response result comprises:
analyzing the response message to obtain a field and a field value related to the response message;
the test log text records the response message in the form of a key-value pair, wherein the key-value pair is formed according to the field and the field value.
7. The method of claim 1,
creating or updating the test log text with a first thread;
sending the request message to the interface with a second thread;
the first thread communicates with the second thread to learn the response result of the interface to the request message.
8. The method of claim 1,
the request message is an HTTP request or an RPC request.
9. The method of claim 1, further comprising:
and classifying and storing the test log texts according to the interface corresponding to the request message.
10. A test tool, comprising: the test recording module and the test execution module; wherein the content of the first and second substances,
the test recording module is used for creating a test log text corresponding to a request message according to the request message to be sent to an interface, wherein the test log text records the test context information and the request message;
and the test execution module is used for sending the request message to the interface and updating the test log text according to the response result of the interface to the request message.
11. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-9.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-9.
CN202011342511.3A 2020-11-25 2020-11-25 Interface testing method and tool Pending CN113760719A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011342511.3A CN113760719A (en) 2020-11-25 2020-11-25 Interface testing method and tool

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011342511.3A CN113760719A (en) 2020-11-25 2020-11-25 Interface testing method and tool

Publications (1)

Publication Number Publication Date
CN113760719A true CN113760719A (en) 2021-12-07

Family

ID=78786074

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011342511.3A Pending CN113760719A (en) 2020-11-25 2020-11-25 Interface testing method and tool

Country Status (1)

Country Link
CN (1) CN113760719A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101593150A (en) * 2009-06-16 2009-12-02 中兴通讯股份有限公司 A kind of system and method for testing performance of web application software interface
CN109298997A (en) * 2018-08-08 2019-02-01 平安科技(深圳)有限公司 Interface test method, system, computer equipment and storage medium
CN109446063A (en) * 2018-09-18 2019-03-08 深圳壹账通智能科技有限公司 Interface test method, device, computer equipment and storage medium
US20190129773A1 (en) * 2017-10-27 2019-05-02 Internaitonal Business Machines Corporation Web api recommendations based on usage in cloud-provided runtimes
CN111478969A (en) * 2020-04-09 2020-07-31 吉林亿联银行股份有限公司 Interface checking method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101593150A (en) * 2009-06-16 2009-12-02 中兴通讯股份有限公司 A kind of system and method for testing performance of web application software interface
US20190129773A1 (en) * 2017-10-27 2019-05-02 Internaitonal Business Machines Corporation Web api recommendations based on usage in cloud-provided runtimes
CN109298997A (en) * 2018-08-08 2019-02-01 平安科技(深圳)有限公司 Interface test method, system, computer equipment and storage medium
CN109446063A (en) * 2018-09-18 2019-03-08 深圳壹账通智能科技有限公司 Interface test method, device, computer equipment and storage medium
CN111478969A (en) * 2020-04-09 2020-07-31 吉林亿联银行股份有限公司 Interface checking method and device

Similar Documents

Publication Publication Date Title
US11030085B2 (en) User defined mocking service behavior
WO2021023149A1 (en) Method and apparatus for dynamically returning message
CN113760674A (en) Information generation method and device, electronic equipment and computer readable medium
CN109656799B (en) Test method and device
CN113360377B (en) Test method and device
CN107766224B (en) Test method and test device
CN112559024A (en) Method and device for generating transaction code change list
CN111787041B (en) Method and device for processing data
CN112948138A (en) Method and device for processing message
US11811884B1 (en) Topic subscription provisioning for communication protocol
CN113760719A (en) Interface testing method and tool
CN111460020B (en) Method, device, electronic equipment and medium for resolving message
EP2103084B1 (en) An intelligent system of unified content posting
CN113779018A (en) Data processing method and device
CN113132447A (en) Reverse proxy method and system
CN111949472A (en) Method and device for recording application logs
CN113347052A (en) Method and device for counting user access data through access log
EP4145317A1 (en) Specifying and testing open communication protocols
CN109358973B (en) Information processing method, system, medium, and computing device
CN111460273B (en) Information pushing method and device
Verma A comparison of web framework efficiency: performance and network analysis of modern web frameworks
CN110019030B (en) Method and device for dividing file
CN114528212A (en) Method, apparatus, device and computer readable medium for providing test data
CN113704080A (en) Automatic testing method and device
CN115454879A (en) Test script generation method and related 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