Interface test method, service device, electronic equipment, storage medium and product

By introducing the interface testing method of http converter and connector in Theia framework products, the problem of low interface testing efficiency in the existing technology is solved, and efficient http interface testing on the test server is realized.

CN119496721APending Publication Date: 2025-02-21HANGZHOU HOLLYSYS AUTOMATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411801365.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

In the prior art, the interface testing of products based on Theia framework is relatively low, only supports unit testing, and does not support traditional http interface testing.

Method used

An interface testing method is proposed, through http converter and connector, the http interface testing of the server to be tested is realized. The http converter parses the http request sent by the interface test tool and determines the request's identification and business request type. When the connector synchronizes service requests, it transmits the transmitted data and identification to the server to be tested through the proxy interface, and transmits the response result back to the http converter.

Benefits of technology

Through this interface testing method, the interface testing efficiency based on Theia framework products can be improved, which is more convenient and efficient than unit testing solutions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119496721A_ABST
    Figure CN119496721A_ABST
Patent Text Reader

Abstract

The invention provides an interface test method, a service device, electronic equipment, a storage medium and a product. The method comprises the following steps: analyzing http request data by using an http converter to obtain address data and transmission data, determining an identifier of an http request, and determining a service request type of the http request based on the address data; when the service request type is a synchronous service request, calling a proxy interface corresponding to the identifier of the http request by using a connector, transmitting the transmission data and the identifier to a to-be-tested server, and transmitting a response result and the identifier output by the to-be-tested server to an http converter; and acquiring a response result corresponding to the http request by using the http converter based on the service request type and the identifier. According to the scheme, the http converter is used for receiving the http request sent by the interface testing tool, the interface of the to-be-tested server side is tested in the http interface testing mode, and the interface testing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of interface testing technology, and in particular to an interface testing method, a service device, an electronic device, a storage medium and a product. Background Art

[0002] As an extensible platform based on Web technology, Theia provides users with a multi-language cloud and desktop IDE experience. Its ease of use, extensibility and cross-platform features make it one of the indispensable tools in modern software development. Currently, a large number of products on the market use Theia as the basic framework to develop software products involving various industries. However, the interface testing method for these products only provides unit testing solutions and does not support traditional http interface testing, resulting in low interface testing efficiency for products based on the Theia framework. Summary of the invention

[0003] Based on the above requirements, the present application proposes an interface testing method, a service device, an electronic device, a storage medium and a product, which can improve the efficiency of interface testing.

[0004] To achieve the above objectives, this application proposes the following technical solutions:

[0005] According to a first aspect of an embodiment of the present application, an interface testing method is provided, which is applied to an interface testing service device, wherein the interface testing service device comprises: an http converter and a connector; the interface testing method comprises:

[0006] The http converter performs data analysis on the http request sent by the interface testing tool, obtains address data and transmission data, and determines the identifier of the http request;

[0007] The http converter determines the service request type of the http request based on the address data;

[0008] When the service request type is a synchronous service request, the connector calls the proxy interface corresponding to the identifier of the http request, transmits the transmission data and the identifier of the http request to the server to be tested through the proxy interface, and transmits the response result corresponding to the http request output by the server to be tested and the identifier of the http request to the http converter; wherein the connector pre-constructs the proxy interface corresponding to each interface in the server to be tested, and each proxy interface is bound to the transmission channel between the server to be tested and the connector;

[0009] The http converter obtains a response result corresponding to the http request based on the business request type and the identifier of the http request.

[0010] Optionally, the interface testing method also includes:

[0011] The connector receives the asynchronous business data sent by the server to be tested, obtains the identifier of the asynchronous business data from the asynchronous business data, and sends the identifier of the asynchronous business data and the asynchronous business data to the http converter for data caching.

[0012] Optionally, the http converter obtains a response result corresponding to the http request based on the business request type and the identifier of the http request, including:

[0013] If the service request type is a synchronous service request, extracting a response result corresponding to the http request from the cache of the http converter according to the identifier of the http request;

[0014] If the service request type is an asynchronous service request, then according to the identifier of the http request and the identifiers of each asynchronous service data stored in the cache of the http converter, the asynchronous service data is extracted from the cache of the http converter as the response result corresponding to the http request.

[0015] Optionally, based on the service request type and the identifier of the http request, obtaining a response result corresponding to the http request includes:

