Automatic interface testing method and device, equipment and medium

Through the interface automated testing method, the problem of low manual testing efficiency is solved, and the rapid and accurate generation and reporting of test results are achieved to ensure that software projects are delivered on time and in quality.

CN120276975APending Publication Date: 2025-07-08AULTON NEW ENERGY AUTOMOBILE TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411916190.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2023-12-29
Filing Date
2024-12-24
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

Manual interface testing leads to inefficient testing, making it difficult to detect interface abnormalities in time, affecting the timely quality delivery of software projects.

Method used

Provides an interface automation testing method, including writing test cases based on the test environment and development environment, selecting preset operation modes (run by project, plan, suite, or use case), batch calling and running test cases through interface automation test scripts, and generating visual test reports.

Benefits of technology

Significantly shorten the testing time, improve testing efficiency, timely discover interface abnormalities, ensure that software iteration is delivered on time and with quality, and generate clear test reports for easy adjustment by R&D personnel.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120276975A_ABST
    Figure CN120276975A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an automatic interface testing method and device, equipment and a medium, belongs to the technical field of software interface testing, and is used for solving the technical problems that in a software interface testing scene, manual interface testing causes low testing efficiency, interface abnormal conditions are not easy to find, and on-time quality guarantee delivery of projects is affected. The method comprises the steps of compiling a test case based on a test environment and a development environment; selecting a preset operation mode based on the test case; wherein the preset running mode at least comprises any one of running according to a project, running according to a plan, running according to a suite and running according to a set use case; and based on the preset operation mode, performing an interface automatic test on the test case to obtain a test result.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims priority based on the invention patent application titled "An Interface Automation Testing Method and Device" with the application number 202311870400.3, which was filed with the Chinese Patent Office on December 29, 2023. This application incorporates the entire text of the above-mentioned Chinese patent application by reference. Technical Field

[0002] This specification relates to the technical field of software interface testing, and particularly to an interface automation testing method, device, equipment, and medium. Background Art

[0003] Software testing is one of the necessary steps in developing high-quality software. During the software development, upgrade, and optimization processes, stages such as unit testing, integration testing, system testing, and regression testing need to be experienced to ensure the quality of each basic component unit and each interface of the software, verify the correctness of the software functions and interfaces, and repair the discovered errors. This requires testers to write test cases to test the software.

[0004] However, currently, an enterprise often involves multiple clients such as APPs and mini-programs. Although these clients use the same set of interfaces, due to different business lines involved in different clients, the development environment, test environment, pre-release environment, and production environment are all different. If manual testing is used for interface testing, the test efficiency will be very low. For example, when the logic of a business module is modified, the original code changes involve multiple function interactions and different field displays on multiple pages. If pure manual interface testing is used, the test time may take 2 - 3 hours, and the test efficiency is very low, which is not conducive to software upgrade and transformation. Moreover, during the continuous iteration of the software, it is also very difficult to detect interface anomalies, and it is impossible to ensure that each iteration can be delivered on time and with high quality. Summary of the Invention

[0005] One or more embodiments of this specification provide an interface automation testing method, device, equipment, and medium, which are used to solve the following technical problems: In the software interface testing scenario, manual interface testing leads to low test efficiency and is not easy to detect interface anomalies, affecting the on-time and high-quality delivery of the project.

[0006] One or more embodiments of this specification adopt the following technical solutions:

[0007] On the one hand, an embodiment of this specification provides an interface automation testing method, including: writing test cases based on the test environment and the development environment;

[0008] selecting a preset operation mode based on the test cases; wherein, the preset operation mode includes at least any one of the following: running by project, running by plan, running by suite, and running by set use cases;

[0009] Based on the preset operation mode, perform interface automation testing on the test cases to obtain test results.

