Interface testing method, device, electronic device and computer readable storage medium
By receiving and utilizing the specific information of the target interface and finding the return results from the test system, the problem of low efficiency of the test interface in the prior art is solved, and more efficient interface testing is achieved.
Patent Information
- Application Number
- CN202210538513.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-17
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-05-17
AI Technical Summary
In the prior art, the problem of low efficiency of the test interface.
By receiving the project name, class name, method name, request parameters and internal logic of the target interface, searching for the first target returns the result from the test system based on this information. If not found, the internal logic of the target interface is executed to find the second target return result, and the test results of the target interface are determined based on these return results.
The efficiency of the test interface is improved and the problem of low efficiency in the prior art is solved.
Smart Images

Figure CN114840372B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of interface testing, and in particular to an interface testing method, device, electronic device, and computer-readable storage medium. Background Art
[0002] Interface testing is a test of the interface between system components. Interface testing is mainly used to detect the interaction points between external systems and systems and between internal subsystems. The focus of the test is to check the data exchange, transmission and control management process, as well as the mutual logical dependencies between systems. When testing an interface, the prior art searches for the content corresponding to the interface from multiple databases in the test system, and then assembles all the content corresponding to the interface to obtain the return result, and obtains the test result corresponding to the interface based on the return result. The entire process of testing the interface is labor-intensive and inefficient.
[0003] In the process of implementing the concept of the present disclosure, the inventors discovered that there are at least the following technical problems in the related art: the problem of low efficiency of the test interface. Summary of the invention
[0004] In view of this, the embodiments of the present disclosure provide an interface testing method, device, electronic device and computer-readable storage medium to solve the problem of low efficiency of testing interfaces in the prior art.
[0005] According to a first aspect of an embodiment of the present disclosure, an interface testing method is provided, comprising: receiving at least one of the following: a target project name, a target class name, a target method name, a target request parameter, and a target internal logic corresponding to a target interface; searching a test system for a first target return result corresponding to the target interface based on at least one of the following: the target project name, the target class name, the target method name, and the target request parameter; when the first target return result is found, determining a target test result corresponding to the target interface according to the first target return result; when the first target return result is not found, executing the target internal logic corresponding to the target interface to search the test system for a second target return result corresponding to the target interface, and determining the target test result corresponding to the target interface according to the second target return result.
[0006] According to a second aspect of an embodiment of the present disclosure, an interface testing device is provided, comprising: a receiving module, configured to receive at least one of the following: a target project name, a target class name, a target method name, a target request parameter and a target internal logic corresponding to a target interface; a searching module, configured to search a first target return result corresponding to the target interface from a testing system based on at least one of the following: the target project name, the target class name, the target method name and the target request parameter; a first determining module, configured to determine a target test result corresponding to the target interface according to the first target return result when the first target return result is found; and a second determining module, configured to execute the target internal logic corresponding to the target interface when the first target return result is not found, so as to search the test system for a second target return result corresponding to the target interface, and determine the target test result corresponding to the target interface according to the second target return result.
[0007] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0008] According to a fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0009] The beneficial effects of the disclosed embodiment compared with the prior art are: because the disclosed embodiment receives at least one of the following: the target project name, target class name, target method name, target request parameters and target internal logic corresponding to the target interface; based on at least one of the following, the first target return result corresponding to the target interface is searched from the test system; when the first target return result is found, the target test result corresponding to the target interface is determined according to the first target return result; when the first target return result is not found, the target internal logic corresponding to the target interface is executed to search the second target return result corresponding to the target interface from the test system, and determine the target test result corresponding to the target interface according to the second target return result. Therefore, the above-mentioned technical means can solve the problem of low efficiency of the test interface in the prior art, thereby improving the efficiency of the test interface. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0011] Figure 1 is a schematic diagram of an application scenario of an embodiment of the present disclosure;
[0012] Figure 2 is a flowchart of an interface testing method provided by an embodiment of the present disclosure;
[0013] Figure 3 is a structural schematic diagram of an interface testing device provided by an embodiment of the present disclosure;
[0014] Figure 4 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0015] In the following description, specific details such as specific system structures and technologies are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present disclosure. However, it should be clear to those skilled in the art that the present disclosure may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obstructing the description of the present disclosure with unnecessary details.
[0016] An interface testing method and device according to an embodiment of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0017] Figure 1 Schematic diagram of an application scenario of an embodiment of the present disclosure. The application scenario may include terminal devices 1, 2 and 3, a server 4 and a network 5.
[0018] Terminal devices 1, 2 and 3 can be hardware or software. When terminal devices 1, 2 and 3 are hardware, they can be various electronic devices with display screens and supporting communication with server 4, including but not limited to smart phones, tablet computers, laptop portable computers and desktop computers, etc.; when terminal devices 1, 2 and 3 are software, they can be installed in the above electronic devices. Terminal devices 1, 2 and 3 can be implemented as multiple software or software modules, or as a single software or software module, and the embodiments of the present disclosure are not limited to this. Furthermore, various applications can be installed on terminal devices 1, 2 and 3, such as data processing applications, instant messaging tools, social platform software, search applications, shopping applications, etc.
[0019] The server 4 may be a server that provides various services, for example, a background server that receives a request sent by a terminal device that establishes a communication connection with the server, and the background server may receive and analyze the request sent by the terminal device, and generate a processing result. The server 4 may be a single server, or a server cluster composed of several servers, or a cloud computing service center, which is not limited in the embodiments of the present disclosure.
[0020] It should be noted that the server 4 can be hardware or software. When the server 4 is hardware, it can be various electronic devices that provide various services for the terminal devices 1, 2, and 3. When the server 4 is software, it can be multiple software or software modules that provide various services for the terminal devices 1, 2, and 3, or it can be a single software or software module that provides various services for the terminal devices 1, 2, and 3, and the embodiments of the present disclosure are not limited to this.
[0021] The network 5 can be a wired network connected by coaxial cable, twisted pair and optical fiber, or it can be a wireless network that can interconnect various communication devices without wiring, such as Bluetooth, Near Field Communication (NFC), infrared, etc., which is not limited in the embodiments of the present disclosure.
[0022] The user can establish a communication connection with the server 4 via the network 5 through the terminal devices 1, 2 and 3 to receive or send information, etc. It should be noted that the specific types, quantities and combinations of the terminal devices 1, 2 and 3, the server 4 and the network 5 can be adjusted according to the actual needs of the application scenario, and the embodiments of the present disclosure are not limited to this.
[0023] Interface testing can be performed within terminal devices 1, 2, 3 and server 4 (mainly the interaction between subsystems or components within each hardware device or server); interface testing can also be performed between terminal devices 1, 2, 3 and server 4 (mainly the interaction between every two hardware devices or one hardware device and the server).
[0024] Figure 2 It is a flowchart of an interface testing method provided by an embodiment of the present disclosure. Figure 2 The interface test method can be Figure 1 The terminal device or server executes. Figure 2 As shown, the interface testing method includes:
[0025] S201, receiving at least one of the following: a target project name, a target class name, a target method name, a target request parameter, and a target internal logic corresponding to a target interface;
[0026] S202, searching the test system for a first target return result corresponding to the target interface based on at least one of the following: a target project name, a target class name, a target method name, and a target request parameter;
[0027] S203, when the first target return result is found, determining the target test result corresponding to the target interface according to the first target return result;
[0028] S204, when the first target return result is not found, executing the target internal logic corresponding to the target interface to search the second target return result corresponding to the target interface from the test system, and determining the target test result corresponding to the target interface according to the second target return result.
[0029] The interface can be roughly divided into six parts, namely: project name, class name, method name, request parameters, internal logic and return results. The project name can be a payment project or an order project, etc.; the class name can be a user or an order, etc.; the method name can be to query an order or update an order, etc.; the request parameter can be the order number of the order to be queried); the internal logic can be the specific execution steps corresponding to the method name, such as querying an order, which databases should be checked, and how to assemble the query results, etc.; the return result is the final result returned, such as the result after assembling the query results.
[0030] Optionally, the first target return result corresponding to the target interface can be searched in the test system according to the target project name, target class name and target method name. The first target return result determines the target test result corresponding to the target interface. For example, if the first target return result meets the preset conditions, the target test result is that the target interface test is good; if the first target return result does not meet the preset conditions, the target test result is that the target interface test fails. For example, if the first target return result is not the content corresponding to the target interface, the target interface test fails.
[0031] If the first target return result is not found, the target internal logic corresponding to the target interface is executed to search the test system for the second target return result corresponding to the target interface.
[0032] According to the technical solution provided by the embodiment of the present disclosure, because the embodiment of the present disclosure receives at least one of the following: the target project name, target class name, target method name, target request parameters and target internal logic corresponding to the target interface; based on at least one of the following, the first target return result corresponding to the target interface is searched from the test system: the target project name, the target class name, the target method name and the target request parameters; when the first target return result is found, the target test result corresponding to the target interface is determined according to the first target return result; when the first target return result is not found, the target internal logic corresponding to the target interface is executed to search for the second target return result corresponding to the target interface from the test system, and determine the target test result corresponding to the target interface according to the second target return result. Therefore, the above-mentioned technical means can be used to solve the problem of low efficiency of the test interface in the prior art, thereby improving the efficiency of the test interface.
[0033] In step S201, before receiving at least one of the following: a target project name, a target class name, a target method name, a target request parameter, and a target internal logic corresponding to a target interface, the method further includes: obtaining a test database, wherein the test database includes multiple interfaces and a project name, a class name, a method name, a request parameter, and an internal logic corresponding to each interface; generating a corresponding first return result for each interface according to at least one of the following: a project name, a class name, a method name, and a request parameter corresponding to each interface; or executing the internal logic corresponding to each interface to search the test system for a second return result corresponding to each interface, and determining the second return result as the first return result; saving the project name, class name, method name, request parameter, internal logic, and the first return result corresponding to each interface as a set of data in a query database, wherein the test system includes a query database.
[0034] The present invention is that before the interface test is performed, the first return result of each interface is edited according to the project name, class name, method name, request parameter and internal logic corresponding to each interface; then the project name, class name, method name, request parameter, internal logic and the first return result corresponding to each interface are saved as a set of data in the query database; when the interface test is performed, the first return result corresponding to the interface is searched from the query database in the test system based on at least one of the following: project name, class name, method name and request parameter; if the first return result corresponding to the interface is not found in the query database, the internal logic corresponding to the interface is executed to search for the second return result corresponding to the interface from the test system; then the second return result is determined as the first return result and saved in the query database. Because the first return result of each interface is edited according to the project name, class name, method name, request parameter and internal logic corresponding to each interface, there is actually a corresponding relationship between the project name, class name, method name, request parameter, internal logic and the first return result corresponding to each interface, so the first return result corresponding to a certain interface can be searched from the query database in the test system based on at least one of the following: project name, class name, method name and request parameter.
[0035] The project name, class name, method name, request parameters, internal logic and first return result corresponding to each interface are saved as a set of data in a query database, wherein, after the test system includes querying the database, the method also includes: receiving a modification instruction; and updating one or more first return results corresponding to one or more interfaces that need to be modified in the query database according to the modification instruction.
[0036] In the prior art, when testing an interface, the content corresponding to the interface is searched from multiple databases in the test system, and then all the content corresponding to the interface is assembled to obtain the return result. Therefore, if the prior art wants to modify the return result of the interface, it is necessary to modify the content corresponding to the interface in multiple databases in the test system. However, the embodiment of the present disclosure can directly modify the first return result corresponding to the interface in the query database.
[0037] In step S203, when the first target return result is found, the target test result corresponding to the target interface is determined according to the first target return result, including: when the first target return result is found, the first target return result is converted into a target object; and the target test result corresponding to the target interface is determined according to the target object.
[0038] Convert the first target return result into a target object, that is, convert the format of the first target return result. The format of the first target return result is json language (the database is generally saved in json language), and the target object is an object-oriented language (object-oriented language can be used directly).
[0039] In step S203, when the first target return result is not found, the target internal logic corresponding to the target interface is executed to search for the second target return result corresponding to the target interface from the test system, and determine the target test result corresponding to the target interface based on the second target return result, including: determining the second target return result as the first target return result; saving the first target return result and at least one of the following: target project name, target class name, target method name and target request parameters as a set of data in a query database, wherein the test system includes a query database.
[0040] The second target return result is used as the first target return result, and the first target return result and at least one of the following: target project name, target class name, target method name and target request parameter are saved as a set of data in the query database; when the target interface is tested next time, the first target return result in the query database can be directly used to improve the efficiency of the interface test. Therefore, the more interfaces tested in the embodiment of the present disclosure, the higher the efficiency of the interface test.
[0041] In an optional embodiment, it includes: deleting one or more items that do not need to be tested in the test system through an item deletion button, wherein the test system includes multiple interfaces and items corresponding to each interface; and controlling the status of each item in the test system to enable testing or disable testing through an item status control button.
[0042] In order to improve the testing efficiency of the interface in the test system, the embodiment of the present disclosure can delete one or more items that do not need to be tested in the test system through the item deletion button (then the interface corresponding to the item also does not need to be tested); the status of the item is enabled testing, which means that the item is allowed to be tested, or is to be tested; the status of the item is disabled testing, which means that the item is not allowed to be tested.
[0043] In an optional embodiment, it includes: deleting one or more interfaces that do not need to be tested in the test system through an interface deletion button, wherein the test system includes multiple interfaces; controlling the status of each interface in the test system to enable testing or disable testing through an interface status control button; and updating one or more interfaces that need to be edited in the test system through an interface editing button.
[0044] In order to improve the testing efficiency of interfaces in the test system, the embodiment of the present disclosure can delete one or more interfaces that do not need to be tested in the test system through an interface deletion button; the status of the interface is enabled testing, which means that the interface allows testing, or is to be tested; the status of the interface is disabled testing, which means that the interface does not allow testing; the project name, class name, method name, request parameters, internal logic and return results corresponding to the interface that can be edited through the interface editing button.
[0045] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0046] The following are embodiments of the device disclosed herein, which can be used to execute the method embodiments disclosed herein. For details not disclosed in the device embodiments disclosed herein, please refer to the method embodiments disclosed herein.
[0047] Figure 3 Schematic diagram of an interface testing device provided by an embodiment of the present disclosure. Figure 3 As shown, the interface testing device comprises:
[0048] The receiving module 301 is configured to receive at least one of the following: a target project name, a target class name, a target method name, a target request parameter, and a target internal logic corresponding to a target interface;
[0049] The search module 302 is configured to search for a first target return result corresponding to a target interface from the test system based on at least one of the following: a target project name, a target class name, a target method name, and a target request parameter;
[0050] The first determination module 303 is configured to determine the target test result corresponding to the target interface according to the first target return result when the first target return result is found;
[0051] The second determination module 304 is configured to execute the target internal logic corresponding to the target interface to search for the second target return result corresponding to the target interface from the test system when the first target return result is not found, and determine the target test result corresponding to the target interface according to the second target return result.
[0052] The interface can be roughly divided into six parts, namely: project name, class name, method name, request parameters, internal logic and return results. The project name can be a payment project or an order project, etc.; the class name can be a user or an order, etc.; the method name can be to query an order or update an order, etc.; the request parameter can be the order number of the order to be queried); the internal logic can be the specific execution steps corresponding to the method name, such as querying an order, which databases should be checked, and how to assemble the query results, etc.; the return result is the final result returned, such as the result after assembling the query results.
[0053] Optionally, the search module 302 is further configured to search the first target return result corresponding to the target interface in the test system according to the target project name, the target class name and the target method name. The first target return result determines the target test result corresponding to the target interface. For example, if the first target return result meets the preset conditions, the target test result is that the target interface test is good; if the first target return result does not meet the preset conditions, the target test result is that the target interface test fails. For example, if the first target return result is not the content corresponding to the target interface, the target interface test fails.
[0054] If the first target return result is not found, the target internal logic corresponding to the target interface is executed to search the test system for the second target return result corresponding to the target interface.
[0055] According to the technical solution provided by the embodiment of the present disclosure, because the embodiment of the present disclosure receives at least one of the following: the target project name, target class name, target method name, target request parameters and target internal logic corresponding to the target interface; based on at least one of the following, the first target return result corresponding to the target interface is searched from the test system: the target project name, the target class name, the target method name and the target request parameters; when the first target return result is found, the target test result corresponding to the target interface is determined according to the first target return result; when the first target return result is not found, the target internal logic corresponding to the target interface is executed to search for the second target return result corresponding to the target interface from the test system, and determine the target test result corresponding to the target interface according to the second target return result. Therefore, the above-mentioned technical means can be used to solve the problem of low efficiency of the test interface in the prior art, thereby improving the efficiency of the test interface.
[0056] Optionally, the receiving module 301 is also configured to obtain a test database, wherein the test database includes multiple interfaces and a project name, class name, method name, request parameters and internal logic corresponding to each interface; generate a corresponding first return result for each interface according to at least one of the following: a project name, class name, method name and request parameters corresponding to each interface; or execute the internal logic corresponding to each interface to search the test system for a second return result corresponding to each interface, and determine the second return result as the first return result; save the project name, class name, method name, request parameters, internal logic and first return result corresponding to each interface as a set of data in a query database, wherein the test system includes a query database.
[0057] The present invention is that before the interface test is performed, the first return result of each interface is edited according to the project name, class name, method name, request parameter and internal logic corresponding to each interface; then the project name, class name, method name, request parameter, internal logic and the first return result corresponding to each interface are saved as a set of data in the query database; when the interface test is performed, the first return result corresponding to the interface is searched from the query database in the test system based on at least one of the following: project name, class name, method name and request parameter; if the first return result corresponding to the interface is not found in the query database, the internal logic corresponding to the interface is executed to search for the second return result corresponding to the interface from the test system; then the second return result is determined as the first return result and saved in the query database. Because the first return result of each interface is edited according to the project name, class name, method name, request parameter and internal logic corresponding to each interface, there is actually a corresponding relationship between the project name, class name, method name, request parameter, internal logic and the first return result corresponding to each interface, so the first return result corresponding to a certain interface can be searched from the query database in the test system based on at least one of the following: project name, class name, method name and request parameter.
[0058] Optionally, the receiving module 301 is further configured to receive a modification instruction; and update one or more first returned results corresponding to one or more interfaces that need to be modified in the query database according to the modification instruction.
[0059] In the prior art, when testing an interface, the content corresponding to the interface is searched from multiple databases in the test system, and then all the content corresponding to the interface is assembled to obtain the return result. Therefore, if the prior art wants to modify the return result of the interface, it is necessary to modify the content corresponding to the interface in multiple databases in the test system. However, the embodiment of the present disclosure can directly modify the first return result corresponding to the interface in the query database.
[0060] Optionally, the first determination module 303 is further configured to convert the first target return result into a target object when the first target return result is found; and determine the target test result corresponding to the target interface according to the target object.
[0061] Convert the first target return result into a target object, that is, convert the format of the first target return result. The format of the first target return result is json language (the database is generally saved in json language), and the target object is an object-oriented language (object-oriented language can be used directly).
[0062] Optionally, the first determination module 303 is also configured to determine the second target return result as the first target return result; save the first target return result and at least one of the following: target project name, target class name, target method name and target request parameter as a set of data in a query database, wherein the test system includes a query database.
[0063] The second target return result is used as the first target return result, and the first target return result and at least one of the following: target project name, target class name, target method name and target request parameter are saved as a set of data in the query database; when the target interface is tested next time, the first target return result in the query database can be directly used to improve the efficiency of the interface test. Therefore, the more interfaces tested in the embodiment of the present disclosure, the higher the efficiency of the interface test.
[0064] Optionally, the receiving module 301 is also configured to delete one or more items that do not need to be tested in the test system through an item deletion button, wherein the test system includes multiple interfaces and items corresponding to each interface; and to control the status of each item in the test system to enable testing or disable testing through an item status control button.
[0065] In order to improve the testing efficiency of the interface in the test system, the embodiment of the present disclosure can delete one or more items that do not need to be tested in the test system through the item deletion button (then the interface corresponding to the item also does not need to be tested); the status of the item is enabled testing, which means that the item is allowed to be tested, or is to be tested; the status of the item is disabled testing, which means that the item is not allowed to be tested.
[0066] Optionally, the receiving module 301 is also configured to delete one or more interfaces that do not need to be tested in the test system through an interface deletion button, wherein the test system includes multiple interfaces; control the status of each interface in the test system to enable testing or disable testing through an interface status control button; and update one or more interfaces that need to be edited in the test system through an interface editing button.
[0067] In order to improve the testing efficiency of interfaces in the test system, the embodiment of the present disclosure can delete one or more interfaces that do not need to be tested in the test system through an interface deletion button; the status of the interface is enabled testing, which means that the interface allows testing, or is to be tested; the status of the interface is disabled testing, which means that the interface does not allow testing; the project name, class name, method name, request parameters, internal logic and return results corresponding to the interface that can be edited through the interface editing button.
[0068] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.
[0069] Figure 4 Schematic diagram of an electronic device 4 provided in an embodiment of the present disclosure. Figure 4 As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 401 executes the computer program 403, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0070] The electronic device 4 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 4 may include, but is not limited to, a processor 401 and a memory 402. Those skilled in the art will appreciate that Figure 4 The electronic device 4 is merely an example and does not limit the electronic device 4 , and may include more or less components than those shown in the figure, or different components.
[0071] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0072] The memory 402 may be an internal storage unit of the electronic device 4, for example, a hard disk or memory of the electronic device 4. The memory 402 may also be an external storage device of the electronic device 4, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 4. The memory 402 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 402 is used to store computer programs and other programs and data required by the electronic device.
[0073] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0074] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present disclosure implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0075] The above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should all be included in the protection scope of the present disclosure.
Claims
1. An interface testing method, characterized in that: include: Receive at least one of the following: a target project name, a target class name, a target method name, a target request parameter, and a target internal logic corresponding to a target interface; Searching for a first target return result corresponding to the target interface from a test system based on at least one of the following: the target project name, the target class name, the target method name, and the target request parameter; When the first target return result is found, determining the target test result corresponding to the target interface according to the first target return result; When the first target return result is not found, executing the target internal logic corresponding to the target interface to search the second target return result corresponding to the target interface from the test system, and determining the target test result corresponding to the target interface according to the second target return result; Wherein, before receiving at least one of the following: the target project name, target class name, target method name, target request parameters and target internal logic corresponding to the target interface, the method further includes: obtaining a test database, wherein the test database includes multiple interfaces and the project name, class name, method name, request parameters and internal logic corresponding to each interface; generating a corresponding first return result for each interface according to at least one of the following: the project name, class name, method name and request parameters corresponding to each interface; or executing the internal logic corresponding to each interface to search the test system for the second return result corresponding to each interface, and determine the second return result as the first return result; saving the project name, class name, method name, request parameters, internal logic and first return result corresponding to each interface as a set of data in a query database, wherein the test system includes the query database; Wherein, when the first target return result is not found, the target internal logic corresponding to the target interface is executed to find the second target return result corresponding to the target interface from the test system, and determine the target test result corresponding to the target interface according to the second target return result, including: determining the second target return result as the first target return result; saving the first target return result and at least one of the following: the target project name, the target class name, the target method name and the target request parameter as a set of data in a query database, wherein the test system includes the query database.
2. The method according to claim 1, characterized in that The project name, class name, method name, request parameter, internal logic and first return result corresponding to each interface are stored in a query database as a set of data, wherein after the test system includes the query database, the method further includes: Receive modification instructions; According to the modification instruction, one or more first returned results corresponding to the one or more interfaces that need to be modified in the query database are updated.
3. The method according to claim 1, characterized in that When the first target return result is found, determining the target test result corresponding to the target interface according to the first target return result includes: When the first target return result is found, converting the first target return result into a target object; A target test result corresponding to the target interface is determined according to the target object.
4. The method according to claim 1, characterized in that: include: Deleting one or more items that do not need to be tested in the test system through an item deletion button, wherein the test system includes multiple interfaces and items corresponding to each interface; The status of each item in the test system is controlled by the item status control button to enable the test or disable the test.
5. The method according to claim 1, characterized in that include: Deleting one or more interfaces in the test system that do not need to be tested by an interface deletion button, wherein the test system includes a plurality of interfaces; Control the state of each interface in the test system to enable testing or disable testing by an interface state control button; One or more interfaces that need to be edited in the test system are updated through the interface editing button.
6. An interface testing device, characterized in that: include: The receiving module is configured to receive at least one of the following: a target project name, a target class name, a target method name, a target request parameter, and a target internal logic corresponding to the target interface; A search module is configured to search for a first target return result corresponding to the target interface from the test system based on at least one of the following: the target project name, the target class name, the target method name, and the target request parameter; A first determination module is configured to determine a target test result corresponding to the target interface according to the first target return result when the first target return result is found; A second determination module is configured to execute the target internal logic corresponding to the target interface to search the test system for a second target return result corresponding to the target interface when the first target return result is not found, and determine the target test result corresponding to the target interface according to the second target return result; The receiving module is further configured to obtain a test database, wherein the test database includes a plurality of interfaces and a project name, a class name, a method name, a request parameter, and an internal logic corresponding to each interface; generate a corresponding first return result for each interface according to at least one of the following: a project name, a class name, a method name, and a request parameter corresponding to each interface; or execute the internal logic corresponding to each interface to search the test system for a second return result corresponding to each interface, and determine the second return result as the first return result; save the project name, the class name, the method name, the request parameter, the internal logic, and the first return result corresponding to each interface as a set of data in a query database, wherein the test system includes the query database; The second determination module is also configured to determine the second target return result as the first target return result; save the first target return result and at least one of the following: the target project name, the target class name, the target method name and the target request parameter as a set of data in a query database, wherein the test system includes the query database.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Interface testing method and device
CN109992495A