[0016] Obtaining a maximum timeout duration from the transmission data;

[0017] Based on the business request type and the identifier of the http request, query the response result corresponding to the http request from the cache of the http converter;

[0018] If a response result corresponding to the http request is found within the maximum timeout period, the response result corresponding to the http request is obtained;

[0019] If the response result corresponding to the http request is not found within the maximum timeout period, a prompt message indicating a response timeout is generated and the prompt message is transmitted to the interface testing tool.

[0020] Optionally, the interface testing method also includes:

[0021] The connector creates a transmission channel according to the IP address and port of the server to be tested, and connects to the server to be tested through the transmission channel; the transmission channel is a WebSocket channel;

[0022] The connector uses a JSON-based remote procedure call protocol to introduce interfaces and interface calling methods in the server to be tested, binds each interface and each interface calling method to a transmission channel, and generates a proxy interface corresponding to each interface in the server to be tested.

[0023] Optionally, the interface testing method also includes:

[0024] The http converter transmits the response result corresponding to the http request to the interface testing tool, so that the interface testing tool determines the interface testing result according to the response result.

[0025] According to a second aspect of an embodiment of the present application, there is provided an interface testing service device, including: an http converter and a connector;

[0026] The http converter performs data analysis on the http request sent by the interface testing tool, obtains address data and transmission data, and determines the identifier of the http request;

[0027] The http converter determines the service request type of the http request based on the address data;

[0028] When the service request type is a synchronous service request, the connector calls the proxy interface corresponding to the identifier of the http request, transmits the transmission data and the identifier of the http request to the server to be tested through the proxy interface, and transmits the response result corresponding to the http request output by the server to be tested and the identifier of the http request to the http converter; wherein the connector pre-constructs the proxy interface corresponding to each interface in the server to be tested, and each proxy interface is bound to the transmission channel between the server to be tested and the connector;

[0029] The http converter obtains a response result corresponding to the http request based on the business request type and the identifier of the http request.

[0030] According to a third aspect of an embodiment of the present application, there is provided an electronic device, including: a memory and a processor;

[0031] The memory is connected to the processor and is used to store programs;

[0032] The processor is used to implement the above interface testing method by running the program in the memory.

[0033] According to a fourth aspect of an embodiment of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned interface testing method is implemented.

[0034] According to a fifth aspect of an embodiment of the present application, a computer program product is provided, comprising computer program instructions, which, when executed by a processor, enable the processor to implement the above-mentioned interface testing method.

[0035] The interface testing method proposed in the present application is applied to an interface testing service device, and the interface testing service device includes: an http converter and a connector. The http converter performs data analysis on the http request sent by the interface testing tool, obtains address data and transmission data, and determines the identifier of the http request; the http converter determines the business request type of the http request based on the address data; when the business request type is a synchronous business request, the connector calls the proxy interface corresponding to the identifier of the http request, transmits the transmission data and the identifier of the http request to the server to be tested through the proxy interface, and transmits the response result corresponding to the http request output by the server to be tested and the identifier of the http request to the http converter; wherein the connector pre-constructs the proxy interface corresponding to each interface in the server to be tested, and each proxy interface is bound to the transmission channel between the server to be tested and the connector; the http converter obtains the response result corresponding to the http request based on the business request type and the identifier of the http request. By adopting the technical solution of the present application, the http converter can receive the http request sent by the http interface testing tool, and perform data interaction with the server to be tested through the connector, so as to realize the interface test of the server to be tested by using the http interface test method, and improve the interface test efficiency compared with the existing unit test scheme. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0037] Figure 1 A schematic diagram of the structure of an interface testing service device provided in an embodiment of the present application;

[0038] Figure 2 A flowchart of an interface testing method provided in an embodiment of the present application;

[0039] Figure 3A schematic diagram of a process for processing asynchronous service data provided in an embodiment of the present application;

[0040] Figure 4 A schematic diagram of a processing flow for obtaining a response result corresponding to an http request provided in an embodiment of the present application;

[0041] Figure 5 A schematic diagram of a process flow for creating a proxy interface provided in an embodiment of the present application;

[0042] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0043] The technical solution of the embodiment of the present application is applicable to the application scenario of interface testing, and is specifically used in the application scenario of interface testing of products based on the Theia framework. The technical solution of the embodiment of the present application can improve the efficiency of interface testing.