[0010] The present invention provides a method for implementing interface automation testing, which provides four test case operation modes. By dividing test cases into test projects, test plans, and test suites, batch calling and batch running of test cases are realized. And in order to facilitate debugging of the implementation code of a single interface during the development stage, the mode of running by use case is still retained, so that this method can not only batch run a large number of test cases according to different modes, but also quickly run single or multiple individual test cases.

[0011] In a feasible implementation manner, based on the test environment and the development environment, write test cases, specifically including:

[0012] Determine the URL addresses of the test environment and the production environment, and perform corresponding configuration on the URL addresses to install the development environment and the corresponding function libraries;

[0013] In the development environment, create a test script according to the function library; the test script encapsulates an interface test method class and an interface test class;

[0014] Run the test script, and write the test cases through the function library.

[0015] In a feasible implementation manner, the operation by project is: run all test cases of the entire project to traverse and execute all test cases in the project;

[0016] The operation by project specifically includes:

[0017] Divide different test projects in the test cases, and put the relevant test cases of each test project into the corresponding test project file;

[0018] Select a single test project or multiple specified test projects to be run according to requirements;

[0019] Read the interface protocol configuration information; wherein, the interface protocol configuration information at least includes the test server IP, port information, and protocol configuration information;

[0020] According to the interface protocol configuration information, run the test script, call the test project file to be run, and perform interface automation testing on the test cases in the test project file to be run in sequence.

[0021] In the running mode of running by project, the present invention supports batch testing according to different projects. By putting the test cases involved in the same project into the corresponding test project file, the test cases in the test project file can be automatically called and run through the interface automation test script, and the test results can be generated in batch, without manual testing one by one, which greatly facilitates the project-based software delivery in enterprises.

[0022] In a feasible implementation manner, the running by plan is: running test cases based on a predefined test plan; the test plan includes a specified set of test cases, an execution order, and a running time.

[0023] The running by plan specifically includes:

[0024] Dividing different test plans in the test cases, and putting the relevant test cases of each test plan into the corresponding test plan file.

[0025] Selecting a single test plan or multiple specified test plans to be run according to requirements.

[0026] Reading interface protocol configuration information; wherein, the interface protocol configuration information at least includes the test server IP, port information, and protocol configuration information.

[0027] According to the interface protocol configuration information, running the test script, calling the test plan file to be run, and performing interface automation testing on the test cases in the test plan file in sequence based on the execution order and running time.

[0028] In the running mode of running by plan, the present invention supports batch testing according to different plans. According to the test plan of the enterprise, putting the test cases involved in the same plan into the corresponding test plan file, the test cases in the test plan file can be automatically called and run through the interface automation test script, and the test results can be generated in batch, without manual testing one by one, and the running of each test case can be controlled according to a certain test order and running time, which greatly facilitates the plan-based software delivery in enterprises.

[0029] In a feasible implementation manner, the running by test suite is: running a specific test suite; the test suite is a set formed by combining multiple related test cases.

[0030] The running by test suite specifically includes:

[0031] Dividing different test suites in the test cases, and putting the relevant cases of each test suite in the corresponding test suite file.

[0032] Select a single test suite or multiple specified test suites to run according to requirements;

[0033] Read the interface protocol configuration information; wherein, the interface protocol configuration information at least includes the test server IP, port information and protocol configuration information;

[0034] According to the interface protocol configuration information, run the test script, call the test suite file to be run, and perform interface automation testing on the test case combinations in the test suite file to be run in sequence.

[0035] In the running mode of running by suite, the present invention supports batch testing according to different test suites. To improve the test efficiency, test cases with high correlation can be combined, and these combinations are placed in the corresponding test suite files, so that the test cases in the test suite file can be automatically called and run through the interface automation test script, and test results can be generated in batch without manual testing one by one. Running test cases with high correlation together can reduce the amplitude and frequency of parameter and code adjustment during running, and can save the test time of test cases as a whole and improve the test efficiency.

[0036] In a feasible implementation manner, the running by case is: running the specified test cases;

[0037] The running by case specifically includes:

