An interface testing method and apparatus

By automatically parsing and building interface test cases, the problems of low efficiency and insufficient coverage in interface testing are solved, enabling more efficient and comprehensive interface testing and ensuring the normal operation of the system under abnormal conditions.

CN122240488APending Publication Date: 2026-06-19JINGDONG TECH HLDG CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JINGDONG TECH HLDG CO LTD
Filing Date
2026-03-19
Publication Date
2026-06-19

Smart Images

  • Figure CN122240488A_ABST
    Figure CN122240488A_ABST
Patent Text Reader

Abstract

This invention discloses an interface testing method and apparatus, relating to the field of application development technology. One specific embodiment of the invention includes: parsing communication interfaces from the code to be tested and extracting the interface code segments of the communication interfaces; determining the corresponding call dependencies for each gateway interface; constructing interface test cases for each gateway interface based on the call dependencies; and using the interface test cases to test whether the gateway interfaces and / or internal communication interfaces associated with the abnormal interface execute preset processing logic when a call abnormality occurs at the gateway interface and / or internal communication interface. This invention improves the automation level, test coverage, and test efficiency of communication interface testing by automatically parsing communication interfaces, extracting interface code segments, determining call dependencies between communication interfaces, constructing interface test cases, and testing the operation of communication interfaces under normal or abnormal call conditions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of application development technology, and in particular to an interface testing method and apparatus. Background Technology

[0002] As application systems become more complex, the testing requirements during system development also become increasingly stringent. Typically, when testing interactive communication interfaces, in addition to testing the functionality of each individual interface, it is also necessary to test the coordinated operation between different communication interfaces to ensure the system remains in a normal operating state.

[0003] Currently, the main approach involves R&D personnel identifying the various communication interfaces that need to be tested, then writing corresponding test cases and executing the communication interface tests. However, with rapid system version iterations and a large number of communication interfaces to be tested, the existing method suffers from low testing efficiency, wasted human resources, and may also lead to low test coverage. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide an interface testing method and apparatus, capable of parsing communication interfaces (gateway interfaces and internal communication interfaces) from the code to be tested, extracting the interface code segments of the communication interfaces, determining the corresponding call dependencies for each gateway interface, constructing interface test cases for each gateway interface based on the call dependencies, and using the interface test cases to test whether the gateway interfaces and / or internal communication interfaces associated with the abnormal interface run preset processing logic when a call abnormality occurs at the gateway interface and / or the internal communication interface. Embodiments of the present invention improve the automation, test coverage, and test efficiency of communication interface testing by automatically parsing communication interfaces, extracting interface code segments, determining the call dependencies between communication interfaces, and constructing interface test cases, thereby testing the operation of communication interfaces under normal or abnormal call conditions.

[0005] To achieve the above objectives, according to one aspect of the present invention, an interface testing method is provided, comprising: parsing communication interfaces from code to be tested; wherein the communication interfaces include gateway interfaces and internal communication interfaces; extracting interface code segments corresponding to each communication interface from the code to be tested, and labeling the interface code segments with corresponding communication interface information; determining the corresponding call dependency relationship for each gateway interface based on the communication interface information of each interface code segment; constructing interface test cases for each gateway interface based on the call dependency relationship; and using the interface test cases to test whether the gateway interface and / or internal communication interface associated with the abnormal interface runs preset processing logic when a call abnormality occurs in the gateway interface and / or internal communication interface.

[0006] Optionally, the interface code segment of the gateway interface includes a front-end code segment and a back-end code segment; the step of extracting the interface code segment corresponding to each communication interface from the code to be tested includes: for each gateway interface, extracting the front-end code segment that triggers the gateway interface call; and the back-end code segment that the gateway interface calls one or more internal communication interfaces in the back-end.

[0007] Optionally, the call dependency relationship includes a front-end call relationship and a back-end call relationship between the gateway interface and one or more internal communication interfaces; determining the corresponding call dependency relationship for each gateway interface based on the communication interface information of each interface code segment includes: constructing a corresponding front-end call relationship tree for each gateway interface based on the first communication interface information of the front-end code segment of each gateway interface; constructing a front-end call relationship for the gateway interface based on the front-end call relationship tree; constructing a corresponding back-end call relationship tree for each gateway interface based on the second communication interface information of the back-end code segment of each gateway interface; constructing a back-end call relationship for the gateway interface based on the back-end call relationship tree; and constructing the corresponding call dependency relationship for each gateway interface based on the front-end call relationship and the back-end call relationship.