[0044] Theia (full name Eclipse Theia) is an IDE product developed using the latest Web technology that supports cloud and desktop operation. As an extensible platform based on Web technology, Theia provides users with a multi-language cloud and desktop IDE experience. Its ease of use, extensibility and cross-platform features make it one of the indispensable tools in modern software development.

[0045] Currently, a large number of products on the market use Theia as the basic framework, and have developed software products involving various industries. However, for the interface testing methods of these products, there is only the official unit testing solution, and its architecture itself does not support traditional http interface testing. The official unit testing solution requires testers to have a basic knowledge of TypeScript, Node, js and other languages ​​before they can conduct product testing. For large projects, this solution is complex to operate, the reuse of the relevant use cases written is low, and it is difficult to maintain. It is not as convenient as http interface testing, so it makes it difficult to conduct related testing work efficiently, consuming a lot of manpower and material resources, thus affecting the interface testing efficiency of products based on the Theia framework.

[0046] Based on this, the present application proposes an interface testing method. This technical solution can create an http converter and a connector, use the http converter to receive the http request sent by the http interface testing tool, and interact with the server to be tested through the connector to perform data, thereby realizing interface testing of the server to be tested using the http interface testing method, improving the interface testing efficiency, and thus solving the problem of low interface testing efficiency of products based on the Theia framework in the prior art.

[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0048] Exemplary Methods

[0049] See also Figure 1 and Figure 2 As shown, the embodiment of the present application proposes an interface testing method, which is applied to an interface testing service device, wherein the interface testing service device 10 includes: an http converter 101 and a connector 102, the http converter 101 is connected to the interface testing tool 20 and the connector 102 respectively, and the connector 102 is connected to the service end 40 to be tested. The interface testing method specifically includes the following steps:

[0050] S201. The http converter performs data analysis on the http request sent by the interface testing tool, obtains address data and transmission data, and determines the identifier of the http request.

[0051] In this embodiment, an http converter 101 is pre-set, and the http converter 101 can provide an HTTP protocol interface to the outside, so that the http converter 101 can be used to achieve connection with the interface testing tool 20, so that the user can use the interface testing tool to call the HTTP protocol interface. The user sends an http request for interface testing through the interface testing tool 20, and the http converter 101 receives the http request sent by the interface testing tool 20, and then performs data parsing on the http request, and parses the address data (i.e., URL parameters) and transmission data (i.e., Body data) from the http request. In this embodiment, the interface testing tool connected to the http converter 101 is a tool that supports HTTP interface testing, such as Postman, Apifox, JMeter, etc.

[0052] After parsing the data of the http request, this embodiment also needs to generate an identifier of the http request, wherein the identifier needs to be a unique string so as to distinguish different http requests. Specifically, this embodiment can directly obtain the service ID of the http request from the transmission data obtained by parsing the data of the http request, and use the service ID as the identifier of the http request. It is also possible to use the random code generation method of UUID to randomly generate a unique string RID, and use the string RID as the identifier of the http request.

[0053] S202. The http converter determines the service request type of the http request based on the address data.

[0054] In this embodiment, after the http converter 101 performs data parsing on the http request to obtain the address data, it is necessary to determine the service request type of the http request sent by the interface test tool according to the address data. Among them, the service request type includes synchronous service request and asynchronous service request, that is, in this embodiment, it is necessary to determine whether the http request is a synchronous service request or an asynchronous service request according to the parsed address data. For example, the service request type of the http request with the address data " / async / data" is determined to be an asynchronous service request, and the service request type of the http request with the address data " / sync / data" is determined to be a synchronous service request.

[0055] S203. When the business request type is a synchronous business request, the connector calls the proxy interface corresponding to the http request identifier, transmits the transmission data and the http request identifier to the server to be tested through the proxy interface, and transmits the response result corresponding to the http request output by the server to be tested and the http request identifier to the http converter.