[0038] Define different cases in the test cases, and place each case in the corresponding test case file;

[0039] Select a single case or multiple specified cases to be run according to requirements;

[0040] Read the interface protocol configuration information; wherein, the interface protocol configuration information at least includes the test server IP, port information and protocol configuration information;

[0041] According to the interface protocol configuration information, run the test script, call the test case file to be run, and perform interface automation testing on the test cases in the test case file to be run;

[0042] When running the test cases in the test case file, if the test case belongs to both the test project and the test suite at the same time, the interface protocol configuration information of the test suite is preferentially read as the interface protocol configuration information of the test case.

[0043] To facilitate debugging the implementation code of a single interface during the development stage, the running mode by case is still retained, so that this method can not only run a large number of test cases in batches according to different modes, but also quickly run a single or multiple individual test cases.

[0044] In a feasible implementation manner, based on the preset operation mode, interface automated testing is performed on the test cases to obtain test results, which specifically includes:

[0045] Based on the selected preset operation mode, the corresponding automated testing process is called, and interface automated testing is performed on the test cases according to the process to obtain interface automated testing results;

[0046] The interface automated testing results are verified through a preset verification method to obtain the test results; wherein, the preset verification method at least includes: string verification, regular verification, and key-value extraction.

[0047] The present invention provides multiple automatic verification methods for test results, which can make up for the problem of low test result accuracy caused by automatic testing, and make the test accuracy of automated testing equal to that of manual testing.

[0048] In a feasible implementation manner, after performing interface automated testing on the test cases based on the preset operation mode to obtain test results, the method further includes:

[0049] After all the test cases in the current operation mode are tested, a preset test report template is called;

[0050] The test results of each test case are displayed according to the preset test report template to generate a visual interface test report;

[0051] The visual interface test report is automatically named with a preset report file name and stored in a preset test report storage path.

[0052] Whether it is a project, a plan, or a suite, after all the test cases therein are all run, the present invention will automatically generate a test report. In the test report, it can be clearly seen which test cases have problems in the current project, plan, or suite, which is convenient for R & D personnel to adjust the corresponding modules or codes.

[0053] In a feasible implementation manner, after generating the visual interface test report, the method further includes:

[0054] Obtain email sending configuration information, including the email sender account password, one or more target email addresses, and whether to encrypt the email;

[0055] Based on the email sending configuration information, the visual interface test report is used as an email attachment and automatically sent to the one or more target email addresses.

[0056] The present invention also provides an automatic email sending function. After generating the interface test report, the system will automatically send an email to one or more responsible persons, omitting the process of data transmission between testers and developers and saving time.

[0057] On the other hand, the embodiment of the present specification also provides an interface automation testing device, including: a test case writing unit for writing test cases based on the test environment and the development environment;

[0058] a running mode selection unit for selecting a preset running mode based on the test cases; wherein the preset running mode includes at least any one of the following: running by project, running by plan, running by suite, and running by set cases;

[0059] an automation testing unit for performing interface automation testing on the test cases based on the preset running mode to obtain test results.

[0060] In a third aspect, the embodiment of the present specification also provides an electronic device, where the device includes:

[0061] 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, and the instructions are executed by the at least one processor to enable the at least one processor to execute the interface automation testing method.

[0062] Finally, the embodiment of the present specification also provides a non-volatile computer storage medium storing computer-executable instructions, and the computer realizes the interface automation testing method when executing the executable instructions.

[0063] Compared with the prior art, an interface automation testing method, device, device and medium provided by the embodiment of the present specification have the following beneficial effects:

[0064] The present invention uses an interface automation test method in the code modification iteration test involving multiple functions, pages, and interfaces, which can shorten the time required for the test by multiples, and can run the completed interface use case script in full within a few minutes, without manually testing each interface one by one, which greatly saves the test time. The python language is used to implement interface automation on the APP side, which can not only run more and more cumbersome test cases at one time, but also find interface abnormalities in time, continuously improve efficiency and system quality, and ensure that each iteration can be delivered on time with quality. In addition, the present invention also provides four test case operation modes, by dividing the test cases into test projects, test plans, and test suites, batch calling and batch running of test cases are realized. After all the test cases are fully run, the present invention automatically generates a test report, in which the test results of each test case in the current project, plan or suite can be seen at a glance, and which test case has problems can be clearly and intuitively seen, which is convenient for R&D personnel to adjust the corresponding modules or codes. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art description. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings:

[0066] Figure 1 A flow chart of an interface automation testing method provided in an embodiment of this specification;

[0067] Figure 2 A flowchart of a project-based operation mode provided for an embodiment of this specification;

[0068] Figure 3 A flowchart of a planned operation mode provided for an embodiment of this specification;

[0069] Figure 4 A flowchart of a kit operation mode provided in an embodiment of this specification;

[0070] Figure 5 A flowchart of a use case operation mode provided by an embodiment of this specification;

[0071] Figure 6 A schematic diagram of the structure of an interface automation test device provided in an embodiment of this specification;

[0072] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of this specification. Detailed implementation manners

[0073] In order to enable those skilled in the art of this technology to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on the embodiments of this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this specification.

[0074] Figure 1 It is a schematic flowchart of an interface automation testing method provided for the embodiments of this specification. As Figure 1 shown, the steps of the interface automation testing method are as follows:

[0075] S101. Write test cases based on the test environment and the development environment.

[0076] Specifically, determine the URL addresses of the test environment and the production environment, and perform corresponding configurations on the URL addresses to install the development environment and the corresponding function libraries. In the development environment, create test scripts according to the function libraries; the test scripts encapsulate an interface test method class and an interface test class. The function libraries at least include the requests library and the unittest library.

[0077] In a feasible implementation manner, the test script can be a Python script. An interface test method class is encapsulated in the Python script. As needed, each interface can correspond to a module, or multiple interfaces can correspond to a module. Each module corresponds to an interface test method class.

[0078] Furthermore, run the test script and write test cases through the function libraries. The configuration of the URL addresses is prior art well-known to those skilled in the art and will not be elaborated in this specification.

[0079] S102. Select a preset running mode based on the test cases.

[0080] The preset running modes provided by the present invention include running by project, running by plan, running by suite, and running by use case.

[0081] The mode of running by project is as follows: Run all the test cases of the entire project to traverse and execute all the test cases in the project. Specifically, it includes: dividing different test items in the test cases, and putting the relevant test cases of each test item into the corresponding test item file. Select a single test item or multiple specified test items to run according to the requirements. Read the interface protocol configuration information; among them, the interface protocol configuration information includes at least the test server IP, port information, and protocol configuration information. Then, according to the interface protocol configuration information, run the test script, call the test item file to be run, and perform interface automation testing on the test cases in the test item file to be run in sequence.

[0082] As a feasible implementation method, Figure 2 The flowchart of a mode of running by project provided by the embodiment of this specification is as Figure 2 shown. If the mode of running by project is adopted, after determining whether to run the specified project or all projects, judge whether the project is to be run according to whether the project is active. If so, read the interface protocol configuration, construct an http object, and obtain all the plans in the project (a project can contain multiple plans). Then perform interface automation testing according to the mode of running by plan. After the entire project testing is completed, automatically generate a test report and send it to the specified email.

[0083] In the mode of running by project, the present invention supports batch testing according to different projects. By putting the test cases related to the same project into the corresponding test project file, the test cases in the test project file can be automatically called and run through the interface automation test script, and the test results can be generated in batches, without manual testing one by one, which greatly facilitates software delivery mainly based on projects in enterprises.