[0008] Optionally, constructing interface test cases for each gateway interface based on the call dependency relationship includes: for each gateway interface, extracting its associated front-end code segment set and back-end code segment set according to the call dependency relationship of the gateway interface; and obtaining the test scenario set and expected return result set of the gateway interface; wherein, the expected return result set includes normal return results and abnormal return results; and using the Cartesian product model, performing set element combination operations based on the front-end code segment set, the back-end code segment set, the test scenario set, and the expected return result set to generate multiple interface test cases covering each test scenario.

[0009] Optionally, the interface testing method further includes: intercepting a gateway interface request during the execution of the interface test case; obtaining simulated test data corresponding to the test scenario required by the gateway interface request from a simulated server; simulating the test return result of the gateway interface using the simulated test data; and / or simulating the linkage return result of the gateway interface and its associated internal communication interface using the simulated test data and the call dependency relationship corresponding to the gateway interface; and, if the test return result or the linkage return result is determined to be abnormal, determining whether the gateway interface and / or internal communication interface associated with the abnormal interface runs a preset processing logic.

[0010] Optionally, the interface testing method further includes: after any interface test case is executed, recording the first interface identifier of the gateway interface that has used simulated test data, and / or the second interface identifier of the internal communication interface that has used simulated test data; calculating the test coverage of the gateway interface based on the first interface identifier, and / or calculating the test coverage of the internal communication interface based on the second interface identifier.

[0011] Optionally, the interface testing method further includes: in response to receiving an execution trigger from the test frontend for the interface test case, obtaining the test return result corresponding to the interface test case; sending the test return result to the test frontend; and causing the test frontend to render the frontend page corresponding to the interface test case based on the test return result, and automatically obtaining the test result image displayed on the frontend page.

[0012] Optionally, the interface testing method further includes: receiving a test result image sent by the test front-end and obtaining an expected result image of the interface test case; comparing the test result image with the expected result image, and determining whether the return result of the gateway interface or internal communication interface associated with the interface test case meets the preset processing strategy based on the comparison result.

[0013] To achieve the above objectives, according to a second aspect of the present invention, an interface testing apparatus is provided, comprising: a code parsing module, a relationship building module, and an interface testing module; wherein, The code parsing module is used to parse the communication interface from the code to be tested; wherein, the communication interface includes a gateway interface and an internal communication interface; extract the interface code segment corresponding to each communication interface from the code to be tested, and annotate the corresponding communication interface information for the interface code segment; The relationship building module is used to determine the corresponding call dependency relationship for each gateway interface based on the communication interface information of each interface code segment. The test interface module is used to construct interface test cases for each gateway interface based on the call dependency relationship; and to use the interface test cases to test whether the gateway interface and / or internal communication interface associated with the abnormal interface runs the preset processing logic when the gateway interface and / or internal communication interface experiences a call exception.

[0014] Optionally, the interface code segment of the gateway interface includes a front-end code segment and a back-end code segment; the interface testing device is used to extract the interface code segment corresponding to each communication interface from the code to be tested, including: for each gateway interface, extracting the front-end code segment that triggers the gateway interface call; and the back-end code segment in which the gateway interface calls one or more internal communication interfaces in the back-end.

[0015] Optionally, the call dependency relationship includes a front-end call relationship and a back-end call relationship between the gateway interface and one or more internal communication interfaces; the interface testing device is used to determine the corresponding call dependency relationship for each gateway interface based on the communication interface information of each interface code segment, including: constructing a corresponding front-end call relationship tree for each gateway interface based on the first communication interface information of the front-end code segment of each gateway interface; constructing a front-end call relationship for the gateway interface based on the front-end call relationship tree; constructing a corresponding back-end call relationship tree for each gateway interface based on the second communication interface information of the back-end code segment of each gateway interface; constructing a back-end call relationship for the gateway interface based on the back-end call relationship tree; and constructing the corresponding call dependency relationship for each gateway interface based on the front-end call relationship and the back-end call relationship.