[0056] See also Figure 1 As shown, in this embodiment, proxy interfaces 1021 corresponding to various interfaces in the server to be tested 40 are pre-constructed in the connector 102, and each proxy interface 1021 is bound to the transmission channel 30 between the server to be tested 40 and the connector 102. Among them, the connector 102 is also provided with a transmission channel client 1022, and the server to be tested 40 is provided with a transmission channel server 401 and a backend business processing component 402. The connector 102 is connected to the transmission channel 30 through the internally provided transmission channel client 1022, and the server to be tested 40 is connected to the transmission channel 30 through the internally provided transmission channel server 401, so that the connector 102 and the server to be tested 40 can perform data interaction through the connection with the transmission channel 30. The server to be tested 40 can perform business processing through the internally provided backend business processing component 402, and the backend business processing component 402 can realize data interaction with the transmission channel 30 through the transmission channel server 401. In addition, the proxy interface 1021 provided in the connector 102 includes two types: a proxy interface for synchronous service requests (SYNC-API) and a proxy interface for asynchronous service requests (ASYNC-API). Among them, the proxy interface for synchronous service requests (SYNC-API) is a module in the connector 102 for connecting and processing synchronous service request APIs, and the proxy interface for asynchronous service requests (ASYNC-API) is a module in the connector 102 for connecting and processing asynchronous service request APIs.

[0057] When the business request type of the http request is determined to be a synchronous business request through the above steps, the connector 102 can call the proxy interface 1021 corresponding to the identifier of the http request, and because the business request type is a synchronous business request at this time, the called proxy interface 1021 is a proxy interface for the synchronous business request. In this embodiment, the proxy interface 1021 corresponding to the identifier of the http request called transmits the parsed transmission data and the determined identifier of the http request to the server 40 to be tested. After receiving the transmission data and the identifier of the http request in the http request, the server 40 to be tested processes the transmission data using the back-end business processing component 402, responds to the http request, and transmits the response result corresponding to the http request and the identifier of the http request to the connector 102 through the transmission channel 30, and the connector 102 transmits the response result corresponding to the http request and the identifier of the http request to the http converter 101.

[0058] S204. The http converter obtains a response result corresponding to the http request based on the business request type and the identifier of the http request.

[0059] In this embodiment, after determining the service request type of the http request, the http converter 101 needs to obtain the response result corresponding to the http request according to the service request type and the identifier of the http request. Specifically, if the service request type of the http request is a synchronous service request, after the connector 102 transmits the response result corresponding to the http request transmitted by the server to be tested 40 and the identifier of the http request to the http converter 101, the http converter 101 directly obtains the response result corresponding to the http request according to the identifier of the http request. In addition, after the connector 102 receives the response result corresponding to the http request and the identifier of the http request fed back by the server to be tested 40, the response result corresponding to the http request and the identifier of the http request can be directly transmitted to the cache of the http converter 101 for storage. After determining that the service request type of the http request is a synchronous service request, the http converter 101 directly extracts the response result corresponding to the identifier of the http request from the cache of the http converter according to the identifier of the http request, which is the response result corresponding to the http request.

[0060] Furthermore, the cache of the http converter 101 of this embodiment also stores the asynchronous business data pre-pushed by the server 40 to be tested through the connector 102 and the identifiers corresponding to each asynchronous business data. If the http converter 101 determines that the business request type of the http request is an asynchronous business request, the asynchronous business data is extracted from the cache of the http converter 101 as the response result corresponding to the http request according to the identifier of the http request and the identifiers of each asynchronous business data stored in the cache of the http converter 101. That is, the identifier of the http request and the identifiers of each asynchronous business data stored in the cache of the http converter 101 are matched and analyzed, and the asynchronous business data whose identifier stored in the cache of the http converter 101 matches the identifier of the http request is used as the response result corresponding to the http request.

[0061] It can be seen from the above introduction that the interface testing method proposed in the embodiment of the present application is applied to the interface testing service device, and the interface testing service device includes: an http converter and a connector. The http converter performs data analysis on the http request sent by the interface testing tool, obtains address data and transmission data, and determines the identifier of the http request; the http converter determines the business request type of the http request based on the address data; when the business request type is a synchronous business request, the connector calls the proxy interface corresponding to the identifier of the http request, transmits the transmission data and the identifier of the http request to the server to be tested through the proxy interface, and transmits the response result corresponding to the http request output by the server to be tested and the identifier of the http request to the http converter; wherein the connector pre-constructs the proxy interface corresponding to each interface in the server to be tested, and each proxy interface is bound to the transmission channel between the server to be tested and the connector; the http converter obtains the response result corresponding to the http request based on the business request type and the identifier of the http request. By adopting the technical solution of the present application, the http converter can receive the http request sent by the http interface testing tool, and interact with the server to be tested through the connector to perform data, so as to realize the interface test of the server to be tested by using the http interface test method, which improves the interface test efficiency compared with the existing unit test scheme.