[0084] Furthermore, the mode of running by plan is as follows: Run the test cases based on a predefined test plan; among them, the test plan includes a specified set of test cases, execution order, and running time. This mode specifically includes: dividing different test plans in the test cases, and putting the relevant test cases of each test plan into the corresponding test plan file; selecting a single test plan or multiple specified test plans to run according to the requirements; reading the interface protocol configuration information; among them, the interface protocol configuration information includes at least the test server IP, port information, and protocol configuration information. Finally, according to the interface protocol configuration information, run the test script, call the test plan file to be run, and perform interface automation testing on the test cases in the test plan file in sequence based on the execution order and running time.

[0085] As a feasible implementation method, Figure 3 The flowchart of a mode of running by plan provided by the embodiment of this specification is asFigure 3 As shown, if the running mode of running according to the plan is adopted, it is judged whether the plan is to be run according to the existence and activity of the plan. If so, the interface protocol configuration is read, an http object is constructed, and all test cases in the plan are obtained. Then, the test cases to be run are tested. When running to a certain test case, if it is found that the case has been disabled or the case is a global initialization case, the case is skipped and the next test case is continued to be run. When running the test cases, the steps to be run in the test cases are run in sequence, and the execution result of each step is recorded. After all the steps to be run are executed, the case execution result is recorded, and the test cases to be run are continued to be searched in the test case management system Testlink, and the loop is entered. After the entire plan is tested, a test report is automatically generated and automatically sent to the specified email address.

[0086] In the running mode of running according to the plan, the present invention supports batch testing according to different plans. According to the test plan of the enterprise, the test cases involved in the same plan are put into the corresponding test plan file, and then the test cases in the test plan file can be automatically called and run through the interface automation test script, and the test results are generated in batches without manual testing one by one, and the running of each test case can be controlled according to a certain test order and running time, which greatly facilitates the software delivery mainly based on the plan in the enterprise.

[0087] Furthermore, the mode of running according to the suite is: running a specific test suite; the test suite is a set that combines multiple related test cases. This mode specifically includes: dividing different test suites in the test cases, putting the related cases of each test suite in the corresponding test suite file; selecting a single test suite or multiple specified test suites to run according to the requirements. Reading the interface protocol configuration information; wherein, the interface protocol configuration information at least includes the test server IP, port information and protocol configuration information. Finally, according to the interface protocol configuration information, the test script is run, the test suite file to be run is called, and the interface automation test is sequentially performed on the test case combinations in the test suite file to be run.

[0088] As a feasible implementation manner, Figure 4 is a flowchart of a mode of running according to the suite provided by the embodiment of the present specification, as Figure 4As shown in the figure, if the running mode of running by suite is adopted, first, according to the existence of the suite, it is judged whether the suite is to be run. If so, the interface protocol configuration is read, an http object is constructed, and all test cases in the suite are obtained. Then, the test cases to be run are tested. If, when running to a certain test case, it is found that the case has been disabled or the case is a global initialization case, then this case is skipped and the next test case is continued to be run. When running the test cases, the steps to be run in the test cases are run in sequence, and the execution result of each step is recorded. After all the steps to be run are executed, the execution result of the case is recorded, and the test cases to be run are continued to be run, entering a loop. After the entire plan is tested, a test report is automatically generated and automatically sent to the specified email address.

[0089] In the running mode of running by suite, the present invention supports batch testing according to different test suites. To improve the test efficiency, test cases with high relevance can be combined, and these combinations are placed in the corresponding test suite files. Then, the test cases in the test suite files can be automatically called and run through the interface automation test script, and test results can be generated in batches without manual testing one by one. Running test cases with high relevance concentrated can reduce the range and frequency of parameter and code adjustment during running, and can save the test time of test cases as a whole and improve the test efficiency.

[0090] Further, running by case means running the specified test cases. Specifically, it includes: defining different cases in the test cases, and placing each case in the corresponding test case file; selecting a single case or multiple specified cases to be run according to the requirements; reading the interface protocol configuration information; where the interface protocol configuration information at least includes the test server IP, port information, and protocol configuration information; according to the interface protocol configuration information, running the test script, calling the test case file to be run, and performing interface automation testing on the test cases in the test case file to be run.