[0016] Optionally, the interface testing device is used to construct interface test cases for each gateway interface based on the call dependency relationship, including: for each gateway interface, extracting its associated front-end code segment set and back-end code segment set according to the call dependency relationship of the gateway interface; and obtaining the test scenario set and expected return result set of the gateway interface; wherein, the expected return result set includes normal return results and abnormal return results; and using a Cartesian product model, performing set element combination operations based on the front-end code segment set, the back-end code segment set, the test scenario set, and the expected return result set to generate multiple interface test cases covering each test scenario.

[0017] Optionally, the interface testing device is configured to intercept gateway interface requests during the execution of the interface test cases, obtain simulated test data corresponding to the test scenarios required by the gateway interface requests from the simulated server; simulate the test return results of the gateway interface using the simulated test data; and / or, simulate the linkage return results of the gateway interface and associated internal communication interfaces using the simulated test data and the call dependencies corresponding to the gateway interface; and, if the test return result or the linkage return result is determined to be abnormal, determine whether the gateway interface and / or internal communication interface associated with the abnormal interface runs preset processing logic.

[0018] Optionally, the interface testing device is configured to, after any interface test case is executed, record a first interface identifier of the gateway interface that has used simulated test data, and / or a second interface identifier of the internal communication interface that has used simulated test data; calculate the test coverage of the gateway interface based on the first interface identifier, and / or calculate the test coverage of the internal communication interface based on the second interface identifier.

[0019] Optionally, the interface testing device is configured to respond to the execution trigger of the interface test case received from the test frontend, obtain the test return result corresponding to the interface test case; send the test return result to the test frontend; so that the test frontend renders the frontend page corresponding to the interface test case according to the test return result, and automatically obtains the test result image displayed on the frontend page.

[0020] Optionally, the interface testing device is configured to receive the test result image sent by the test front-end and obtain the expected result image of the interface test case; compare the test result image with the expected result image, and determine whether the return result of the gateway interface or internal communication interface associated with the interface test case meets the preset processing strategy based on the comparison result.

[0021] To achieve the above objectives, according to a third aspect of the present invention, an electronic device for interface testing is provided, characterized in that it includes: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any of the methods described in the above interface testing methods.

[0022] To achieve the above objectives, according to a fourth aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, characterized in that, when the program is executed by a processor, it implements any of the methods described in the above-described interface testing methods.

[0023] To achieve the above objectives, according to a fifth aspect of the present invention, a computer program product is provided, comprising a computer program, characterized in that, when the computer program is executed by a processor, it implements any of the methods described above for interface testing.

[0024] One embodiment of the above invention has the following advantages or beneficial effects: it can parse the communication interfaces (gateway interfaces and internal communication interfaces) from the code to be tested, extract the interface code segments of the communication interfaces, and determine the corresponding call dependencies for each gateway interface; it can construct interface test cases for each gateway interface based on the call dependencies; and it can use the interface test cases to test whether the gateway interfaces and / or internal communication interfaces associated with the abnormal interface run the preset processing logic when a call abnormality occurs in the gateway interface and / or internal communication interface. This embodiment of the invention improves the automation level, test coverage, and test efficiency of testing communication interfaces by automatically parsing communication interfaces, extracting interface code segments, determining the call dependencies between communication interfaces, constructing interface test cases, and testing the operation of communication interfaces under normal or abnormal call conditions. Furthermore, this embodiment of the invention can automatically obtain the test result image displayed on the page after the test case returns through the front-end page, and further compare the test result image with the expected result image. By comparing the results, it analyzes the interface test situation, further improving the accuracy and efficiency of test case and test result analysis.

[0025] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description

[0026] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein: Figure 1 This is a flowchart illustrating an interface testing method provided in an embodiment of the present invention; Figure 2 is a schematic diagram of the interaction process of an interface test provided by an embodiment of the present invention; Figure 3 This is a schematic diagram of an interface testing page provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of an interface testing device provided in an embodiment of the present invention; Figure 5 is an exemplary system architecture diagram in which embodiments of the present invention can be applied; Figure 6 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation

[0027] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0028] like Figure 1 As shown, this embodiment of the invention provides an interface testing method, which may include the following steps: Step S101: Parse the communication interface from the code to be tested; wherein the communication interface includes a gateway interface and an internal communication interface; extract the interface code segment corresponding to each communication interface from the code to be tested, and annotate the corresponding communication interface information for the interface code segment.

[0029] Step S102: Based on the communication interface information of each interface code segment, determine the corresponding call dependency relationship for each gateway interface.

[0030] Step S103: Based on the call dependency relationship, construct interface test cases for each gateway interface. Use the interface test cases to test whether the gateway interface and / or internal communication interface associated with the abnormal interface runs the preset processing logic when the gateway interface and / or internal communication interface experience a call exception.

[0031] Specifically, in this embodiment of the invention, Code LLM (Code Large Language Model) can be used to automatically parse the communication interfaces from the code to be tested. These communication interfaces include gateway interfaces and internal communication interfaces. The gateway interface is a communication interface that can be called by external systems (e.g., application clients, browsers, third-party systems, etc.), while the internal communication interface is, for example, an RPC interface (Remote Procedure Call), representing a communication interface called within the application system. It is understood that the gateway interface can implement the business logic and data interaction provided by the application system by calling one or more internal communication interfaces.

[0032] Furthermore, the interface code segment corresponding to each communication interface is extracted from the code to be tested, and the corresponding communication interface information is labeled for the interface code segment. Specifically, based on the located gateway interfaces and internal communication interfaces, the interface code segment of each communication interface is obtained; wherein, the interface code segment includes interface identifier, interface parameters, interface implementation code logic, return data, etc.

[0033] Furthermore, the communication interface information corresponding to each interface code segment is used to uniquely identify a certain interface code segment, so as to execute subsequent steps to determine the call dependency relationship based on the tagged communication interface information.

[0034] In this embodiment of the invention, for a certain gateway interface, the interface code segment of the gateway interface includes a front-end code segment and a back-end code segment; the step of extracting the interface code segment corresponding to each communication interface from the code to be tested includes: for each gateway interface, extracting the front-end code segment that triggers the gateway interface call; and the back-end code segment that the gateway interface calls one or more internal communication interfaces in the back-end.

[0035] For example, in one application scenario, a user goes through client A -> gateway interface B -> internal communication interface C. The data returned by communication interface C is returned to client A via gateway interface B. That is, the gateway interface is associated with the front-end code segment of the front-end (i.e., client) calling the gateway interface and the back-end code segment of the gateway interface calling the internal communication interface, thereby constructing a full-link call relationship (i.e., call dependency relationship) that includes the gateway interface.

[0036] The following example illustrates a front-end code snippet for a gateway interface: " / gw2 / generic / XXXX / h5 / m / getShareContent": { "method": "getShareContent", "triggers": [{ "type": "click", "element": "await this.getShareContent()", "component": "Inner.vue"} ]}]} In this embodiment of the invention, "gw" is a keyword identifying the "gateway interface," and "triggers" represents the type of frontend call to the gateway interface (e.g., via Click, event, async, lifeCycle, etc.) and the specific business logic. It is understood that the backend code segment does not include the "triggers" part, but includes the specific business logic for calling other internal communication interfaces. Similarly, a frontend call relationship tree is constructed through multiple frontend code segments.

[0037] Furthermore, based on each gateway interface, the call dependencies (call chains) of that gateway interface are constructed.

[0038] In this embodiment of the invention, the call dependency relationship of the gateway interface can be constructed by building a relationship tree that reflects the call logic relationship. The call dependency relationship includes backend call relationships between the gateway interface and one or more internal communication interfaces, and also includes frontend call relationships. The step of determining the corresponding call dependency relationship for each gateway interface based on the communication interface information of each interface code segment includes: constructing a corresponding frontend call relationship tree for each gateway interface based on the first communication interface information of the frontend code segment of each gateway interface; constructing a frontend call relationship for the gateway interface based on the frontend call relationship tree; constructing a corresponding backend call relationship tree for each gateway interface based on the second communication interface information of the backend code segment of each gateway interface; constructing a backend call relationship for the gateway interface based on the backend call relationship tree; and constructing the corresponding call dependency relationship for each gateway interface based on its frontend call relationship and its backend call relationship. The first or second communication interface information is used to uniquely identify a specific interface code segment. The call dependency relationship of each gateway interface is obtained by constructing the frontend relationship tree and the backend relationship tree respectively.