[0062] As an optional implementation, the embodiment of the present application further proposes an interface testing method, which, after executing step S204, further includes the following steps:

[0063] The http converter transmits the response result corresponding to the http request to the interface testing tool, so that the interface testing tool determines the interface testing result according to the response result.

[0064] After obtaining the response result corresponding to the http request, the http converter 101 directly transmits the response result corresponding to the http request to the interface testing tool connected to it, and the interface testing tool analyzes the interface testing result based on the http request sent by it and the response result corresponding to the http request fed back. The interface testing tool is an existing http interface testing tool. Therefore, the interface testing tool performs interface testing result analysis on the http request sent by it and the response result corresponding to the http request fed back by it, which belongs to the prior art and will not be elaborated in this embodiment.

[0065] As an optional implementation, see Figure 3 As shown, in another embodiment of the present application, the interface testing method further includes the following steps:

[0066] S301. The connector receives asynchronous business data sent by the server to be tested, obtains an identifier of the asynchronous business data from the asynchronous business data, and sends the identifier of the asynchronous business data and the asynchronous business data to the http converter for data caching.

[0067] In this embodiment, the service end 40 to be tested can push asynchronous business data to the interface test service device 10 through the transmission channel 30. The connector 102 in the interface test service device 10 receives the asynchronous business data transmitted by the transmission channel 30 through the transmission channel client 1022. The transmission channel client 1022 transmits the asynchronous business data to the proxy interface 1021 in the connector 102, wherein the proxy interface 1021 is a proxy interface for asynchronous business requests. The connector 102 uses the proxy interface 1021 to obtain the business ID from the asynchronous business data, and uses the business ID as the identifier of the asynchronous business data. Then, the connector 102 sends the asynchronous business data and the identifier of the asynchronous business data to the http converter 101, and the http converter 101 directly associates the asynchronous business data and the identifier of the asynchronous business data, and stores them in its internal cache, so that when the asynchronous business request needs it, it can be directly obtained from the cache of the http converter 101.

[0068] As an optional implementation, see Figure 4 As shown, in another embodiment of the present application, in step S204 of the above embodiment, based on the business request type and the identifier of the http request, obtaining the response result corresponding to the http request specifically includes the following steps:

[0069] S401. Obtain a maximum timeout duration from transmission data.

[0070] In this embodiment, after the http converter 101 parses the http request and obtains the transmission data in the http request, the maximum timeout duration can be obtained from the transmission data, for example, the value of the timeOut field in the transmission data (Body data) is used as the maximum timeout duration.

[0071] S402: Based on the business request type and the identifier of the http request, query the response result corresponding to the http request from the cache of the http converter.

[0072] This embodiment queries the response result corresponding to the http request from the cache of the http converter 101 according to the business request type and the identifier of the http request, that is, queries the identifier that matches the identifier of the http request from the cache of the http converter 101. If the identifier that matches the identifier of the http request is queried from the cache of the http converter 101, it means that the response result corresponding to the http request can be queried from the cache of the http converter. If the identifier that matches the identifier of the http request is not queried from the cache of the http converter 101, it means that the response result corresponding to the http request cannot be queried from the cache of the http converter.

[0073] S403: If the response result corresponding to the http request is found within the maximum timeout period, the response result corresponding to the http request is obtained.

[0074] In this embodiment, in the process of querying the response result corresponding to the http request from the cache of the http converter 101 based on the business request type and the identifier of the http request, it is necessary to collect the current query duration in real time. If the response result corresponding to the http request is queried within the maximum timeout period, the response result corresponding to the http request is directly obtained, and the response result corresponding to the http request is sent to the interface testing tool, so that the interface testing tool determines the interface testing result according to the response result.

[0075] S404: If no response result corresponding to the http request is found within the maximum timeout period, a prompt message indicating a response timeout is generated and the prompt message is transmitted to the interface testing tool.