[0091] When running the test cases in the test case file, if the test case belongs to both the test project and the test suite at the same time, the interface protocol configuration information of the test suite is preferentially read as the interface protocol configuration information of the test case.

[0092] As a feasible implementation manner, Figure 5 This is a flowchart of a running mode by case provided by the embodiment of this specification. As Figure 5 shown, if it is necessary to run the specified test cases, the running mode of running by project is adopted. First, it is judged whether the test case exists. If so, a case object is constructed, the interface protocol configuration is read, an http object is constructed, and then the test case is run through the interface automation script. After the test is completed, a test report is automatically generated and automatically sent to the specified email address.

[0093] To facilitate debugging the implementation code of a single interface during the development stage, the mode of running by test cases is still retained, enabling this method to not only batch run a large number of test cases according to different modes but also quickly run single or multiple individual test cases.

[0094] S103. Based on a preset running mode, perform interface automation testing on the test cases to obtain a test result.

[0095] Specifically, based on the selected preset running mode, call the corresponding automation testing process, and perform interface automation testing on the test cases according to the process to obtain an interface automation test result.

[0096] Furthermore, verify the interface automation test result through a preset verification method to obtain a test result; wherein, the preset verification method at least includes: string verification, regular verification, and key-value extraction. The present invention provides multiple automatic verification methods for test results, which can make up for the problem of low test result accuracy caused by automatic testing, and make the test accuracy of automatic testing equal to that of manual testing.

[0097] As a feasible implementation manner, the present invention supports HTTPS and HTTP protocols, supports POST and GET methods, supports requests in JSON and non-JSON data formats, and supports various forms of data verification. And it supports graphical operation, and the following operations can be implemented without writing code:

[0098] a) Customize variables to store the request / query results returned by the app server and the database server.

[0099] b) Automatically verify the results returned by the app server according to a custom mode, support verification in multiple modes, including string, non-string, key-value extraction, member inclusion, member exclusion, matching / mismatching regular expressions, fully matching lists / tuples / sets / dictionaries, etc.

[0100] c) Execute sql query / update operations according to the sql statements input in the interface. For sql queries that only return a single record, it also supports extracting and saving the query results.

[0101] d) Support dynamic parameterization of urls and parameter bodies, support global dynamic parameters and non-global dynamic parameters (such as custom variables storing the return results of a certain interface).

[0102] Further, after all the test cases in the current running mode have been tested, a preset test report template is called. The test results of each test case are displayed according to the preset test report template to generate a visual interface test report. The visual interface test report is automatically named with the preset report file name and stored in the preset test report storage path.

[0103] Whether it is a project, a plan, or a suite, after all the test cases therein have been run, the present invention will automatically generate a test report. In the test report, it is possible to clearly see the test results of each test case in the current project, plan, or suite, and which test case has a problem can be clearly and intuitively seen, facilitating developers to adjust the corresponding modules or codes.

[0104] Further, after generating the HTML visual interface test report, email sending configuration information is obtained, including the email sender account password, one or more target email addresses, and whether to encrypt the email. Based on the email sending configuration information, the visual interface test report is used as an email attachment and automatically sent to one or more target email addresses. The automatic email sending function provided by the present invention will automatically send an email to one or more responsible persons after generating the interface test report, omitting the process of data transmission between testers and developers, and saving communication and data transmission time in the R & D process.

[0105] As a feasible implementation manner, the interface automation testing method provided by the present invention also supports logging printing to files and consoles. It can automatically print a log file of a preset size in the path where the log file is located.

[0106] Further, the embodiments of the present specification also provide an interface automation testing device, as Figure 6 described, the interface automation testing device 600 includes:

[0107] A test case writing unit 610 for writing test cases based on the test environment and the development environment;

