A testing method, system, device and storage medium for application programming interfaces
By importing interface document data in Jmeter and automatically loading interface data information with Dubbo Sampler, the problem of interface failure caused by input errors in interface testing in the prior art is solved, and more efficient and accurate interface testing is achieved.
Patent Information
- Application Number
- CN202310244084.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-13
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2043-03-13
AI Technical Summary
In the prior art, when accessing the RPC-class interface through Jmeter for testing, it is necessary to input it into the Sampler customized by jmeter according to the interface document one by one, which is easy to cause the interface to be unable to be tuned.
By obtaining interface document data, importing the database to form an interface collection, Dubbo Sampler automatically loads interface data information, performs data testing and returns test results, combining Jmeter and database management interface information.
It solves the problem of input errors in interface testing, improves testing efficiency and accuracy, and simplifies the interface debugging process.
Smart Images

Figure CN116244201B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of application programming interface testing, and particularly relates to a testing method, system, device and storage medium for an application programming interface. Background Art
[0002] When testers write scripts to test RPC (Remote Procedure Call) class interfaces, they need to input parameters one by one according to the interface document into the Sampler customized in jmeter, which is troublesome, time-consuming and extremely prone to input errors, resulting in the inability to access the interface; when accessing RPC class interfaces in Jmeter, there is no dedicated Sampler available and it can only be called through third-party plugins. The input parameters of such plugins need to be manually input by referring to the interface document.
[0003] That is, in the prior art, when accessing RPC class interfaces through Jmeter for testing, parameters need to be input one by one according to the interface document into the Sampler customized in jmeter, which is prone to input errors and results in the inability to access the interface. Summary of the Invention
[0004] To at least overcome to some extent the problem that when accessing RPC class interfaces through Jmeter for testing in the related art, parameters need to be input one by one according to the interface document into the Sampler customized in jmeter, which is prone to input errors and results in the inability to access the interface, this application provides a testing method, system, device and storage medium for an application programming interface.
[0005] The solution of this application is as follows:
[0006] In a first aspect, this application provides a testing method for an application programming interface, and the method includes:
[0007] Obtain relevant data of relevant interface documents;
[0008] Import the relevant data into a database to obtain a first database interface collection;
[0009] Use the first database interface collection to create a Dubbo Sampler, and automatically load all interface data information in the first database interface collection;
[0010] Use all interface data information in the first database interface collection to obtain any method in any of the interface data information, perform data testing, and return relevant test result information of the method.
[0011] Further, by using the first database interface set, create a Dubbo Sampler to automatically load all interface data information in the first database interface set, including:
[0012] Create a Dubbo Sampler by using the first database interface set;
[0013] Use the Dubbo Sampler to connect to the database through the Java application interface and automatically load all interface data information in the first database interface set.
[0014] Further, by using all interface data information in the first database interface set, obtain any method in any of the interface data information, perform data testing, and return the relevant test result information of the method, including:
[0015] Use all interface data information in the first database interface set to select any interface group and load the relevant associated service information in the interface group;
[0016] Call the relevant associated service information to load all interface methods under the relevant associated service information;
[0017] Select any method to be tested, query the interface parameter information and request parameter information of the method, and use the interface parameter information and request parameter information to perform data testing through the Dubbo Sampler, and return the relevant test result information of the method.
[0018] Further, when any method needs to be updated, query the first database interface set. If the method exists, directly perform data update and save it to the first database interface set;
[0019] Otherwise, add the method and save it to the first database interface set.
[0020] In a second aspect, the present application provides a test system for application programming interfaces. The system includes:
[0021] An acquisition module for acquiring relevant data of relevant interface documents;
[0022] A data processing module for importing the relevant data into a database to obtain a first database interface set;
[0023] Create a Dubbo Sampler by using the first database interface set and automatically load all interface data information in the first database interface set;
[0024] A data testing module, which is used to utilize all interface data information in the first database interface collection, obtain any method in any of the interface data information, perform data testing, and return relevant test result information of the method. [[ID=②]]
[0025] [[ID=③]]Thirdly, the present application provides a test device for an application programming interface. The device includes: [[ID=④]] [[ID=⑤]]
[0026] [[ID=⑥]]A memory, on which an executable program is stored; [[ID=⑦]] [[ID=⑧]]
[0027] [[ID=⑨]]A processor, which is used to execute the executable program in the memory to implement the steps of any of the methods described above. [[ID=⑩]] [[ID=⑪]]
[0028] [[ID=⑫]]Fourthly, the present application provides a computer-readable storage medium. The computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a computer to execute the steps of any of the methods described above. [[ID=⑬]] [[ID=⑭]]
[0029] [[ID=⑮]]The technical solution provided by the present application may include the following beneficial effects: [[ID=⑯]] [[ID=⑰]]
[0030] [[ID=⑱]]The present application obtains relevant data of relevant interface documents; imports the relevant data into a database to obtain a first database interface collection; utilizes the first database interface collection to create a Dubbo Sampler, automatically loads all interface data information in the first database interface collection, utilizes all interface data information in the first database interface collection, obtains any method in any of the interface data information, performs data testing, and returns relevant test result information of the method. The present application manages interface information by combining JmeterDubboSampler with a database, which helps to solve the problem that when testing RPC class interfaces through Jmeter, it is necessary to input parameters one by one according to the interface document into the Sampler customized by jmeter, which is prone to input errors resulting in the inability to access the interface, and facilitates subsequent interface testing. [[ID=⑲]] [[ID=⑳]]
[0031] [[ID=㉑]]It should be understood that the above general description and subsequent detailed description are only exemplary and explanatory, and cannot limit the present application. [[ID=㉒]] [[ID=㉓]]BRIEF DESCRIPTION OF THE DRAWINGS [[ID=㉔]] [[ID=㉕]]
[0032] [[ID=㉖]]The accompanying drawings here are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application. [[ID=㉗]] [[ID=㉘]]
[0033] [[ID=㉙]] Figure 1 [[ID=㉚]]is a schematic flowchart of a test method for an application programming interface provided by an embodiment of the present application; [[ID=㉛]] [[ID=㉜]]
[0034] [[ID=㉝]] Figure 2It is a schematic flow chart of a test method for RPC protocol - based APIs using Jmeter provided by an embodiment of the present application;
[0035] Figure 3 It is a schematic diagram of an application programming interface calling dobbo sample provided by an embodiment of the present application;
[0036] Figure 4 It is a schematic diagram of the composition of a test system for an application programming interface provided by another embodiment of the present application;
[0037] Figure 5 It is a schematic diagram of the composition of a test device for an application programming interface provided by another embodiment of the present application. Detailed implementation manners
[0038] Here, exemplary embodiments will be described in detail, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0039] Embodiment 1
[0040] Please refer to Figure 1 , Figure 1 It is a schematic flow chart of a test method for an application programming interface provided by an embodiment of the present application. The method includes:
[0041] S1. Obtain relevant data from relevant interface documents;
[0042] S2. Import the relevant data into a database to obtain a first database interface collection;
[0043] S3. Use the first database interface collection to create a Dubbo Sampler and automatically load all interface data information in the first database interface collection;
[0044] S4. Use all interface data information in the first database interface collection to obtain any method in any of the interface data information, perform data testing, and return relevant test result information of the method.
[0045] In one embodiment, as described in step S3, the using the first database interface collection to create a Dubbo Sampler and automatically load all interface data information in the first database interface collection includes:
[0046] Create a Dubbo Sampler by using the first database interface set.
[0047] Use the Dubbo Sampler to connect to the database through the Java application interface, i.e., JDBC (Java Database Connect), and automatically load all interface data information in the first database interface set.
[0048] In one embodiment, as described in step S4, use all interface data information in the first database interface set to obtain any method in any of the interface data information, perform data testing, and return relevant test result information of the method, including:
[0049] As Figure 2 shown, use all interface data information in the first database interface set to select any interface group and load relevant associated service information in the interface group;
[0050] Call the relevant associated service information and load all interface methods under the relevant associated service information;
[0051] Select any method to be tested, query the interface parameter information and request parameter information of the method, and use the interface parameter information and request parameter information to perform data testing through the Dubbo Sampler and return relevant test result information of the method.
[0052] It should be noted that when any method needs to be updated, query the first database interface set. If the method exists, directly perform data update and save it to the first database interface set;
[0053] Otherwise, add the method and save it to the first database interface set.
[0054] During specific implementation, after the tester obtains the interface document of the interface to be tested, import the interface information into the database.
[0055] In Jmeter, after creating a Dubbo Sampler, as Figure 3 shown, automatically load all interface groups, select the corresponding interface group, and all interfaces in it can be brought out;
[0056] Select an interface, bring out all methods under all interfaces, and you can select the method to be tested. At the same time, its parameter type and request parameters will be brought out.
[0057] As Figure 2As shown, when the interface method needs to be updated, just click save. If the method does not exist in the table, it will be added. If it exists, it will be updated.
[0058] Embodiment 2
[0059] Please refer to Figure 4 , Figure 4 which is a schematic flowchart of a test method for an application programming interface provided by an embodiment of the present application. The system includes:
[0060] An acquisition module 101 for acquiring relevant data of relevant interface documents;
[0061] A data processing module 102 for importing the relevant data into a database to obtain a first database interface collection;
[0062] Using the first database interface collection, create a Dubbo Sampler to automatically load all interface data information in the first database interface collection;
[0063] A data testing module 103 for using all interface data information in the first database interface collection to obtain any method in any of the interface data information, perform data testing, and return relevant test result information of the method.
[0064] Embodiment 3
[0065] Please refer to Figure 5 , Figure 5 which is a schematic flowchart of a test method for an application programming interface provided by an embodiment of the present application. The device includes:
[0066] A memory 31 on which an executable program is stored;
[0067] A processor 32 for executing the executable program in the memory 31 to implement the steps of the method described in any one of the above.
[0068] In addition, the present application provides a computer-readable storage medium storing computer instructions for causing a computer to execute the steps of the method described in any one of the above. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (abbreviation: HDD) or a solid-state drive (SSD), etc.; the storage medium may also include a combination of the above types of memories.
[0069] It can be understood that the same or similar parts in the above embodiments can be referred to each other, and for the content not detailed in some embodiments, reference can be made to the same or similar content in other embodiments.
[0070] It should be noted that in the description of the present application, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present application, unless otherwise specified, the meaning of "a plurality of" refers to at least two.
[0071] Any process or method description shown in the flowchart or described in other ways herein can be understood as representing a module, segment, or part of code including one or more executable instructions for implementing a specific logical function or process. And the scope of the preferred embodiments of the present application includes additional implementations, where the functions can be executed in a manner that is not shown or discussed in the order, including in a substantially simultaneous manner according to the involved functions or in a reverse order, which should be understood by those skilled in the technical field to which the embodiments of the present application belong.
[0072] It should be understood that each part of the present application can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits with logic gate circuits for implementing logical functions on data signals, application specific integrated circuits with appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
[0073] Those of ordinary skill in the art of the present technology can understand that all or part of the steps carried by the methods of the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.
[0074] In addition, each functional unit in the various embodiments of the present application can be integrated into a processing module, or each unit can exist physically alone, or two or more units can be integrated into a module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. When the above integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0075] The above-mentioned storage medium can be a read-only memory, a magnetic disk, an optical disk, etc.
[0076] In the description of this specification, the descriptions referring to terms such as "one embodiment", "some embodiments", "examples", "specific examples", or "some examples", etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of this application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.
[0077] Although the embodiments of this application have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting this application. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A test method for an application programming interface, characterized in that The method includes: Obtain relevant data of relevant interface documents; Import the relevant data into a database to obtain a first database interface collection; Utilize the first database interface collection to create a Dubbo Sampler and automatically load all interface data information in the first database interface collection; Utilize all interface data information in the first database interface collection to obtain any method in any of the interface data information, conduct data testing, and return relevant test result information of the method; The step of utilizing the first database interface collection to create a Dubbo Sampler and automatically load all interface data information in the first database interface collection includes: Utilize the first database interface collection to create a Dubbo Sampler; Utilize the Dubbo Sampler to connect to the database through a Java application programming interface and automatically load all interface data information in the first database interface collection.
2. The method according to claim 1, characterized in that, The step of utilizing all interface data information in the first database interface collection to obtain any method in any of the interface data information, conduct data testing, and return relevant test result information of the method includes: Utilize all interface data information in the first database interface collection to select any interface group and load relevant associated service information in the interface group; Invoke the relevant associated service information and load all interface methods under the relevant associated service information; Select any method to be tested, query the interface parameter information and request parameter information of the method, and utilize the interface parameter information and request parameter information to conduct data testing through the Dubbo Sampler and return relevant test result information of the method.
3. The method according to claim 1, characterized in that, The method further includes: When any method needs to be updated, query the first database interface collection. If the method exists, directly conduct data update and save it to the first database interface collection; Otherwise, add the method and save it to the first database interface collection.
4. A test system for an application programming interface, characterized in that, Applied to the test method of an application programming interface according to any one of claims 1-3, the system includes: An acquisition module for obtaining relevant data of relevant interface documents; A data processing module for importing the relevant data into a database to obtain a first database interface collection; Utilize the first database interface collection to create a Dubbo Sampler and automatically load all interface data information in the first database interface collection; A data testing module for utilizing all interface data information in the first database interface collection to obtain any method in any of the interface data information, conduct data testing, and return relevant test result information of the method.
5. A test device for an application programming interface, characterized in that The device includes: A memory on which an executable program is stored; A processor for executing the executable program in the memory to implement the steps of the method according to any one of claims 1-3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the steps of the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Dubbo interface test method and device, electronic device and storage medium
CN112363907A