[0076] If the current query duration collected in real time has exceeded the maximum timeout duration, it means that the http converter 101 has not found the response result corresponding to the http request within the maximum timeout duration. At this time, it means that the response result corresponding to the http request may not be stored in the cache of the http converter 101. It may be that the server 40 to be tested has not fed back or pushed the response result corresponding to the http request to the http converter 101, or data is lost during the feedback or push process. Therefore, if the response result corresponding to the http request is not found within the maximum timeout duration, a prompt message indicating a response timeout is generated, and the prompt message is transmitted to the interface test tool so that the interface test tool can make a corresponding response.

[0077] As an optional implementation, see Figure 5 As shown, in another embodiment of the present application, the interface testing method further includes the following steps:

[0078] S501. The connector creates a transmission channel according to the IP address and port of the server to be tested, and connects to the server to be tested through the transmission channel.

[0079] In this embodiment, when creating the connector 102, the connector 102 needs to create a transmission channel 30 between the connector 102 and the server to be tested 40 according to the IP address and port of the server to be tested 40, wherein the transmission channel is preferably a WebSocket channel, and maintains the connection between the connector 102 and the server to be tested 40, that is, the connector 102 is connected to the server to be tested 40 through the transmission channel 30. In this embodiment, the connector 102 is responsible for connecting to the WebSocket interface in the server to be tested based on the Theia framework, and initializing the relevant underlying framework.

[0080] S502. The connector uses the JSON-based remote procedure call protocol to introduce the interfaces and interface calling methods in the server to be tested, binds each interface and each interface calling method to the transmission channel, and generates proxy interfaces corresponding to each interface in the server to be tested.

[0081] In this embodiment, the connector 102 can scan all interfaces registered in the server to be tested 40, and then use the JSON-based remote procedure call protocol (i.e., JSON-RPC protocol) to introduce the interface and the calling method of the interface in the server to be tested 40, and use the JSON-RPC protocol to bind the interface and the calling method of the interface in the server to be tested 40 to the transmission channel 30 (i.e., WebSocket channel) in an RPC proxy manner, that is, create an RPC proxy interface, thereby realizing the initialization of the proxy interface and generating the proxy interface corresponding to each interface in the server to be tested 40. Among them, JSON-RPC (JSONRemote Procedure Call), that is, a remote procedure call protocol based on JSON, is a stateless and lightweight remote procedure call (RPC) protocol. It uses JSON (JavaScript Object Notation) as the data format and transmits data through protocols such as HTTP or TCP, thereby realizing communication between the client and the server.

[0082] Furthermore, in each of the above embodiments, the server to be tested is a server of a software product developed using Theia as the basic framework.

[0083] Exemplary Devices

[0084] Accordingly, the present application embodiment also provides an interface testing service device, see Figure 1 As shown, the device comprises:

[0085] The http converter 101 is used to parse the http request sent by the interface testing tool, obtain the address data and the transmission data, and determine the identifier of the http request;

[0086] The http converter 101 is further used to determine the service request type of the http request based on the address data;

[0087] The connector 102 is used to call the proxy interface corresponding to the identifier of the http request when the service request type is a synchronous service request, transmit the transmission data and the identifier of the http request to the server to be tested through the proxy interface, and transmit the response result corresponding to the http request output by the server to be tested and the identifier of the http request to the http converter; wherein the connector pre-constructs the proxy interface corresponding to each interface in the server to be tested, and each proxy interface is bound to the transmission channel between the server to be tested and the connector;

[0088] The http converter 101 is also used to obtain a response result corresponding to the http request based on the business request type and the identifier of the http request.

[0089] From the above introduction, it can be seen that the interface testing service device proposed in the embodiment of the present application can use the http converter 101 to receive the http request sent by the http interface testing tool, and interact with the server to be tested 40 through the connector 102 to perform data, thereby realizing the interface test of the server to be tested 40 using the http interface testing method, which improves the interface testing efficiency compared to the existing unit testing scheme.

[0090] As an optional implementation, in another embodiment of the present application, it is disclosed that the connector 102 is also used for:

[0091] Receive the asynchronous business data sent by the server to be tested, obtain the identifier of the asynchronous business data from the asynchronous business data, and send the identifier of the asynchronous business data and the asynchronous business data to the http converter for data caching.

[0092] As an optional implementation, another embodiment of the present application discloses that the http converter 101 is specifically used for:

[0093] If the service request type is a synchronous service request, the response result corresponding to the http request is extracted from the cache of the http converter according to the identifier of the http request;

[0094] If the service request type is an asynchronous service request, the asynchronous service data is extracted from the cache of the http converter as a response result corresponding to the http request according to the identifier of the http request and the identifiers of each asynchronous service data stored in the cache of the http converter.

[0095] As an optional implementation, another embodiment of the present application discloses that the http converter 101 is further used for:

[0096] Get the maximum timeout from the transmission data;

[0097] Based on the business request type and the identifier of the http request, query the response result corresponding to the http request from the cache of the http converter;

[0098] If the response result corresponding to the http request is found within the maximum timeout period, the response result corresponding to the http request is obtained;

[0099] If the response result corresponding to the http request is not found within the maximum timeout period, a prompt message indicating a response timeout is generated and transmitted to the interface testing tool.

[0100] As an optional implementation, in another embodiment of the present application, the connector 102 is further used for:

[0101] Create a transmission channel according to the IP address and port of the server to be tested, and connect to the server to be tested through the transmission channel; the transmission channel is a WebSocket channel;

[0102] Using the JSON-based remote procedure call protocol, the interfaces and interface calling methods in the server to be tested are introduced, and each interface and each interface calling method are bound to the transmission channel to generate proxy interfaces corresponding to each interface in the server to be tested.

[0103] As an optional implementation, another embodiment of the present application discloses that the http converter 101 is further used for:

[0104] The response result corresponding to the http request is transmitted to the interface testing tool, so that the interface testing tool determines the interface testing result according to the response result.

[0105] The interface testing service device provided in this embodiment belongs to the same application concept as the interface testing method provided in the above embodiments of this application, can execute the interface testing method provided in any of the above embodiments of this application, and has the corresponding functional modules and beneficial effects of executing the interface testing method. For technical details not fully described in this embodiment, please refer to the specific processing content of the interface testing method provided in the above embodiments of this application, and will not be repeated here.

[0106] Exemplary Electronic Devices

[0107] Another embodiment of the present application also provides an electronic device, see Figure 6 As shown, the device includes:

[0108] Memory 200 and processor 210;

[0109] The memory 200 is connected to the processor 210 and is used to store programs;

[0110] The processor 210 is used to implement the interface testing method disclosed in any of the above embodiments by running the program stored in the memory 200.

[0111] Specifically, the electronic device may further include: a bus, a communication interface 220 , an input device 230 and an output device 240 .

[0112] The processor 210, the memory 200, the communication interface 220, the input device 230 and the output device 240 are connected to each other via a bus.

[0113] A bus may include a pathway that transfers information between components of a computer system.

[0114] The processor 210 may be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the scheme of the present invention. It may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0115] The processor 210 may include a main processor, and may also include a baseband chip, a modem, and the like.

[0116] The memory 200 stores a program for executing the technical solution of the present invention, and may also store an operating system and other key services. Specifically, the program may include a program code, and the program code includes a computer operation instruction. More specifically, the memory 200 may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk storage, a flash, and the like.

[0117] The input device 230 may include a device for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor.

[0118] Output device 240 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.

[0119] The communication interface 220 may include any transceiver or the like to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.

[0120] The processor 210 executes the program stored in the memory 200 and calls other devices, which can be used to implement each step of any interface testing method provided in the above embodiments of the present application.

[0121] Exemplary computer program products and storage media

[0122] In addition to the above-mentioned methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the interface testing method according to various embodiments of the present application described in the above-mentioned "Exemplary Method" section of this specification.

[0123] The computer program product may be written in any combination of one or more programming languages ​​to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0124] In addition, an embodiment of the present application may also be a storage medium on which a computer program is stored, and the computer program is executed by a processor to execute the steps of the interface testing method according to various embodiments of the present application described in the above "Exemplary Method" section of this specification.

[0125] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0126] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0127] The steps in the methods of each embodiment of the present application can be adjusted in sequence, combined and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.

[0128] The modules and sub-modules in the devices and terminals of the various embodiments of the present application can be combined, divided and deleted according to actual needs.