[0108] A running mode selection unit 620 for selecting a preset running mode based on the test cases; wherein, the preset running mode includes at least any one of the following: running by project, running by plan, running by suite, and running by set cases;

[0109] An automated testing unit 630 for performing interface automated testing on the test cases based on the preset running mode to obtain test results.

[0110] Further, the embodiments of the present specification also provide an electronic device, as Figure 7As shown, the device includes: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the interface automation testing method in any of the above embodiments. For example, in one embodiment, the processor can execute:

[0111] Write test cases based on the test environment and development environment; select a preset running mode based on the test cases; wherein the preset running modes include at least one of the following: running by project, running by plan, running by suite, and running by set cases; perform interface automation testing on the test cases based on the preset running mode to obtain test results.

[0112] Finally, an embodiment of this specification also provides a non-volatile computer storage medium storing computer executable instructions. When the computer executes the executable instructions, the interface automation testing method in any of the above embodiments is implemented. For example, in one embodiment, the above computer executable instructions can implement:

[0113] Write test cases based on the test environment and development environment; select a preset running mode based on the test cases; wherein the preset running modes include at least one of the following: running by project, running by plan, running by suite, and running by set cases; perform interface automation testing on the test cases based on the preset running mode to obtain test results.

[0114] The present invention uses an interface automation test method in the code modification iteration test involving multiple functions, pages, and interfaces, which can shorten the time required for the test by multiples, and can run the completed interface use case script in full within a few minutes, without manually testing each interface one by one, which greatly saves the test time. The python language is used to implement interface automation on the APP side, which can not only run more and more cumbersome test cases at one time, but also find interface abnormalities in time, continuously improve efficiency and system quality, and ensure that each iteration can be delivered on time with quality. In addition, the present invention also provides four test case operation modes, by dividing the test cases into test projects, test plans, and test suites, batch calling and batch running of test cases are realized. After all the test cases are fully run, the present invention automatically generates a test report, in which the test results of each test case in the current project, plan or suite can be seen at a glance, and which test case has problems can be clearly and intuitively seen, which is convenient for R&D personnel to adjust the corresponding modules or codes.

[0115] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other, and the key point of each embodiment is to illustrate the differences from other embodiments. In particular, for the embodiments of apparatuses, devices, and non-volatile computer storage media, since they are basically similar to the method embodiments, the description is relatively simple, and reference can be made to the relevant parts of the method embodiments for the relevant content.

[0116] The specific embodiments of this specification are described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the figures do not necessarily require the particular order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0117] The above description is only for one or more embodiments of this specification and is not intended to limit this specification. For those skilled in the art, various modifications and changes can be made to one or more embodiments of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of this specification shall be included within the scope of the claims of this specification.

Claims

1. An interface automation testing method, characterized in that, The method includes: Writing test cases based on the test environment and the development environment; Selecting a preset running mode based on the test cases; wherein, the preset running mode includes at least any one of the following: running by project, running by plan, running by suite, and running by set cases; Performing interface automation testing on the test cases based on the preset running mode to obtain test results.

2. The interface automation testing method according to claim 1, wherein Writing test cases based on the test environment and the development environment, specifically including: Determining the URL addresses of the test environment and the production environment, and performing corresponding configurations on the URL addresses to install the development environment and the corresponding function libraries; In the development environment, creating test scripts according to the function libraries; the test scripts encapsulate an interface test method class and an interface test class; Running the test scripts and writing the test cases through the function libraries.

3. An interface automation testing method according to claim 1, characterized in that, The running by project is: running all the test cases of the entire project to traverse and execute all the test cases in the project; The running by project specifically includes: Dividing different test projects in the test cases, and putting the relevant test cases of each test project into the corresponding test project files; Selecting a single test project or multiple specified test projects to be run according to requirements; Reading interface protocol configuration information; wherein, the interface protocol configuration information includes at least the test server IP, port information, and protocol configuration information; According to the interface protocol configuration information, running the test scripts, calling the test project files to be run, and performing interface automation testing on the test cases in the test project files to be run in sequence.