[0039] The data structure of the backend call relationship tree can include: the gateway interface identifier (name), interface description (description), methods included in the interface (methods), and interface parameters; the methods included in the interface include method name (name), method address (path), request type (httpMethod), return parameter type (returnType), and associated RPC interface (i.e., internal communication interface); the RPC interface includes interface name (name) and return parameter type (returnType), etc. Below is a sample data structure of the backend call relationship tree for a gateway interface (OrderGatewayApi), which can be in JSON format: {"name": "OrderGatewayApi", "description": "Order Gateway Interface", "methods": [ {"name": "createGoldOrder", "path": " / order / gold / create", "httpMethod": "POST", "params": [{"name": "orderRequest", "type": "GoldOrderRequest"} ], "returnType": "OrderResponse"}, ] Furthermore, after determining the corresponding call dependencies for each gateway interface, interface test cases are constructed for each gateway interface based on the call dependencies. This includes: for each gateway interface, extracting its associated front-end code segment set and back-end code segment set according to the call dependencies of the gateway interface; and obtaining the test scenario set and expected return result set for the gateway interface; wherein the expected return result set includes normal results and abnormal results; and using the Cartesian product model, performing element combination operations on the front-end code segment set, the back-end code segment set, the test scenario set, and the expected return result set to generate multiple interface test cases covering each test scenario.

[0040] For example, for a gateway interface X, its front-end code segment set is X1, its back-end code segment set is X2, its test scenario set is Y, and its expected return result set is Z. The test scenario includes specific test steps for test points, and the expected return result includes normal or abnormal results corresponding to a specific test scenario. That is, using the Cartesian product model, based on the front-end code segment set, the back-end code segment set, the test scenario set, and the expected return result set, a combination operation of set elements is performed to generate multiple interface test cases covering each test scenario.

[0041] For example, for gateway interface A, the multiple interface test cases built can cover the following two test scenarios:

[0042] For example, gateway interface C depends on RPC interface B, and the multiple interface test cases it constructs can cover the following four test scenarios:

[0043] Specifically, in this embodiment of the invention, automatically generated interface test cases can be used to test whether the gateway interface and / or internal communication interface associated with the abnormal interface runs the preset processing logic when the gateway interface and / or internal communication interface experiences a call exception.

[0044] In some application scenarios, when an access anomaly occurs at a particular communication interface, it is necessary to test whether other associated communication interfaces can run preset processing logic. Running this preset processing logic can maintain the normal operation of the system, thereby improving system fault tolerance and robustness. This preset processing logic includes interface rate limiting logic (e.g., limiting the number of accesses to a communication interface per unit time to overcome the problem of system overload or even crash due to sudden high concurrency requests) and interface degradation logic (e.g., stopping logging, disabling certain settings to reduce resource consumption).

[0045] Further, preferably, when executing tests using interface test cases, simulated test data can be requested from the simulation server (i.e., the server providing the MOCK service), and the tests can be executed using the simulated test data. That is, the gateway interface request during the execution of the interface test case is intercepted, and the simulated test data corresponding to the test requirement data required by the gateway interface request is obtained from the simulation server; the interface return result of the gateway interface is simulated using the simulated test data; and / or, using the simulated test data, combined with the call dependency relationship corresponding to the gateway interface, the linkage return result of the gateway interface and the associated internal communication interface is simulated; if it is determined that the interface return result or the linkage return result is an abnormal result, it is determined whether the gateway interface and / or internal communication interface associated with the abnormal interface runs the preset processing logic.

[0046] By performing interface tests using simulated test data, we can decouple from development, improving development and testing efficiency. We can also simulate different interface return results or linked return results, improving the comprehensiveness and reliability of the test coverage.

[0047] Further preferably, after any interface test case is executed, the first interface identifier of the gateway interface that used simulated test data and / or the second interface identifier of the internal communication interface that used simulated test data are recorded; the test coverage of the gateway interface is calculated based on the first interface identifier, and / or the test coverage of the internal communication interface is calculated based on the second interface identifier. Specifically, in this embodiment of the invention, since simulated test data can be used for testing both the gateway interface and / or the internal communication interface, it is possible to determine whether an interface has been tested by recording whether simulated test data has been used. This step allows for the calculation of test coverage of the gateway interface and / or the internal communication interface from an interface perspective, further improving the comprehensiveness of test coverage and test efficiency.

[0048] Figure 3The diagram shows a page illustration for interface testing, which shows three gateway interfaces. Each gateway interface has an interface identifier, a method identifier for calling the interface (i.e., the gateway interface), a method type, a method environment, a front-end page identifier, and whether simulated test data is used. "√" indicates that simulated test data is used, and "✗" indicates that simulated test data is not used.

[0049] Steps S101 and S102 describe a method for automatically parsing the code to be tested and generating interface test cases. By segmenting, marking, and summarizing the code to be tested at the interface dimension, a logical relationship tree of the interface code segments is generated. This relationship tree serves as the basis for subsequent test case generation and execution, systematically identifying and locating all interfaces that require the execution of pre-defined processing logic. This ensures that the pre-defined processing logic (degradation or rate limiting) of each potential interface is fully checked and verified, reducing the repetitiveness and risk of omissions in manual operations, and improving the accuracy and efficiency of interface analysis; thus enhancing the comprehensiveness, automation, and accuracy of testing.

[0050] Furthermore, by combining the backend call relationship tree with the frontend call relationship tree, this embodiment of the invention can quickly match the dependencies between gateway interfaces and frontend code segments. When the associated RPC interface returns results based on simulated test data, the scope of impact on the frontend can be quickly located, ensuring that the frontend page can respond correctly and be displayed to the user when running preset processing logic (such as degradation). Through the data storage and matching mechanism of the structured backend call relationship tree and the frontend call relationship tree (i.e., call dependencies), the code location where the exception occurred can be accurately located, allowing developers to quickly fix it, improving the stability of the application system and the user experience.

[0051] like Figure 2 As shown, this embodiment of the invention provides an interactive flow for interface testing, which includes: a test front-end, a test server, a simulation server, and a page processing terminal; the flow may include the following steps: Step S201: Generate interface test cases.

[0052] Specifically, the test server obtains the code to be tested (which can be the entire code of the application system or a part of the code for a certain function) through the test frontend, parses out the communication interfaces, extracts the interface code segment of each communication interface, marks each interface code segment, builds interface test cases for each gateway interface, and sends the interface test cases to the test frontend.

[0053] Step S202: Run the interface test cases.

[0054] After the test frontend triggers the execution of the interface test case via the frontend page, the test server can intercept the request sent by the gateway interface and forward it to the simulation server. The simulation server provides the simulated test data required by the gateway interface and provides test return results (e.g., simulated normal return results and simulated abnormal return results). The test server sends the test return results to the test frontend; so that the test frontend renders the frontend page corresponding to the interface test case based on the test return results and automatically obtains the test result image displayed on the frontend page.

[0055] Step S203: Analyze the test results based on the front-end page.

[0056] The test frontend can render the frontend page corresponding to the test case based on the test return results; and trigger the page processing end to perform a screenshot operation on the frontend page. The page processing end sends the screenshot of the test result image to the test server; the test server can analyze the screenshot by comparing the preset result image with the screenshot of the test result image and generate an interface test analysis report. The page processing end can include an automatic screenshot tool or a tool that automatically acquires page images; the test server can use an artificial intelligence visual model to recognize, compare, and analyze the test result images, improving the intelligence and accuracy of determining test results.

[0057] For the test server, it receives the test result image sent by the test frontend and obtains the expected result image of the interface test case; it compares the test result image with the expected result image, and determines whether the return result of the gateway interface or internal communication interface associated with the interface test case meets the preset processing strategy based on the comparison result.

[0058] like Figure 4 As shown, this embodiment of the invention provides an interface testing device 400, including: a code parsing module 401, a relationship building module 402, and an interface testing module 403; wherein, The code parsing module 401 is used to parse the communication interface from the code to be tested; wherein, the communication interface includes a gateway interface and an internal communication interface; extract the interface code segment corresponding to each communication interface from the code to be tested, and annotate the corresponding communication interface information for the interface code segment; The relationship building module 402 is used to determine the corresponding call dependency relationship for each gateway interface based on the communication interface information of each interface code segment; wherein, the call dependency relationship includes the backend call relationship between the gateway interface and one or more internal communication interfaces; The test interface module 403 is used to construct interface test cases for each gateway interface based on the call dependency relationship; and to use the interface test cases to test whether the gateway interface and / or internal communication interface associated with the abnormal interface runs the preset processing logic when the gateway interface and / or internal communication interface experiences a call exception.

[0059] This invention also provides an electronic device for interface testing, comprising: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in any of the above embodiments.

[0060] This invention also provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method provided in any of the above embodiments.

[0061] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements any of the interface testing methods described above.

[0062] Figure 5 An exemplary system architecture 500 is shown that can be applied to the interface testing method or interface testing apparatus of the present invention.

[0063] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, and 503, a network 504, and a server 505. Network 504 serves as the medium for providing communication links between terminal devices 501, 502, and 503 and server 505. Network 504 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0064] Users can use terminal devices 501, 502, and 503 to interact with server 505 via network 504 to receive or send messages, etc. Various client applications can be installed on terminal devices 501, 502, and 503, such as e-commerce client applications, web browser applications, search applications, instant messaging tools, and email clients.