[0129] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are only schematic, for example, the division of modules or submodules is only a logical function division, and there may be other division methods in actual implementation, for example, multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0130] The modules or submodules described as separate components may or may not be physically separated, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place, or they may be distributed on multiple network modules or submodules. Some or all of the modules or submodules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0131] In addition, each functional module or submodule in each embodiment of the present application may be integrated into one processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into one module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or in the form of software functional modules or submodules.

[0132] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0133] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly by hardware, software units executed by a processor, or a combination of the two. The software units may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0134] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0135] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. An interface testing method, characterized in that: Applied to an interface testing service device, the interface testing service device comprises: an http converter and a connector; the interface testing method comprises: The http converter performs data analysis on the http request sent by the interface testing tool, obtains address data and transmission data, and determines the identifier of the http request; The http converter determines the service request type of the http request based on the address data; When the service request type is a synchronous service request, the connector calls the proxy interface corresponding to the identifier of the http request, transmits the transmission data and the identifier of the http request to the server to be tested through the proxy interface, and transmits the response result corresponding to the http request output by the server to be tested and the identifier of the http request to the http converter; wherein the connector pre-constructs the proxy interface corresponding to each interface in the server to be tested, and each proxy interface is bound to the transmission channel between the server to be tested and the connector; The http converter obtains a response result corresponding to the http request based on the business request type and the identifier of the http request.

2. The method according to claim 1, characterized in that Also includes: The connector receives the asynchronous business data sent by the server to be tested, obtains the identifier of the asynchronous business data from the asynchronous business data, and sends the identifier of the asynchronous business data and the asynchronous business data to the http converter for data caching.

3. The method according to claim 2, characterized in that The http converter obtains a response result corresponding to the http request based on the business request type and the identifier of the http request, including: If the service request type is a synchronous service request, extracting a response result corresponding to the http request from the cache of the http converter according to the identifier of the http request; If the service request type is an asynchronous service request, then according to the identifier of the http request and the identifiers of each asynchronous service data stored in the cache of the http converter, the asynchronous service data is extracted from the cache of the http converter as the response result corresponding to the http request.

4. The method according to claim 1, characterized in that: Based on the service request type and the identifier of the http request, obtaining a response result corresponding to the http request includes: Obtaining a maximum timeout duration from the transmission data; Based on the business request type and the identifier of the http request, query the response result corresponding to the http request from the cache of the http converter; If a response result corresponding to the http request is found within the maximum timeout period, the response result corresponding to the http request is obtained; If the response result corresponding to the http request is not found within the maximum timeout period, a prompt message indicating a response timeout is generated and the prompt message is transmitted to the interface testing tool.

5. The method according to claim 1, characterized in that Also includes: The connector creates a transmission channel according to the IP address and port of the server to be tested, and connects to the server to be tested through the transmission channel; The transmission channel is a WebSocket channel; The connector uses a JSON-based remote procedure call protocol to introduce interfaces and interface calling methods in the server to be tested, and binds each interface and each interface calling method to a transmission channel to generate a proxy interface corresponding to each interface in the server to be tested.

6. The method according to claim 1, characterized in that Also includes: The http converter transmits the response result corresponding to the http request to the interface testing tool, so that the interface testing tool determines the interface testing result according to the response result.

7. An interface testing service device, characterized in that: include: http converters and connectors; The http converter performs data analysis on the http request sent by the interface testing tool, obtains address data and transmission data, and determines the identifier of the http request; The http converter determines the service request type of the http request based on the address data; When the service request type is a synchronous service request, the connector calls the proxy interface corresponding to the identifier of the http request, transmits the transmission data and the identifier of the http request to the server to be tested through the proxy interface, and transmits the response result corresponding to the http request output by the server to be tested and the identifier of the http request to the http converter; wherein the connector pre-constructs the proxy interface corresponding to each interface in the server to be tested, and each proxy interface is bound to the transmission channel between the server to be tested and the connector; The http converter obtains a response result corresponding to the http request based on the business request type and the identifier of the http request.

8. An electronic device, characterized in that: include: Memory and processor; The memory is connected to the processor and is used to store programs; The processor is used to implement the interface testing method according to any one of claims 1 to 6 by running the program in the memory.

9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the interface testing method according to any one of claims 1 to 6 is implemented.

10. A computer program product, characterized in that The method comprises computer program instructions, which, when executed by a processor, enable the processor to implement the interface testing method according to any one of claims 1 to 6.