4. An interface automation testing method according to claim 1, wherein The running by plan is: running test cases based on a predefined test plan; the test plan includes a specified set of test cases, an execution order, and a running time; The running by plan specifically includes: Dividing different test plans in the test cases, and putting the relevant test cases of each test plan into the corresponding test plan files; Selecting a single test plan or multiple specified test plans to be run according to requirements; Reading interface protocol configuration information; wherein, the interface protocol configuration information includes at least the test server IP, port information, and protocol configuration information; According to the interface protocol configuration information, running the test scripts, calling the test plan files to be run, and performing interface automation testing on the test cases in the test plan files in sequence based on the execution order and the running time.

5. An interface automation testing method according to claim 1, characterized in that, The running by suite is: running a specific test suite; The test suite is a set formed by combining multiple relevant test cases; The running by test suite specifically includes: Dividing different test suites in the test cases, and putting the relevant cases of each test suite into the corresponding test suite files; Selecting a single test suite or multiple specified test suites to be run according to requirements; Reading interface protocol configuration information; wherein, the interface protocol configuration information includes at least the test server IP, port information, and protocol configuration information; Run the test script according to the interface protocol configuration information, call the test suite file to be run, and perform interface automation testing on the test case combinations in the test suite file to be run in sequence.

6. An interface automation testing method according to claim 1, characterized in that, The running by case is: running the specified test case; The running by case specifically includes: Define different cases in the test cases, and place each case in the corresponding test case file; Select a single case or multiple specified cases to be run according to requirements; Read the interface protocol configuration information; wherein, the interface protocol configuration information at least includes the test server IP, port information, and protocol configuration information; According to the interface protocol configuration information, run the test script, call the test case file to be run, and perform interface automation testing on the test cases in the test case file to be run; When running the test cases in the test case file, if the test case belongs to both the test project and the test suite at the same time, preferentially read the interface protocol configuration information of the test suite as the interface protocol configuration information of the test case.

7. An interface automation testing method according to claim 1, characterized in that Based on the preset running mode, perform interface automation testing on the test cases to obtain test results, specifically including: Based on the selected preset running mode, call the corresponding automated test process, and perform interface automation testing on the test cases according to the process to obtain the interface automation test results; Verify the interface automation test results through a preset verification method to obtain the test results; wherein, the preset verification method at least includes: string verification, regular verification, and key-value extraction.

8. An interface automation testing method according to claim 1, wherein After performing interface automation testing on the test cases based on the preset running mode to obtain test results, the method further includes: After all the test cases in the current running mode are tested, call a preset test report template; Display the test results of each test case according to the preset test report template to generate a visual interface test report; Automatically name the visual interface test report as the preset report file name and store it in the preset test report storage path.

9. An interface automation testing method according to claim 8, wherein After generating the visual interface test report, the method further includes: Obtain the email sending configuration information, including the email sender account password, one or more target email addresses, and whether to encrypt the email; Based on the email sending configuration information, send the visual interface test report as an email attachment to the one or more target email addresses automatically.

10. An interface automated test device, characterized in that, The device includes: A test case writing unit for writing test cases based on the test environment and the development environment; A running mode selection unit for selecting a preset running mode based on the test cases; wherein, the preset running mode at least includes any one of the following: running by project, running by plan, running by suite, and running by specified case; An automated test unit for performing interface automation testing on the test cases based on the preset running mode to obtain test results.

11. An electronic device, characterized in that, The device includes: 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, and the instructions are executed by the at least one processor to enable the at least one processor to execute the interface automation testing method according to any one of claims 1-9.

12. A non-volatile computer storage medium stores computer-executable instructions, characterized in that, When the computer executes the executable instructions, it implements an interface automation testing method according to any one of claims 1-9.

Citation Information

Cited By

  • Automated resource allocation and dependency tracing for testing lane generation

    US20260044440A1