Interface testing method and device
By grabbing interface data and merging test cases, automatic testing scenarios are realized, and the problem of incomplete testing in the existing technology is solved, testing efficiency and accuracy are improved, and manpower and material investment is reduced.
Patent Information
- Application Number
- CN201811405501.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-11-23
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2038-11-23
AI Technical Summary
The existing black box testing system cannot test the data not displayed by the software, resulting in the incomplete test scenario, long test cycle and a large amount of manpower and material resources.
Provide an interface testing method and device, which can capture data in interface description documents, write and merge test cases, realize automatic testing of multiple test scenarios, generate test results and determine whether the interface meets the test requirements, and support storage test groups and Report.
It realizes fast and efficient interface testing, reduces manpower and material investment, improves testing efficiency and accuracy, and the generated test reports are clear and standardized, and supports automatic execution of timed and automatic execution.
Smart Images

Figure CN111221718B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of testing technology, and in particular to an interface testing method and device. Background Art
[0002] In the existing black box testing system, testing can only be performed based on the data displayed by the software, and data that is not displayed by the software cannot be tested, and some special scenarios cannot be tested. This leads to problems such as incomplete testing scenarios, long testing cycles, and high testing capital requirements. In order to solve the above problems, more manpower and material resources need to be invested. Summary of the invention
[0003] In view of this, an object of the embodiments of the present invention is to provide an interface testing method and device, which can quickly and efficiently implement interface testing and reduce the investment in manpower and material resources.
[0004] Based on the above purpose, an embodiment of the present invention provides an interface testing method, including:
[0005] Capture the interface data in the interface description document;
[0006] Write multiple test cases according to the interface data, and merge the multiple test cases into a test group;
[0007] The interface is automatically tested for multiple test scenarios according to the test group to generate test results.
[0008] Optionally, the interface data includes an interface address, interface parameters, and a scene domain name.
[0009] Optionally, merging the multiple test cases into a test group includes: merging the multiple test cases into the test group in a chronological order of timestamps.
[0010] Optionally, the automatically testing the interface according to the test group for multiple test scenarios to generate the test results includes:
[0011] Generate a test report based on the running results of the test group;
[0012] According to the test report, determine whether the interface meets the interface test requirements.
[0013] Optionally, the method further includes: storing the test group and the test report in a database.
[0014] The embodiment of the present invention further provides an interface testing device, comprising:
[0015] A capture module is used to capture the interface data in the interface description document;
[0016] A writing module, used for writing multiple test cases according to the interface data, and merging the multiple test cases into a test group;
[0017] The test module is used to automatically test the interface in multiple test scenarios according to the test group and generate test results.
[0018] Optionally, the interface data includes an interface address, interface parameters, and a scene domain name.
[0019] Optionally, the writing module is further used to implement: merging the multiple test cases into the test group in the order of timestamps.
[0020] Optionally, the test module is further used to implement:
[0021] Generate a test report based on the running results of the test group;
[0022] According to the test report, determine whether the interface meets the interface test requirements.
[0023] Optionally, a storage module is also included, and the storage module is used to store the test group and the test report in a database.
[0024] From the above description, it can be seen that an interface testing method and device provided by an embodiment of the present invention, the test script can accurately obtain the information of the interface in the interface description document; the test script runs multiple test scenarios to implement the testing of multiple test scenarios, and can automatically execute the script at a fixed time, which can greatly improve the testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 A schematic diagram of a flow chart of an interface testing method according to an embodiment of the present invention;
[0026] Figure 2 It is a schematic diagram of the structure of the interface testing device described in an embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.
[0028] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two non-identical entities with the same name or non-identical parameters. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present invention. The subsequent embodiments will not explain this one by one.
[0029] Figure 1 The figure is a flow chart of the interface testing method according to an embodiment of the present invention.
[0030] An embodiment of the present invention provides an interface testing method, including:
[0031] Step 101, capture interface data in the interface description document.
[0032] Optionally, the interface data includes interface address, interface parameters, scene domain name, etc. The getapiinfo() function is used to capture the interface data in the interface description document, and the obtained interface data, i.e., the return value, includes the interface address url, interface parameters parames, and scene domain name host.
[0033] In order to facilitate the capture of interface data in the interface description document, the interface description document needs to be standardized. Specifically, the scenario domain name, request method and other information can be written according to the parameter type, so that the test script can accurately capture the interface address, interface parameters, scenario domain name and other interface data in the interface description document.
[0034] Step 102: compile multiple test cases according to the interface data, and merge the multiple test cases into a test group.
[0035] Optionally, merging the multiple test cases into a test group includes: merging the multiple test cases into the test group in the order of timestamps. After merging into the test group, when the interfaces are tested at the same time, the interfaces can be automatically tested in sequence in the order of the test group, without the need for separate operations each time, which can greatly improve the test efficiency and reduce the test time.
[0036] Step 103: Automatically test the interface in multiple test scenarios according to the test group and generate test results.
[0037] Optionally, the automatically testing the interface according to the test group for multiple test scenarios to generate the test results includes:
[0038] Generate a test report based on the running results of the test group;
[0039] According to the test report, determine whether the interface meets the interface test requirements.
[0040] During the test, add test scenarios to the test script of the test group, debug the changes of interface parameters in multiple scenarios, set the test sequence of the test group in multiple test scenarios according to the timestamp, run the test script, and generate a test report based on the script running results. Use the createdom(info, file) function to generate an interface test report, where info is the interface call value returned by the sendapi() method, and file is the file address for creating the test report.
[0041] In this embodiment, the test script can accurately obtain the information of the interface in the interface description document; the test script runs multiple scenarios, can generate a unified test report, and clearly indicate the results of each test case of the interface; the test script can be adjusted according to changes in the interface, and the script can be automatically executed at a scheduled time; the generated test report is accurate and standardized, which is conducive to improving the office efficiency of testers.
[0042] In some other embodiments of the present invention, the test group and the test report are stored in a database. During testing, the test group, test report and other information are stored in the test operation and maintenance library, which can be directly retrieved and used in subsequent tests without rewriting, which can greatly improve the test efficiency.
[0043] Figure 2 It is a schematic diagram of the structure of the interface testing device described in an embodiment of the present invention.
[0044] An embodiment of the present invention provides an interface testing device, including:
[0045] The capture module 11 is used to capture the interface data in the interface description document.
[0046] The writing module 12 is used to write multiple test cases according to the interface data and merge the multiple test cases into a test group.
[0047] The testing module 13 is used to automatically test the interface in multiple test scenarios according to the test group and generate test results.
[0048] Optionally, the interface data includes an interface address, interface parameters, and a scene domain name.
[0049] Optionally, the writing module 12 is further used to implement: merging the multiple test cases into the test group in the order of timestamps.
[0050] Optionally, the testing module 13 is further used to implement:
[0051] Generate a test report based on the running results of the test group;
[0052] According to the test report, determine whether the interface meets the interface test requirements.
[0053] Optionally, a storage module is also included, and the storage module is used to store the test group and the test report in a database.
[0054] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present disclosure (including the claims) is limited to these examples. Within the scope of the present invention, the above embodiments or technical features in different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the present invention as described above, which are not provided in detail for the sake of simplicity.
[0055] The embodiments of the present invention are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. An interface testing method, characterized in that: include: Capture the interface data in the interface description document, where the interface data includes the interface address, interface parameters, and scene domain name; Compile multiple test cases according to the interface data, merge the multiple test cases into a test group, and the test group includes multiple test scenarios; add test scenarios to the test script of the test group, debug the changes of interface parameters in the multiple test scenarios, and set the test order of the test group in the multiple test scenarios according to the timestamp; The interface is automatically tested for multiple test scenarios according to the test group to generate test results.
2. The method according to claim 1, characterized in that The merging of the multiple test cases into a test group includes: merging the multiple test cases into the test group in the order of timestamps.
3. The method according to claim 1, characterized in that The automatically testing the interface for multiple test scenarios according to the test group and generating the test results comprises: Generate a test report based on the running results of the test group; According to the test report, determine whether the interface meets the interface test requirements.
4. The method according to claim 3, characterized in that Also includes: The test group and the test report are stored in a database.
5. An interface testing device, characterized in that: include: A capture module, used to capture interface data in an interface description document, wherein the interface data includes an interface address, interface parameters, and a scene domain name; A writing module, used to write multiple test cases according to the interface data, merge the multiple test cases into a test group, wherein the test group includes multiple test scenarios; add test scenarios to the test script of the test group, debug the changes of interface parameters in multiple test scenarios, and set the test order of the test group in multiple test scenarios according to the timestamp; The test module is used to automatically test the interface in multiple test scenarios according to the test group and generate test results.
6. The device according to claim 5, characterized in that The writing module is also used to implement: merging the multiple test cases into the test group in the order of timestamps.
7. The device according to claim 5, characterized in that The test module is also used to implement: Generate a test report based on the running results of the test group; According to the test report, determine whether the interface meets the interface test requirements.
8. The device according to claim 7, characterized in that: It also includes a storage module, which is used to store the test group and the test report in a database.
Citation Information
Patent Citations
Automatic interface test method and device, equipment and storage medium
CN108415832A
