Interface testing method and device
By determining the atomic-level exception type in interface testing and generating exception data into the web debugging agent tool, the problems of high invasiveness and low efficiency of existing interface testing solutions are solved, and efficient interface testing is achieved.
Patent Information
- Application Number
- CN202311810538.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-26
- Publication Date
- 2025-07-01
AI Technical Summary
On the one hand, the existing interface testing scheme is highly invasive and has high development and maintenance costs, while on the other hand, it is time-consuming and labor-intensive, and has low testing effectiveness and efficiency.
By determining the target atomic-level exception type in the preset type library, generating exception data and injecting it into the web debugging agent tool, using this tool for interface testing.
Automatic testing based on atomic-level exception types is realized, which improves testing efficiency and effectiveness.
Smart Images

Figure CN120234232A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to the field of automated testing technology, and particularly to an interface testing method and apparatus. Background Art
[0002] A client may encounter various unpredictable situations, such as server failures, network connection interruptions, etc. To improve the stability of the client, the following two testing solutions are proposed: Solution 1) Integrate an SDK in the client, inject abnormal data of the server interface, and detect whether abnormal situations such as client crashes and white screens occur; Solution 2) Randomly or manually simulate interface fields into controlled, unexpected types, etc., generate abnormal data, and return the abnormal data to the client through a client connection proxy to detect whether the client has an abnormality.
[0003] Among them, Solution 1) has a relatively large intrusion on the client, and the development and maintenance costs are relatively high; Solution 2) consumes a lot of time and labor costs when the interface fields are large, and the test effectiveness and efficiency are relatively low. Summary of the Invention
[0004] Embodiments of this application provide an interface testing method, apparatus, device, and storage medium.
[0005] According to a first aspect, an embodiment of this application provides an interface testing method, which includes: in response to obtaining an interface testing request, determining a target atomic-level abnormal type in a preset type library; generating abnormal data based on the abnormal data generation methods corresponding to the atomic-level abnormal types in the target atomic-level abnormal type; injecting the abnormal data into a web debugging proxy tool according to the injection methods corresponding to the atomic-level abnormal types in the target atomic-level abnormal type; and testing the interface to be tested based on the injected web debugging proxy tool.
[0006] According to a second aspect, an embodiment of this application provides an interface testing apparatus, which includes: an obtaining module configured to determine a target atomic-level abnormal type in a preset type library in response to obtaining an interface testing request; a generating module configured to generate abnormal data based on the abnormal data generation methods corresponding to the atomic-level abnormal types in the target atomic-level abnormal type; an injecting module configured to inject the abnormal data into a web debugging proxy tool according to the injection methods corresponding to the atomic-level abnormal types in the target atomic-level abnormal type; and a testing module configured to test the interface to be tested based on the injected web debugging proxy tool.
[0007] According to a third aspect, an embodiment of the present application provides an electronic device, which includes one or more processors; a storage device storing one or more programs thereon, and when the one or more programs are executed by the one or more processors, the one or more processors implement the interface testing method according to any embodiment of the first aspect.
[0008] According to a fourth aspect, an embodiment of the present application provides a computer-readable medium storing a computer program thereon, and when the program is executed by a processor, it implements the interface testing method according to any embodiment of the first aspect.
[0009] In response to obtaining an interface testing request, the present application determines a target atomic-level exception type in a preset type library; generates exception data based on the exception data generation methods corresponding to the atomic-level exception types in the target atomic-level exception type; injects the exception data into a web debugging proxy tool according to the injection methods corresponding to the atomic-level exception types in the target atomic-level exception type; and tests the interface to be tested based on the injected web debugging proxy tool, thereby realizing automated testing based on atomic-level exception types and improving the testing efficiency and effectiveness.
[0010] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 is an exemplary system architecture diagram to which the present application can be applied;
[0012] Figure 2 is a flowchart of an embodiment of the interface testing method according to the present application;
[0013] Figure 3 is a schematic diagram of an application scenario of the interface testing method according to the present application;
[0014] Figure 4 is a flowchart of another embodiment of the interface testing method according to the present application;
[0015] Figure 5 is a flowchart of another embodiment of the interface testing device according to the present application;
[0016] Figure 6 is a schematic diagram of the structure of a computer system of a server suitable for implementing the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0017] The exemplary embodiments of the present application will be described below in conjunction with the accompanying drawings. Various details of the embodiments of the present application are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, descriptions of well-known functions and structures are omitted in the following description for clarity and conciseness.
[0018] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the drawings and in conjunction with the embodiments.
[0019] Figure 1 An exemplary system architecture 100 showing an embodiment of the interface test method to which the present application can be applied is presented.
[0020] As Figure 1 shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0021] The terminal devices 101, 102, 103 interact with the server 105 through the network 104 to receive or send messages, etc. Various application platforms may be installed on the terminal devices 101, 102, 103.
[0022] The terminal devices 101, 102, 103 can be hardware or software. When the terminal devices 101, 102, 103 are hardware, they can be various electronic devices with a display screen, including but not limited to mobile phones, laptop computers, and scanning devices. When the terminal devices 101, 102, 103 are software, they can be installed in the above-listed electronic devices. It can be implemented as multiple software or software modules (for example, used to provide interface test services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0023] The terminal devices 101, 102, 103 are terminal devices that provide various services. For example, upon receiving an interface test request, in a preset type library, a target atomic-level exception type is determined; based on the exception data generation methods corresponding to the atomic-level exception types in the target atomic-level exception type, exception data is generated; according to the injection methods corresponding to the atomic-level exception types in the target atomic-level exception type, the exception data is injected into the web debugging proxy tool; based on the injected web debugging proxy tool, the interface to be tested is tested.
[0024] It should be noted that the server 105 can be hardware or software. When the server 105 is hardware, it can be implemented as a distributed server cluster composed of multiple servers or as a single server. When the server is software, it can be implemented as multiple software or software modules or as a single software or software module. Specific limitations are not made here.
[0025] It should be pointed out that the interface test method provided by the embodiments of the present disclosure can be executed by the terminal devices 101, 102, 103, and can also be executed in cooperation with the server 105 and the terminal devices 101, 102, 103. Correspondingly, each part (such as each unit, subunit, module, submodule) included in the interface test device can be all set in the terminal devices 101, 102, 103, or can be respectively set in the server 105 and the terminal devices 101, 102, 103.
[0026] It should be understood that Figure 1 the numbers of the terminal devices, network, and server in
[0027] Figure 2 are merely illustrative. According to the implementation requirements, there can be any number of terminal devices, network, and server.
[0028] Step 201, in response to obtaining an interface test request, determine a target atomic-level exception type in a preset type library.
[0029] In this embodiment, the execution subject (such as Figure 1 the terminal devices 101, 102, 103 shown in
[0030] can monitor the interface test requests input by the user in a wired connection or wireless connection manner in real time or regularly.
[0031] Among them, the interface test request can include an interface matching rule, and the interface matching rule is used to determine the interface to be tested.
[0031] Further, the execution subject can determine a target atomic-level exception type in a preset type library.
[0032] Among them, the number of atomic-level exception types included in the target atomic-level exception type can be one or multiple, and the present application does not make any limitation on this.
[0033] Specifically, the target atomic-level exception type can include one or more of the following atomic-level exception types: network timeout, HTTP status code exception, array field empty, object field empty, picture connection access exception, price field empty or negative, color value field empty.
[0034] Here, there are various ways for the execution entity to determine the target atomic-level exception type in the type library. For example, one or more preset different atomic-level exception types, such as an empty array field, an empty object field, etc., can be used as the target atomic-level exception type; all atomic-level exception types in the type library can be used as the target atomic-level exception type; based on the corresponding relationship between the preset fault scenarios and the atomic-level exception types, the target atomic-level exception type corresponding to the target fault scenario can be determined, etc. This application does not make any limitations in this regard.
[0035] Among them, the type library can include multiple atomic-level exception types. Each atomic-level exception type is used to indicate an exception type, and the exception types indicated by each atomic-level exception type are different from each other.
[0036] In addition, the interface test request can also include information such as the APP installation package link, page protocol, etc. The execution entity can download the installation package based on the APP installation package link, install it on the client, and use the UI automation to configure the web debugging proxy tool.
[0037] Here, the web debugging proxy tool can be a proxy tool for web debugging in existing technologies or future development technologies. For example, whistle, fiddler, charls, etc.
[0038] The above wireless connection methods can include but are not limited to 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other currently known or future-developed wireless connection methods.
[0039] Step 202: Generate exception data based on the exception data generation methods corresponding to each atomic-level exception type in the target atomic-level exception type.
[0040] In this implementation manner, after obtaining the target atomic-level exception type, the execution entity can generate exception data according to the exception data generation method corresponding to each atomic-level exception type in the target atomic-level exception type.
[0041] Here, the exception data generation methods corresponding to each atomic-level exception type can be pre-configured based on the category of the atomic-level exception type.
[0042] For example, for network timeout, the corresponding abnormal data generation method can be: configure the timeout period, for example, 16s, 20s, etc.; for HTTP status code exceptions, the corresponding abnormal data generation method can be: configure the HTTP status code, for example, 400, 403, 404, 500, etc.; for an array field being empty, the corresponding abnormal data generation method can be: automatically capture the Response Body of the interface, identify the fields in the Response Body whose value type is an array, and modify the value of each field to [] / null; for an object field being empty, the corresponding abnormal data generation method can be: automatically capture the Response Body of the interface, identify the fields in the Response Body whose value type is an object, and modify the value of each field to {} / null; for an exception in accessing a picture link, the corresponding abnormal data generation method can be: automatically capture the Response Body of the interface, identify the fields in the Response Body whose value suffix is '.png / .webp / .avif / .jpg', and modify the value of each field to ""; for a price field being empty or negative, the corresponding abnormal data generation method can be: automatically capture the Response Body of the interface, identify the fields in the Response Body that contain 'price', and modify the value of each field to null / -1; for a color value field being empty, the corresponding abnormal data generation method can be: automatically capture the Response Body of the interface, identify the fields in the Response Body whose prefix is '#' and can be split into 6 characters, and modify the value of each field to "".
[0043] Step 203, inject the abnormal data into the web debugging proxy tool according to the injection methods corresponding to the respective atomic-level abnormal types in the target atomic-level abnormal type.
[0044] In this embodiment, after determining the abnormal data corresponding to the target atomic-level abnormal type, the execution entity can write the abnormal data into the web debugging proxy tool rule in the injection method according to the injection methods corresponding to the respective atomic-level abnormal types in the target atomic-level abnormal type.
[0045] Here, the injection methods corresponding to the respective atomic-level abnormal types can be associated with the web debugging proxy tool.
[0046] Specifically, taking the web debugging proxy tool whistle as an example, for network timeout, the specific injection method can be: {interface matching rule}reqDelay: / / timeout time; for abnormal HTTP status codes, the specific injection method can be: {interface matching rule}statusCode: / / HTTP status code; for empty array fields, empty object fields, abnormal access to image links, empty or negative price fields, empty color value fields, etc., the specific injection method can be: {interface matching rule}resBody: / / {abnormal data}.
[0047] Step 204: Based on the injected web debugging proxy tool, test the interface to be tested.
[0048] In this embodiment, the execution entity can open the page to be tested according to the preset page protocol and test the interface to be tested based on the injected web debugging proxy tool.
[0049] Among them, the interface to be tested can be determined based on the interface matching rule.
[0050] Here, the interface matching rule can include various types. For example, determining the interface to be tested based on the keyword of the interface URL; determining the interface to be tested based on the keyword of the Request Body, etc. This application does not make any limitations in this regard.
[0051] Furthermore, the execution entity can record the detection result by detecting the client log.
[0052] In some alternative ways, the interface matching rule can include: in response to determining that the interface URL meets the preset conditions, determining the interface to be tested based on the interface URL; in response to determining that the interface URL does not meet the preset conditions, determining the interface to be tested based on the keyword in the request body.
[0053] In this implementation, the interface matching rule can include: first determining whether the interface URL meets the preset conditions. If it meets the preset conditions, determining the interface to be tested based on the interface URL. If it does not meet the preset conditions, determining the interface to be tested according to the keyword in the request body, that is, the Request Body.
[0054] Among them, the preset conditions can include: the interface URL includes a keyword for uniquely and correctly identifying the interface.
[0055] Specifically, if the interface URL includes two keywords that can correctly identify the interface, that is, the interface URL can match two different interfaces to be tested, that is, the interface URL does not meet the preset conditions, the execution entity can determine the interface to be tested according to the keyword in the Request Body.
[0056] This implementation method determines the interface to be tested based on the interface URL in response to determining that the interface URL meets the preset conditions; and determines the interface to be tested based on the keywords in the request body in response to determining that the interface URL does not meet the preset conditions, effectively improving the effectiveness and reliability of the determined interface to be tested.
[0057] In some alternative ways, the method further includes: recording the test results in the following ways: detecting client logs and image recognition.
[0058] In this implementation method, after testing the interface to be tested based on the injected web debugging proxy tool, the execution entity can detect whether there are crashes, white screens, null error fields, etc. and record them by detecting client logs and image recognition.
[0059] This implementation method improves the effectiveness and reliability of the test results by recording the test results in the following ways: detecting client logs and image recognition.
[0060] In some alternative ways, the web debugging proxy tool is whistle.
[0061] In this implementation method, the execution entity injects abnormal data into whistle according to the injection method corresponding to each atomic-level exception type to obtain the injected whistle; and tests the interface to be tested based on the injected whistle.
[0062] Among them, whistle is a cross-platform web debugging proxy tool based on Node. Whistle supports multiple operating systems, such as Windows, macOS, Linux, etc. After whistle is installed, the proxy configuration of whistle can be performed through the command line or graphical interface. After the configuration is completed, the proxy can be set to the address of whistle in the browser or other tools, and then network requests can be made. Whistle will intercept and display all network requests and response data. Further, the network requests and response data can be processed and intercepted through plugins or custom scripts.
[0063] Whistle has the advantages of being easy to expand, convenient to configure, and high in security. This method improves the effectiveness and reliability of the test by using the injected whistle to test the interface to be tested.
[0064] Continue to refer to Figure 3 , Figure 3 is a schematic diagram of an application scenario of the interface test method according to this embodiment.
[0065] In Figure 3In the application scenario, the execution entity 301 can monitor the interface test request 302 input by the user in real time or regularly through wired or wireless connection. The interface test request 302 may include: the link of the APP installation package, the sheme protocol of the page, and the interface matching rule. In response to obtaining the interface test request 302, the execution entity may first download the installation package according to the installation package link, automatically install it on the client using a command, and configure whistle for the mobile phone using UI automation. Further, in the preset type library, the target atomic-level exception type 303 is determined. For example, network timeout. The type library includes multiple atomic-level exception types, each atomic-level exception type is used to indicate an exception type, and the exception types indicated by each atomic-level exception type are different; based on the exception data generation method corresponding to each atomic-level exception type in the target atomic-level exception type 303, that is, the exception data generation method corresponding to network timeout: configure the timeout time such as 16s, 20s, etc., to generate the exception data 304; according to the injection method corresponding to each atomic-level exception type in the target atomic-level exception type, such as {interface matching rule}reqDelay: / / timeout time, inject the exception data into the web debugging proxy tool; based on the injected web debugging proxy tool 305, test the interface to be tested 306, and the interface to be tested is determined based on the interface matching rule.
[0066] The interface test method of the present disclosure, by responding to obtaining the interface test request, determines the target atomic-level exception type in the preset type library; generates the exception data based on the exception data generation method corresponding to each atomic-level exception type in the target atomic-level exception type; injects the exception data into the web debugging proxy tool according to the injection method corresponding to each atomic-level exception type in the target atomic-level exception type; and tests the interface to be tested based on the injected web debugging proxy tool, realizes the automated test based on the atomic-level exception type, and improves the test efficiency and effectiveness.
[0067] Figure 4 The flowchart 400 of the embodiment of the interface test method applicable to the present application is shown. In this embodiment, the interface test method includes the following steps:
[0068] Step 401, in response to obtaining the interface test request, in the preset type library, based on the corresponding relationship between the preset fault scenario and the atomic-level exception type, determine the target atomic-level exception type corresponding to the target fault scenario.
[0069] In this embodiment, the execution entity can monitor the interface test request input by the user in real time or regularly through wired or wireless connection.
[0070] Among them, the interface test request may further include the target fault scenario.
[0071] In response to obtaining an interface test request, the execution entity can determine the target atomic-level exception type corresponding to the target fault scenario in a preset type library according to the corresponding relationship between the preset fault scenarios and the atomic-level exception types.
[0072] Among them, there can be multiple fault scenarios. For example, network basic faults, big promotion activity basic faults, etc. This application does not limit this.
[0073] Specifically, if the target fault scenario is a network basic fault, the target atomic-level exception types corresponding to the target fault scenario may include: network timeout, HTTP status code, and gateway code exception.
[0074] In some optional ways, the method further includes: in the preset type library, in response to the failure to determine the target atomic-level exception type corresponding to the target fault scenario, updating the type library based on the target atomic-level exception type.
[0075] In this implementation, if the execution entity fails to determine the target atomic-level exception type corresponding to the target fault scenario in the preset type library according to the corresponding relationship between the preset fault scenarios and the atomic-level exception types, that is, there is no target atomic-level exception type corresponding to the target fault scenario in the preset type library, or only some of the atomic-level exception types in the target atomic-level exception types exist, the type library can be updated according to the target atomic-level exception type.
[0076] Specifically, based on the corresponding relationship between the preset fault scenarios and the atomic-level exception types, determining the target atomic-level exception types corresponding to the target fault scenario includes: atomic-level exception type M, atomic-level exception type N, atomic-level exception type K. If the preset type library only includes atomic-level exception type M and atomic-level exception type N, the execution entity can supplement atomic-level exception type K into the type library to update the type library.
[0077] This implementation realizes the timely update of the type library by updating the type library based on the target atomic-level exception type in response to the failure to determine the target atomic-level exception type corresponding to the target fault scenario in the preset type library.
[0078] Step 402: Generate exception data based on the exception data generation methods corresponding to the atomic-level exception types in the target atomic-level exception type.
[0079] In this embodiment, the implementation details and technical effects of step 402 can refer to the description of step 202 and will not be elaborated here.
[0080] Step 403: Inject the abnormal data into the web debugging proxy tool according to the injection methods corresponding to the atomic-level abnormal types in the target atomic-level abnormal type.
[0081] In this embodiment, for the implementation details and technical effects of step 403, reference may be made to the description of step 203, which will not be elaborated here.
[0082] Step 404: Test the interface to be tested based on the injected web debugging proxy tool.
[0083] In this embodiment, for the implementation details and technical effects of step 404, reference may be made to the description of step 204, which will not be elaborated here.
[0084] From Figure 4 it can be seen that compared with the corresponding embodiment of Figure 2 , in the process 400 of the interface testing method in this embodiment, in response to obtaining an interface test request, in a preset type library, based on the correspondence between the preset fault scenarios and atomic-level abnormal types, the target atomic-level abnormal type corresponding to the target fault scenario is determined; based on the abnormal data generation methods corresponding to the atomic-level abnormal types in the target atomic-level abnormal type, abnormal data is generated; according to the injection methods corresponding to the atomic-level abnormal types in the target atomic-level abnormal type, the abnormal data is injected into the web debugging proxy tool; based on the injected web debugging proxy tool, the interface to be tested is tested, realizing targeted testing based on fault scenarios. Users can freely build scenario-based faults according to their needs, which helps to discover higher-priority problems in a short time and improves the effectiveness and pertinence of interface testing.
[0085] Further referring to Figure 5 , as an implementation of the methods shown in the above figures, an embodiment of an interface testing device is provided in the present application. This device embodiment corresponds to the method embodiment shown in Figure 2 , and this device can be specifically applied to various electronic devices.
[0086] As shown in Figure 5 , the interface testing device 500 in this embodiment includes: an acquisition module 501, a generation module 502, an injection module 503, and a testing module 504.
[0087] Among them, the acquisition module 501 can be configured to determine the target atomic-level abnormal type in a preset type library in response to obtaining an interface test request.
[0088] The generation module 502 can be configured to generate abnormal data based on the abnormal data generation methods corresponding to the atomic-level abnormal types in the target atomic-level abnormal type.
[0089] The injection module 503 can be configured to inject abnormal data into the web debugging proxy tool according to the injection methods corresponding to the atomic-level abnormal types in the target atomic-level abnormal type.
[0090] The testing module 504 can be configured to test the interface to be tested based on the injected web debugging proxy tool.
[0091] In some optional ways of this embodiment, the acquisition module is further configured to determine the target atomic-level abnormal type corresponding to the target fault scenario based on the corresponding relationship between the preset fault scenario and the atomic-level abnormal type in the preset type library.
[0092] In some optional ways of this embodiment, the device further includes an update module, which is configured to update the type library based on the target atomic-level abnormal type in the preset type library in response to the failure to determine the target atomic-level abnormal type corresponding to the target fault scenario.
[0093] In some optional ways of this embodiment, the interface matching rule includes: in response to determining that the interface URL meets the preset conditions, determining the interface to be tested based on the interface URL; in response to determining that the interface URL does not meet the preset conditions, determining the interface to be tested based on the keyword in the request body.
[0094] In some optional ways of this embodiment, the device further includes a recording module, and the recording module is configured to record the test results in the following ways: detecting the client log and image recognition.
[0095] In some optional ways of this embodiment, the web testing proxy tool is whistle.
[0096] It should be noted that in the technical solution of the present disclosure, in terms of the collection, acquisition, update, analysis, processing, use, transmission, storage, etc. of user personal information, it complies with the provisions of relevant laws and regulations, is used for legal purposes, and does not violate public order and good customs. Necessary measures are taken for user personal information to prevent illegal access to user personal information data, and to maintain the security of user personal information, network security, and national security.
[0097] According to the embodiments of the present application, the present application also provides an electronic device and a readable storage medium.
[0098] As Figure 6 shown, it is a block diagram of an electronic device for an interface testing method according to an embodiment of the present application.
[0099] FIG. 600 is a block diagram of an electronic device for an interface testing method according to an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as, a personal digital processor, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or claimed herein.
[0100] As Figure 6 shown, the electronic device includes: one or more processors 601, a memory 602, and an interface for connecting the components, including a high-speed interface and a low-speed interface. The various components are interconnected using different buses and may be installed on a common motherboard or otherwise installed as required. The processor may process instructions executed within the electronic device, including instructions stored in the memory or on the memory to display graphical information of a GUI on an external input / output device (such as, a display device coupled to the interface). In other embodiments, multiple processors and / or multiple buses may be used in conjunction with multiple memories and multiple memories if needed. Similarly, multiple electronic devices may be connected, each device providing part of the necessary operations (e.g., as a server array, a set of blade servers, or a multi-processor system). Figure 6 Here, one processor 601 is taken as an example.
[0101] The memory 602 is the non-transitory computer-readable storage medium provided by the present application. Among them, the memory stores instructions executable by at least one processor, so that the at least one processor executes the interface testing method provided by the present application. The non-transitory computer-readable storage medium of the present application stores computer instructions, and the computer instructions are used to cause a computer to execute the interface testing method provided by the present application.
[0102] The memory 602, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as program instructions / modules corresponding to the interface testing method in the embodiments of the present application (for example, Figure 5 shown, the acquisition module 501, the generation module 502, the injection module 503, and the test module 504). The processor 601 executes various functional applications and data processing of the server by running the non-transitory software programs, instructions, and modules stored in the memory 602, that is, implements the interface testing method in the above method embodiments.
[0103] The memory 602 may include a program storage area and a data storage area. The program storage area may store an operating system and application programs required for at least one function. The data storage area may store data created by the use of the electronic device for interface testing, etc. In addition, the memory 602 may include high-speed random access memory and may also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory 602 may optionally include a memory remotely provided with respect to the processor 601, and these remote memories may be connected to the electronic device for interface testing through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0104] The electronic device for the interface testing method may further include: an input device 603 and an output device 604. The processor 601, the memory 602, the input device 603, and the output device 604 may be connected through a bus or other means. Figure 6 Taking connection through a bus as an example.
[0105] The input device 603 may receive input digital or character information, such as input devices like a touch screen, a keypad, a mouse, a trackpad, a touchpad, a pointing stick, one or more mouse buttons, a trackball, a joystick, etc. The output device 604 may include a display device, an auxiliary lighting device (e.g., an LED), and a haptic feedback device (e.g., a vibration motor), etc. The display device may include but is not limited to a liquid crystal display (LCD), a light-emitting diode (LED) display, and a plasma display. In some embodiments, the display device may be a touch screen.
[0106] Various embodiments of the systems and techniques described herein may be implemented in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application-specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs, the one or more computer programs being executable and / or interpretable on a programmable system including at least one programmable processor, the programmable processor may be a dedicated or general-purpose programmable processor, and may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0107] These computing procedures (also referred to as programs, software, software applications, or code) include machine instructions for a programmable processor and can implement these computing procedures using high-level procedures and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or apparatus (e.g., a magnetic disk, an optical disk, a memory, a programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0108] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0109] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0110] A computer system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other.
[0111] According to the technical solution of the embodiment of the present application, automated testing based on atomic-level exception types is realized, improving the testing efficiency and effectiveness.
[0112] It should be understood that the various forms of processes shown above can be used, with steps reordered, added or deleted. For example, the steps described in this application can be executed in parallel, sequentially or in a different order, as long as the desired results of the technical solution disclosed in this application can be achieved, and no limitation is imposed herein.
[0113] The above specific embodiments do not constitute a limitation on the scope of protection of this application. Those skilled in the art should understand that various modifications, combinations, sub - combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application shall be included within the scope of protection of this application.
Claims
1. An interface testing method, the method comprising: In response to obtaining an interface test request, determining a target atomic-level exception type in a preset type library, the type library including a plurality of atomic-level exception types, each atomic-level exception type being used to indicate an exception type, and the exception types indicated by the respective atomic-level exception types being different from each other, the interface test request including: an interface matching rule; Generating exception data based on the exception data generation methods corresponding to the respective atomic-level exception types in the target atomic-level exception type; Injecting the exception data into a web debugging proxy tool according to the injection methods corresponding to the respective atomic-level exception types in the target atomic-level exception type; Testing the interface to be tested based on the injected web debugging proxy tool, the interface to be tested being determined based on the interface matching rule.
2. The method according to claim 1, wherein, The interface test request further includes: a target failure scenario, and determining the target atomic-level exception type in the preset type library includes: In the preset type library, determining the target atomic-level exception type corresponding to the target failure scenario based on the corresponding relationship between the preset failure scenario and the atomic-level exception type.
3. The method according to claim 2, the method further comprising: In the preset type library, in response to a failure to determine the target atomic-level exception type corresponding to the target failure scenario, updating the type library based on the target atomic-level exception type.
4. According to the method of any one of claims 1-3, wherein, The interface matching rule includes: In response to determining that the interface URL meets a preset condition, determining the interface to be tested based on the interface URL; In response to determining that the interface URL does not meet the preset condition, determining the interface to be tested based on the keyword in the request body.
5. The method according to any one of claims 1-3, the method further comprising: Recording the test results in the following ways: detecting the client log, image recognition.
6. The method according to claim 5, wherein The web test proxy tool is whistle.
7. An interface testing device, the device comprising: An acquisition module configured to, in response to obtaining an interface test request, determine a target atomic-level exception type in a preset type library, the type library including a plurality of atomic-level exception types, each atomic-level exception type being used to indicate an exception type, and the exception types indicated by the respective atomic-level exception types being different from each other, the interface test request including: an interface matching rule; A generation module configured to generate exception data based on the exception data generation methods corresponding to the respective atomic-level exception types in the target atomic-level exception type; An injection module configured to inject the exception data into a web debugging proxy tool according to the injection methods corresponding to the respective atomic-level exception types in the target atomic-level exception type; A test module configured to test the interface to be tested based on the injected web debugging proxy tool, the interface to be tested being determined based on the interface matching rule.
8. The device according to claim 7, wherein, The acquisition module is further configured to: In the preset type library, determine the target atomic-level exception type corresponding to the target failure scenario based on the corresponding relationship between the preset failure scenario and the atomic-level exception type.
9. An electronic device, characterized in that, Including: At least one processor; And A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1-6.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are for causing the computer to perform the method according to any one of claims 1-6.