[0065] Terminal devices 501, 502, and 503 can be various electronic devices with displays and supporting various client applications, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0066] Server 505 can be a server that provides various services, such as a backend management server that supports client applications used by users through terminal devices 501, 502, and 503. The backend management server can process the received triggers of interface test cases and feed back the return results of the interface test cases to the terminal devices.

[0067] It should be noted that the interface testing method provided in this embodiment of the invention is generally executed by server 505, and correspondingly, the interface testing device is generally set in server 505.

[0068] It should be understood that Figure 5 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0069] The following is for reference. Figure 6 It shows a schematic diagram of the structure of a computer system 600 suitable for implementing a terminal device of the present invention. Figure 6 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0070] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage section 608 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the system 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0071] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.

[0072] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit (CPU) 601, it performs the functions defined above in the system of this invention.

[0073] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0074] The flowcharts and block diagrams in the accompanying drawings 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 a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0075] The modules and / or units described in the embodiments of the present invention can be implemented in software or hardware. The described modules and / or units can also be housed in a processor; for example, a processor can be described as including a code parsing module, a relationship building module, and a test interface module. The names of these modules do not necessarily limit the module itself; for example, the code parsing module can also be described as "a module that extracts the interface code segment corresponding to each communication interface from the code to be tested."

[0076] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, cause the device to include: the ability to parse communication interfaces (gateway interfaces and internal communication interfaces) from the code to be tested, extract interface code segments of the communication interfaces, determine the corresponding call dependencies for each gateway interface; construct interface test cases for each gateway interface based on the call dependencies; and use the interface test cases to test whether the gateway interface and / or internal communication interface associated with the abnormal interface runs preset processing logic in the event of a call exception occurring at the gateway interface and / or internal communication interface. This invention improves the automation, test coverage, and testing efficiency of communication interface testing by automatically parsing communication interfaces, extracting interface code segments, determining call dependencies between communication interfaces, and constructing interface test cases to test the operation of communication interfaces under normal or abnormal call conditions. Furthermore, this invention can automatically obtain the test result images displayed on the front-end page, comparing the test result images with the expected result images. By analyzing the comparison results, the accuracy and efficiency of test case and result analysis are further improved.

[0077] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. An interface test method characterized by, include: The communication interfaces are parsed from the code to be tested; wherein, the communication interfaces include gateway interfaces and internal communication interfaces; the interface code segment corresponding to each communication interface is extracted from the code to be tested, and the corresponding communication interface information is marked for the interface code segment; Based on the communication interface information of each interface code segment, determine the corresponding call dependency relationship for each gateway interface; Based on the call dependency relationship, construct interface test cases for each gateway interface; use the interface test cases to test whether the gateway interface and / or internal communication interface associated with the abnormal interface runs the preset processing logic in the event of a call exception occurring at the gateway interface and / or internal communication interface.

2. The method according to claim 1, characterized in that, The gateway interface's interface code segment includes a front-end code segment and a back-end code segment; The step of extracting the interface code segment corresponding to each communication interface from the code to be tested includes: For each gateway interface, extract the front-end code segment that triggers the gateway interface call; and the back-end code segment that the gateway interface calls one or more internal communication interfaces in the back-end.

3. The method according to claim 2, characterized in that, The call dependency relationship includes the front-end call relationship and the back-end call relationship between the gateway interface and one or more internal communication interfaces; The step of determining the corresponding call dependency relationship for each gateway interface based on the communication interface information of each interface code segment includes: Based on the first communication interface information of the front-end code segment of each gateway interface, a corresponding front-end call relationship tree is constructed for each gateway interface; and a front-end call relationship is constructed for the gateway interfaces according to the front-end call relationship tree. Based on the second communication interface information of the backend code segment of each gateway interface, a corresponding backend call relationship tree is constructed for each gateway interface; and a backend call relationship is constructed for the gateway interfaces according to the backend call relationship tree. Based on the front-end call relationship and the back-end call relationship of each gateway interface, construct its corresponding call dependency relationship.

4. The method according to claim 2, characterized in that, Based on the aforementioned call dependencies, construct interface test cases for each gateway interface, including: For each gateway interface, based on the call dependency relationship of the gateway interface, extract its associated front-end code segment set and back-end code segment set; and obtain the test scenario set and expected return result set of the gateway interface; wherein, the expected return result set includes normal return results and abnormal return results; Using the Cartesian product model, a set element combination operation is performed based on the set of front-end code segments, the set of back-end code segments, the set of test scenarios, and the set of expected return results to generate multiple interface test cases covering various test scenarios.

5. The method according to claim 1, characterized in that, Further includes: Intercept the gateway interface request during the execution of the interface test case, and obtain the simulated test data corresponding to the test scenario required by the gateway interface request from the simulated server; The simulated test data is used to simulate the test return results of the gateway interface; And / or, Using the simulated test data and the call dependencies corresponding to the gateway interface, simulate the linkage return results of the gateway interface and the associated internal communication interface; If the test return result or the linkage return result is determined to be abnormal, determine whether the gateway interface and / or internal communication interface associated with the abnormal interface is running the preset processing logic.

6. The method according to claim 5, characterized in that, Further includes: After any interface test case is executed, record the first interface identifier of the gateway interface that used the simulated test data, and / or the second interface identifier of the internal communication interface that used the simulated test data; The test coverage of the gateway interface is calculated based on the first interface identifier, and / or the test coverage of the internal communication interface is calculated based on the second interface identifier.

7. The method according to claim 1, characterized in that, Further includes: In response to the execution trigger of the test case for the interface from the test front end, obtain the test return result corresponding to the test case for the interface; The test results are sent to the test frontend, so that the test frontend renders the frontend page corresponding to the interface test case based on the test results and automatically obtains the test result image displayed on the frontend page.

8. The method according to claim 7, characterized in that, Further includes: Receive the test result image sent by the test front-end, and obtain the expected result image of the interface test case; By comparing the test result image with the expected result image, it is determined whether the return result of the gateway interface or internal communication interface associated with the interface test case meets the preset processing strategy.

9. An interface testing device, characterized in that, This includes: a code parsing module, a relationship building module, and a test interface module; among which, The code parsing module is used to parse the communication interface from the code to be tested; wherein, the communication interface includes a gateway interface and an internal communication interface; extract the interface code segment corresponding to each communication interface from the code to be tested, and annotate the corresponding communication interface information for the interface code segment; The relationship building module is used to determine the corresponding call dependency relationship for each gateway interface based on the communication interface information of each interface code segment. The test interface module is used to construct interface test cases for each gateway interface based on the call dependency relationship; and to use the interface test cases to test whether the gateway interface and / or internal communication interface associated with the abnormal interface runs the preset processing logic when the gateway interface and / or internal communication interface experiences a call exception.

10. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-8.

11. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-8.

12. A computer program product, comprising a computer program, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-8.