Interface testing method and device, electronic equipment and storage medium

By automating the search and adaptation of processor type information, the high learning cost and poor versatility of interface testing in existing technologies are solved, realizing an efficient and flexible interface testing method.

CN116048949BActive Publication Date: 2026-03-20QINGDAO HAIER TECH +1
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-28
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

In existing technologies, testing interfaces requires manually writing and modifying JMeter scripts, resulting in high learning costs, poor test versatility, and high testing costs, failing to achieve automation and universality.

Method used

By automatically finding the processor type information based on the identification information of the interface to be tested, adapting the corresponding processor for pre-processing, and automatically generating test request information, the automation and universality of interface testing are achieved.

Benefits of technology

It improves the automation and versatility of interface testing, reduces the cost of manual script modification, supports pre-processing of different interfaces, is compatible with different testing needs, and has high testing efficiency and good flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116048949B_ABST
    Figure CN116048949B_ABST
Patent Text Reader

Abstract

The application provides an interface test method and device, electronic equipment and a storage medium, the method comprising: according to the identification information of the interface to be tested, searching the interface configuration information of the interface to be tested in the database constructed in advance; according to the processor type information, adapting the processor corresponding to the processor type information for the processor to process the pre-task of the interface to be tested; receiving the processing result returned by the processor, generating the test request information of the interface to be tested according to the processing result; testing the interface to be tested according to the test request information, and obtaining the actual test result of the interface to be tested. The application realizes automatic adaptation of the processor according to the interface configuration information of the interface to be tested, tests the interface to be tested after pre-task processing, has high automation degree and test efficiency, and has good versatility and flexibility.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of automation testing, and in particular to an interface testing method and device, electronic equipment and a storage medium. BACKGROUND

[0002] With the widespread use of computer software in all industries, software quality is gradually valued by users, and software testing as the front end of software quality assurance becomes more important. Therefore, in order to ensure service quality, HTTP (Hypertext Transfer Protocol) service interface needs to be tested.

[0003] At present, when testing the interface, a third-party testing tool such as Postman and Soupui is usually used. When using such a testing tool to test the interface, the parameters and paths need to be input into the third-party testing tool to test the interface. However, in order to ensure the security of the system, security processing such as anti-replay or signature verification needs to be performed before testing the interface. Directly using a third-party testing tool cannot achieve security processing such as anti-replay or signature verification. If the security processing task cannot be completed before calling the interface, the interface cannot be called, and the interface cannot be tested.

[0004] In order to solve the above problems, the prior art relies on the development personnel to write Jmeter scripts to achieve security processing such as anti-replay or signature verification of the test interface, and then uses a third-party testing tool to test the interface. The writing of Jmeter scripts requires the development personnel to have a good computer foundation, and the learning cost is high. Moreover, the Jmeter script needs to be modified each time the interface is tested to adapt to the current interface test, resulting in poor test versatility. SUMMARY

[0005] The present application provides an interface testing method, device, electronic equipment and storage medium, which solves the defects of high learning cost, poor test versatility and high test cost in the prior art when testing an interface that needs to be processed specially, and improves the automation and versatility of testing the interface.

[0006] The present application provides an interface testing method, comprising:

[0007] According to the identification information of the interface to be tested, the processor type information corresponding to the interface to be tested is found.

[0008] determine a processor corresponding to the processor type information, and perform a pre-processing task on the interface to be tested by the processor; the pre-processing task is a task to be processed before testing the interface to be tested;

[0009] receive a processing result returned by the processor, and generate test request information of the interface to be tested according to the processing result;

[0010] test the interface to be tested according to the test request information, and obtain an actual test result of the interface to be tested.

[0011] According to the interface test method provided by the application, the method further comprises:

[0012] According to the identification information of the interface to be tested, the reference test result of the interface to be tested is searched;

[0013] The actual test result is matched with the reference test result;

[0014] In the case that the matching result is that the actual test result and the reference test result are different, it is determined that the test of the interface to be tested fails;

[0015] In the case that the matching result is that the actual test result and the reference test result are the same, it is determined that the test of the interface to be tested succeeds.

[0016] According to the interface test method provided by the application, the method further comprises:

[0017] In the case that it is determined that the test of the interface to be tested fails, it is judged whether the number of continuous test failures of the interface to be tested is greater than a preset value;

[0018] In the case that the number is greater than the preset value, alarm information is sent to a terminal.

[0019] According to the interface test method provided by the application, the method further comprises:

[0020] In the case that the number is greater than the preset value, according to the identification information of a service to which the interface to be tested belongs, configuration information of the service to which the interface to be tested belongs is searched;

[0021] And / or, according to the identification information of a service corresponding to the service, configuration information of the service corresponding to the service is searched;

[0022] According to the identification information of the service, configuration information of a user corresponding to the service is searched;

[0023] According to the configuration information of the service and / or the configuration information of the business, the interface to be tested is located, and the locating result is sent to the user according to the configuration information of the user.

[0024] According to the interface testing method provided by the application, the method further comprises:

[0025] In the case that it is determined that the test on the interface to be tested is successful, it is inquired whether there is a historical alarm of the interface to be tested;

[0026] In the case that there is the historical alarm, the historical alarm is eliminated, and the user is informed that the historical alarm has been recovered.

[0027] According to the interface testing method provided by the application, the method further comprises:

[0028] According to the identification information of the interface to be tested, matching information in interface configuration information of the interface to be tested is found;

[0029] According to the test request information, the business logic in the matching information is executed, and the reference test result is acquired; or,

[0030] According to the test request information, the reference test result is found and acquired in the matching information.

[0031] According to the interface testing method provided by the application, the method further comprises:

[0032] The target task is received at a preset frequency; wherein the target task is formed according to one or more same category interfaces to be tested;

[0033] The identification information of each interface to be tested in the target task is received in batches.

[0034] The application further provides an interface testing device, comprising:

[0035] A finding module is configured to find processor type information corresponding to an interface to be tested according to identification information of the interface to be tested;

[0036] A processing module is configured to determine a processor corresponding to the processor type information, and configured to process a pre-task of the interface to be tested by the processor; wherein the pre-task is a to-be-processed task before the interface to be tested is tested;

[0037] A generating module is configured to receive a processing result returned by the processor, and configured to generate test request information of the interface to be tested according to the processing result;

[0038] A test module is configured to test the interface to be tested according to the test request information, and obtain an actual test result of the interface to be tested.

[0039] The application further provides an electronic device, 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 interface test method according to any one of the above when executing the program.

[0040] The application further provides a non-transitory computer readable storage medium, which stores a computer program, wherein the computer program is executable on a processor to implement the steps of the interface test method according to any one of the above.

[0041] The application further provides a computer program product, which includes a computer program, wherein the computer program is executable on a processor to implement the steps of the interface test method according to any one of the above.

[0042] The interface test method, device, electronic device and storage medium provided by the application can automatically find and obtain the interface configuration information of the interface to be tested in the database according to the identification information of the interface to be tested, then automatically adapt the corresponding processor according to the processor type information in the interface configuration information, automatically process the pre-task of the interface to be tested through the adapted processor, and automatically generate the test request information according to the processing result returned by the processor, so that the interface to be tested can be called and tested according to the test request information. The whole test process is automatically completed, the test efficiency is high, the manual cost and learning cost caused by manual modification of scripts at each test can be effectively avoided, different pre-tasks of different interfaces can be processed and tested by configuring different configuration information for different interfaces to be tested, the test of different interfaces to be tested with different requirements can be compatible, the versatility is good, and the configuration file can be modified according to actual requirements, so the flexibility is good. BRIEF DESCRIPTION OF DRAWINGS

[0043] In order to more clearly illustrate the technical solutions of the present application or prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor.

[0044] Figure 1 is a flowchart of the interface test method provided by the application;

[0045] Figure 2 is a structure diagram of the database in the interface test method provided by the application;

[0046] Figure 3is a structural schematic diagram of a test execution process in an interface test method provided by the application;

[0047] Figure 4 is a structural schematic diagram of an interface test device provided by the application;

[0048] Figure 5 is a structural schematic diagram of an electronic device provided by the application. DETAILED DESCRIPTION

[0049] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0050] The present application will be described below with reference to the drawings. Figure 1 An interface test method provided by the present application is described below, which can be applied to electronic devices such as mobile phones, tablet computers and desktop computers. The interface test method in the present embodiment can be implemented by using JAVA language or C language, and supports the configuration of software interfaces such as HTTP (Hyper Text Transfer Protocol, HyperText Transfer Protocol). The interface test method includes the following steps:

[0051] In step 101, the processor type information corresponding to the to-be-tested interface is found according to the identification information of the to-be-tested interface.

[0052] The execution subject in the present embodiment can be an executor such as a computer.

[0053] The to-be-tested interface is a software interface that needs to be tested, which can be an HTTP service interface, etc. The present embodiment does not make specific limitation on this.

[0054] The identification information of the to-be-tested interface can be a number or an ID (Identity Document, identity), etc. The present embodiment does not make specific limitation on this. Each to-be-tested interface has unique identification information.

[0055] The pre-constructed database stores interface configuration information of a plurality of interfaces. The interface configuration information includes, but is not limited to, an ID of the interface, a service ID, an interface name, an interface URL (Uniform Resource Locator), a request header, a request parameter, a request method, an expected matching value, a matching type, a pre-processor type, a maximum time consumption, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0056] As shown in Figure 2 The pre-constructed database also stores service configuration information, service-user mapping relationship, alarm user configuration information, service configuration information, interface alarm record, environment configuration information, interface call record, task-interface mapping relationship, and task configuration information, which are not specifically limited in the embodiment.

[0057] The above configuration and mapping relationship can be stored in the database in the form of a table, which is not specifically limited in the embodiment.

[0058] The service configuration information includes, but is not limited to, a service ID, a business ID, a service name, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0059] The service-user mapping relationship includes, but is not limited to, a main chain, a service ID, a user ID, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0060] The alarm user configuration information includes, but is not limited to, a main chain, a user name, a mobile phone number, an email, an enterprise WeChat, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0061] The service configuration information includes, but is not limited to, a service ID, a business ID, a service name, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0062] The interface alarm record includes, but is not limited to, an alarm ID, an exception ID, a service ID, an alarm user ID set, an alarm content, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0063] The environment configuration information includes, but is not limited to, an environment ID, an environment code, an environment name, a URL prefix, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0064] The interface call record includes but is not limited to a main chain, a service ID, a task ID, an interface ID, an exception ID, a batch, an interface name, a request URL, a request header, a request parameter, a request method, an expected matching value, a matching type, a processor type, a maximum time consumption, a test return result, a state, an interface time consumption, a creation time, a creator, a modification time, and a modifier, etc., and the embodiment is not specifically limited thereto.

[0065] The task and interface mapping relationship includes but is not limited to a main chain, a task ID, an interface ID, a state, a note, a creation time, a creator, a modification time, and a modifier, etc., and the embodiment is not specifically limited thereto.

[0066] The task configuration information includes but is not limited to a task ID, an environment ID, a task name, a Corn expression, a task UUID (Universally Unique Identifier), a state, a note, a creation time, and a creator, etc., and the embodiment is not specifically limited thereto.

[0067] The interface configuration information, the business configuration information, the service and user mapping relationship, the alarm user configuration information, the service configuration information, the environment configuration information, the task and interface mapping relationship, and the task configuration information can be updated according to actual needs. The updating includes but is not limited to adding, deleting, or modifying.

[0068] Optionally, when the to-be-tested interface needs to be tested, the executor acquires the identification information of the to-be-tested interface; then, the interface configuration information containing the identification information is searched in the database; and then, the processor type information is searched in the interface configuration information.

[0069] Each identification information corresponds to unique interface configuration information, and the interface configuration information contains corresponding processor type information.

[0070] Step 102, determining a processor corresponding to the processor type information, for processing a pre-task of the to-be-tested interface by the processor; wherein the pre-task is a to-be-processed task before the to-be-tested interface is tested.

[0071] The processor can be divided into multiple types according to the functions implemented by the processor; the types of the processor include but are not limited to processors for processing replay, signature verification, and Token type tasks; and correspondingly, the target task includes but is not limited to tasks of the replay, signature verification, and Token types.

[0072] The processor type information can be represented by a number, such as when the processor type information is empty or 0, indicating no pending task before testing the interface to be tested; when the processor type information is 1, indicating that the pending task before testing the interface to be tested is a replay task; when the processor type information is 2, indicating that the pending task before testing the interface to be tested is a signature verification task; and when the processor type information is 3, indicating that the pending task before testing the interface to be tested is a Token task.

[0073] Since the interface provided by the background to the foreground usually increases the anti-replay processing, the interface interaction between systems usually needs to be verified; therefore, anti-replay or signature verification processing is required before calling the interface.

[0074] Optionally, after obtaining the interface configuration information of the interface to be tested, it is determined whether the interface to be tested is in a normal running state according to the state in the interface configuration information.

[0075] If the interface to be tested is in a normal running state, the processor type information corresponding to the interface to be tested is obtained from the interface configuration information, and a processor corresponding to the processor type information is adapted according to the processor type information; when the corresponding processor is adapted, the target task of the interface to be tested is sent to the processor, so that the processor processes the target task, and the processing result is returned to the executor.

[0076] If the interface to be tested is in an abnormal running state, it is prompted that the interface to be tested is in an abnormal running state and cannot be tested.

[0077] In the prior art, a dial test system is formulated to process the pending task before testing the interface to be tested; wherein the processing scheme of the dial test system is to directly execute a Jmeter script with a fixed frequency, and script code is written in the Jmeter script to execute target tasks and interface response processing. However, the dial test system has weak functions and does not perceive the interface test process, mainly relying on the Jmeter script provided by the developer. Therefore, the developer needs to be familiar with Jmeter, which requires a lot of learning time, and the interface test relies on Jmeter, which needs to be changed every time the interface is tested, and the usability is not high and additional time is required.

[0078] The embodiment only needs to automatically acquire the processor type information in the interface configuration information of the interface to be tested according to the identification information of the interface to be tested, automatically adapt to the corresponding processor, and execute the corresponding target task, which is not only suitable for testing of ordinary interfaces, but also suitable for testing of interfaces with special target tasks before testing, is simple to operate, has strong applicability, can effectively reduce code overhead caused by code writing, and can support multiple types of processors at the same time. During the interface testing stage, the system calls the corresponding processor for processing according to the configuration, and the user does not need to perceive the process.

[0079] In step 103, the processing result returned by the processor is received, and the test request information of the interface to be tested is generated according to the processing result.

[0080] Optionally, the processing result returned by the processor is received, and the processing result is fused into the request header and the request body in the interface configuration information to form the test request information of the interface to be tested, that is, the request information contains the request parameter and the request address, and also contains the processing result.

[0081] For example, the processing result returned by the processor is a signature verification result, that is, a signature.

[0082] In step 104, the interface to be tested is tested according to the test request information, and an actual test result of the interface to be tested is acquired.

[0083] Optionally, after the request information is acquired, a communication link between the interface to be tested and the executor is established according to the request address in the test request information, the request parameter is sent to the interface to be tested through the communication link, the interface to be tested is called to execute the request parameter, and the actual test result is acquired.

[0084] It should be noted that when the interface to be tested is called for testing, the calling record needs to be recorded in real time, that is, the interface calling record of the interface to be tested is generated.

[0085] The actual test result can be directly returned by the interface to be tested, or can be acquired by querying the interface calling record, and the embodiment is not limited in this regard.

[0086] The data format of the actual test result can be a JSON (JavaScript Object Notation, lightweight data exchange format) format, and the embodiment is not limited in this regard.

[0087] The embodiment automatically acquires interface configuration information of the interface to be tested in the database according to the identification information of the interface to be tested; then, automatically adapts a corresponding processor according to processor type information in the interface configuration information, automatically processes the pre-task of the interface to be tested through the adapted processor, and automatically generates test request information according to a processing result returned by the processor, so that the interface to be tested can be called according to the test request information to perform testing; the entire testing process is automatically completed, the testing efficiency is high, the manual cost and learning cost caused by manual modification of scripts at each time of testing are effectively avoided; and different configuration information is configured for different interfaces to be tested, so that different pre-tasks of different interfaces can be processed and tested, the testing of different interfaces to be tested with different requirements can be compatible, and the versatility is good; and the configuration file can be modified according to actual requirements, and the flexibility is good.

[0088] On the basis of the above embodiment, the embodiment further includes: finding a reference test result of the interface to be tested according to identification information of the interface to be tested; matching the actual test result with the reference test result; in a case where the matching result is that the actual test result and the reference test result are different, determining that the testing of the interface to be tested fails; and in a case where the matching result is that the actual test result and the reference test result are the same, determining that the testing of the interface to be tested succeeds.

[0089] Optionally, after the actual test result is acquired, a reference test result of the interface to be tested can be acquired according to matching information in the interface configuration information; the reference test result is an expected return test result of the interface to be tested.

[0090] Optionally, in a case where the expected return test result exists in the matching information, the expected return test result is directly taken as the reference test result; in a case where a matching rule exists in the matching information, the test request information is matched and calculated according to the matching rule to obtain the reference test result; the embodiment is not limited in this regard.

[0091] After the reference test result is acquired, the actual test result and the reference test result are matched through a result matcher to determine whether the actual test result and the reference test result match.

[0092] In a case where the actual test result and the reference test result match, that is, the actual test result and the reference test result are the same, it is determined that the testing of the interface to be tested succeeds, and an identification of testing success is generated.

[0093] In a case where the actual test result and the reference test result do not match, i.e., the actual test result and the reference test result are not the same, it is determined that the test on the interface to be tested fails, an identification of test failure is generated, and the interface call exception record is updated according to the relevant parameters generated during the test on the interface to be tested, such as increasing the number of consecutive failures in the interface call exception record by 1.

[0094] In addition, the alarm trigger can be called according to the identification of test success or the identification of test failure to determine whether to alarm.

[0095] The test success or test failure result can be fed back to the user to enable the user to obtain the test situation of the interface to be tested in real time.

[0096] In summary, the interface test method provided in the embodiment can automatically obtain the reference test result expected to be returned by the interface to be tested through the matching information in the interface configuration information, and compare the actual test result with the reference test result to determine whether the test result of the interface to be tested is successful. Compared with the manual comparison of test results in the prior art, the test efficiency is improved, human error is avoided, and the accuracy of the test result is improved.

[0097] On the basis of the above embodiment, the embodiment further includes: in a case where it is determined that the test on the interface to be tested fails, determining whether the number of continuous test failures of the interface to be tested is greater than a preset value; and in a case where the number is greater than the preset value, sending alarm information to a terminal.

[0098] The preset value can be set according to actual needs, such as 3 times, which is not limited in the embodiment.

[0099] The terminal can be a computer, a smart wearable device, a mobile phone, or the like.

[0100] Since the instantaneous abnormal situation or abnormal interference can cause the interface to be tested to be in an instantaneous abnormal state, but the interface to be tested returns to normal in a short time. This abnormal state is instantaneous abnormality, and the influence on the system is small and can be ignored.

[0101] Therefore, in order to filter the occurrence of the instantaneous abnormal state and accurately obtain the continuous abnormal state of the interface to be tested, i.e., in a case where a real fault occurs, alarm information is sent. In the embodiment, in a case where it is determined that the test on the interface to be tested fails, the number of continuous abnormalities of the interface to be tested is updated in the form of cumulative addition by 1; then, it is determined whether the updated number of continuous abnormalities is greater than a preset value, and in a case where the number is greater than the preset value, it is indicated that the interface to be tested has a real fault. Through this method, the influence of the instantaneous abnormal situation or abnormal interference on the judgment result of whether the interface to be tested has a real fault can be effectively alleviated.

[0102] In the case of judging that the to-be-tested interface actually fails, an alarm information is sent to the terminal to prompt the user that the to-be-tested interface fails, so that the user can maintain the to-be-tested interface in time.

[0103] And the interface alarm record and the interface calling exception record are updated.

[0104] The alarm information can include, but is not limited to, being sent to the terminal in the form of voice or text.

[0105] The content of the alarm information includes, but is not limited to, the interface configuration information of the to-be-tested interface, the test result, the interface calling record, the interface alarm record and the interface calling exception record, etc.

[0106] The embodiment can flexibly customize the condition of judging whether the to-be-tested interface actually fails according to actual needs, and can effectively avoid the influence of transient exceptions on the test result judgment, has strong anti-interference ability, stable output, and high accuracy of test result judgment. In addition, the alarm information can be sent to the terminal in time to assist the user to find the fault root cause in time according to the alarm information and maintain in time.

[0107] On the basis of the above embodiment, the embodiment further includes: in the case that the number of times is greater than the preset value, according to the identification information of the service to which the to-be-tested interface belongs, the configuration information of the service to which the to-be-tested interface belongs is found; and / or, according to the identification information of the business corresponding to the service, the configuration information of the business corresponding to the service is found; according to the identification information of the service, the configuration information of the user corresponding to the service is found; according to the configuration information of the service and / or the configuration information of the business, the to-be-tested interface is positioned, and the positioning result is sent to the user according to the configuration information of the user.

[0108] Optionally, in the case that the number of continuous abnormal times of the to-be-tested interface is greater than the preset value, the to-be-tested interface can be positioned according to the configuration information related to the to-be-tested interface in the database, so that the user can maintain the to-be-tested interface in time according to the positioning.

[0109] The interface configuration information, the interface alarm record, the interface calling exception record and the interface calling record all pre-store the association relationship between the to-be-tested interface and the service identification information;

[0110] Optionally, the identification information of the service to which the to-be-tested interface belongs can be found in the interface configuration information, the interface alarm record, the interface calling exception record or the interface calling record;

[0111] According to the identification information of the service, the configuration information of the service to which the to-be-tested interface belongs is found in the database;

[0112] obtain the identification information of the service corresponding to the business from the service configuration information, and find the configuration information of the service corresponding to the business in the database according to the identification information of the service corresponding to the business;

[0113] find the identification information of the user corresponding to the service identification information in the user-service mapping relationship of the database, and find the configuration information of the user corresponding to the service in the database according to the identification information of the user;

[0114] position the interface to be tested according to the configuration information of the service and / or the configuration information of the business, and accurately send the positioning result to the corresponding user according to the configuration information of the user, so that the user can maintain the interface to be tested in time according to the positioning information.

[0115] In addition, the identification information of the task can also be found in the task interface mapping relationship according to the identification information of the interface to be tested, and the configuration information of the task corresponding to the interface to be tested can be found in the task configuration information according to the identification information of the task.

[0116] find the configuration information of the environment in which the interface to be tested is located in the environment configuration information according to the identification information of the environment in which the task is located in the configuration information of the task;

[0117] position the interface to be tested according to one or more of the configuration information of the service, the configuration information of the business, the configuration information of the task and the configuration information of the environment, and accurately send the positioning result to the corresponding user, so that the user can maintain the interface to be tested in time according to the positioning information.

[0118] The prior art test tool can only test the interface to be tested, and manual positioning of the abnormal interface to be tested is required. When the number of interfaces to be tested is large, it is difficult for manual positioning to determine which service the abnormal interface to be tested belongs to, which business system the abnormal interface to be tested is located in, which users to inform, and a large amount of manual cost is required.

[0119] The embodiment can quickly and accurately position the service to which the abnormal interface to be tested belongs, and the business and user associated with the service according to the various configuration information and mapping relationships in the database. Once the interface to be tested is abnormal, the corresponding user can be notified, and the specific positioning result of the interface to be tested can be informed to the user, so that the user can quickly determine which system is faulty.

[0120] It should be noted that when the interface test is implemented by the user issuing an instruction, the test can be directly performed and the test result can be directly returned to the user, and the user does not need to be found.

[0121] On the basis of the above embodiments, the embodiment further includes: in the case of determining that the test on the to-be-tested interface is successful, querying whether there is a historical alarm of the to-be-tested interface; in the case of existing the historical alarm, eliminating the historical alarm and notifying a user that the historical alarm has been recovered.

[0122] Optionally, in the case of determining that the test on the to-be-tested interface is successful, querying whether there is a historical alarm of the to-be-tested interface in the interface call exception record of the to-be-tested interface;

[0123] In the case of existing the historical alarm, eliminating the historical alarm and notifying a user that the historical alarm has been recovered.

[0124] The way of notifying the user includes but is not limited to short message, email, WeChat and DingTalk, etc., which is not limited in the embodiment.

[0125] On the basis of the above embodiments, the embodiment further includes: according to the identification information of the to-be-tested interface, finding the reference test result of the to-be-tested interface, including: according to the identification information of the to-be-tested interface, finding the matching information in the interface configuration information of the to-be-tested interface; according to the test request information, executing the business logic in the matching information to obtain the reference test result; or, according to the test request information, finding the reference test result in the matching information.

[0126] The matching information includes but is not limited to business logic and expected test result; for example, the matching information is a string, including regular expression and numerical range, etc.

[0127] Optionally, the business logic in the matching information can be executed according to the test request information to obtain the reference test result; or the reference test result can be directly found in the matching information; the embodiment is not limited in this regard.

[0128] The embodiment can verify whether the to-be-tested interface is tested successfully through various ways, which is simple to operate and good in flexibility.

[0129] On the basis of the above embodiments, the embodiment further includes: receiving a target task at a preset frequency; wherein the target task is formed according to one or more to-be-tested interfaces of the same category; and the identification information of each to-be-tested interface in the target task is received in batches.

[0130] The category of the to-be-tested interface can be divided according to the function realized by the to-be-tested interface, etc., which is not limited in the embodiment.

[0131] Optionally, when testing the to-be-tested interfaces, the task scheduler creates one or more target tasks of the to-be-tested interfaces of the same category, sets different execution frequencies for each task, and according to the execution frequencies of the tasks, the allocation executor executes the corresponding target tasks at the frequencies; and queries and obtains the identification information of all to-be-tested interfaces, and sends the identification information of the to-be-tested interfaces to the executor in batches.

[0132] The executor receives the target tasks sent by the task scheduler at the preset frequencies, and receives the identification information of each to-be-tested interface in the target tasks sent by the task scheduler; and tests each to-be-tested interface according to the identification information of each to-be-tested interface.

[0133] The embodiment can test to-be-tested interfaces of different categories in parallel according to different frequencies and different dimensions, which can effectively improve the testing efficiency; and when to-be-tested interfaces of the same category appear abnormal or alarm, the to-be-tested interfaces can be located according to the configuration information and mapping relationship established in the database.

[0134] As Figure 3 The structure diagram of the testing execution process in the interface testing method in the embodiment is shown in FIG. 1, and the specific steps include,

[0135] Step 1, creating a target task; multiple to-be-tested interfaces of the same category are attributed to the same target task, the execution frequency of each target task is set, and the target task is started;

[0136] Step 2, task scheduling; the task scheduler allocates the target task to the corresponding executor at the frequency according to the execution frequency of the task; and queries all to-be-tested interfaces under the target task, and transmits the identification information of the to-be-tested interfaces to the executor in batches;

[0137] Step 3, the executor obtains the configuration information of the to-be-tested interface according to the identification information of each to-be-tested interface, determines the state of the to-be-tested interface according to the configuration information of the to-be-tested interface, and deletes the identification information of the interface with the state of being unusable; then, the corresponding processor is adapted according to the processor type information in the interface configuration information, so that the processor processes the pre-task of the to-be-tested interface; then, the processing result returned by the processor is obtained, and the processing result is written into the request header and the request body in the interface configuration information to form request information;

[0138] Step 4, interface calling; the calling of the to-be-tested interface is executed according to the generated request information, and the interface calling record and the actual test result of the to-be-tested interface are recorded.

[0139] Step 5, matching the actual test result with the reference test result obtained according to the business logic in the matching information or the reference test result obtained by searching in the matching information, determining the test success or test failure of the interface to be tested, and obtaining the corresponding test success identifier or test failure identifier;

[0140] Step 6, confirming whether to generate an alarm according to the test success identifier or test failure identifier; for the test success identifier, calling an alarm trigger to query the interface alarm record of the interface to be tested; if there is a historical alarm, eliminating the historical alarm and notifying the user that the alarm has been restored; for the test failure identifier, calling the alarm trigger to determine whether to trigger the alarm, that is, if the number of continuous test failures is greater than a preset value, the alarm is triggered, and the alarm prompt number is accumulated by 1;

[0141] Step 7, updating the test result, time consumption, return information and the like in the interface call record; wherein, the return information needs to be optimized to prevent the database disk from being overlimited due to too large data volume.

[0142] In summary, the test method in the embodiment can automatically test the dial test by the system, and has high test efficiency; and the complex special processing task, that is, the pre-task and the test result processing, makes the interface test support configuration, dynamic execution, and only a small amount of changes are needed to perform the interface test and online monitoring, and the user only needs to understand simple configuration rules to achieve different tests of the interface to be tested, without understanding the complex special processing process, so that the test of the special interface of the pre-task is simpler and more general.

[0143] The interface test device provided by the present application is described below, and the interface test device described below can be correspondingly referred to the interface test method described above.

[0144] As shown in Figure 4 The embodiment provides an interface test device, which comprises a searching module 401, a processing module 402, a generating module 403 and a testing module 404, wherein:

[0145] The searching module 401 is configured to search the processor type information corresponding to the interface to be tested according to the identification information of the interface to be tested.

[0146] The execution subject of the embodiment can be an executor, such as a computer.

[0147] The interface to be tested is a software interface that needs to be tested, which can be an HTTP service interface, and the embodiment does not make specific limitation thereto.

[0148] The identification information of the interface to be tested can be a number or an ID, and the embodiment does not make specific limitation thereto. Each interface to be tested has unique identification information.

[0149] The pre-constructed database stores interface configuration information of a plurality of interfaces. The interface configuration information includes, but is not limited to, an interface ID, a service ID, an interface name, an interface URL, a request header, a request parameter, a request method, an expected matching value, a matching type, a pre-processor type, a maximum time consumption, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0150] The pre-constructed database also stores service configuration information, service-user mapping relationship, alarm user configuration information, service configuration information, interface alarm record, environment configuration information, interface call record, task-interface mapping relationship, and task configuration information, which are not specifically limited in the embodiment.

[0151] The service configuration information includes, but is not limited to, a service ID, a service name, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0152] The service-user mapping relationship includes, but is not limited to, a main chain, a service ID, a user ID, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0153] The alarm user configuration information includes, but is not limited to, a main chain, a user name, a mobile phone number, an email, an enterprise WeChat, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0154] The service configuration information includes, but is not limited to, a service ID, a service name, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0155] The interface alarm record includes, but is not limited to, an alarm ID, an exception ID, a service ID, an alarm user ID set, an alarm content, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0156] The environment configuration information includes, but is not limited to, an environment ID, an environment code, an environment name, a URL prefix, a state, a note, a creation time, a creator, a modification time, and a modifier, and the like, which are not specifically limited in the embodiment.

[0157] The interface call record includes but is not limited to a main chain, a service ID, a task ID, an interface ID, an exception ID, a batch, an interface name, a request URL, a request header, a request parameter, a request method, an expected matching value, a matching type, a processor type, a maximum time consumption, a test return result, a state, an interface time consumption, a creation time, a creator, a modification time, and a modifier, etc. The embodiment is not specifically limited thereto.

[0158] The task and interface mapping relationship includes but is not limited to a main chain, a task ID, an interface ID, a state, a note, a creation time, a creator, a modification time, and a modifier, etc. The embodiment is not specifically limited thereto.

[0159] The task configuration information includes but is not limited to a task ID, an environment ID, a task name, a corn expression, a task UUID, a state, a note, a creation time, and a creator, etc. The embodiment is not specifically limited thereto.

[0160] The interface configuration information, the service configuration information, the service and user mapping relationship, the alarm user configuration information, the service configuration information, the environment configuration information, the task and interface mapping relationship, and the task configuration information can be updated according to actual needs. The updating includes but is not limited to adding, deleting, or modifying.

[0161] Optionally, when the to-be-tested interface needs to be tested, the executor acquires the identification information of the to-be-tested interface; then, the interface configuration information containing the identification information is searched in the database; then, the processor type information is searched in the interface configuration information.

[0162] Each identification information corresponds to unique interface configuration information; the interface configuration information contains corresponding processor type information.

[0163] The processing module 402 is configured to determine a processor corresponding to the processor type information, and to process a pre-task of the to-be-tested interface by the processor; the pre-task is a to-be-processed task before the to-be-tested interface is tested.

[0164] The processor can be divided into multiple types according to the functions implemented by the processor; the types of the processor include but are not limited to processors for processing replay, signature verification, and token type tasks; correspondingly, the target task includes but is not limited to tasks of the replay, signature verification, and token type.

[0165] The processor type information can be represented by a number, such as when the processor type information is empty or 0, indicating no pending task before testing the interface to be tested; when the processor type information is 1, indicating that the pending task before testing the interface to be tested is a replay task; when the processor type information is 2, indicating that the pending task before testing the interface to be tested is a signature verification task; and when the processor type information is 3, indicating that the pending task before testing the interface to be tested is a token task.

[0166] Since the interface provided by the background to the foreground usually increases the anti-replay processing, the interface interaction between systems usually needs to be signature verified; therefore, anti-replay or signature verification processing is required before calling the interface.

[0167] Optionally, after obtaining the interface configuration information of the interface to be tested, it is determined whether the interface to be tested is in a normal running state according to the state in the interface configuration information.

[0168] If the interface to be tested is in a normal running state, processor type information corresponding to the interface to be tested is obtained from the interface configuration information, and a processor corresponding to the processor type information is adapted according to the processor type information; when the corresponding processor is adapted, the target task of the interface to be tested is sent to the processor, so that the processor processes the target task, and the processing result is returned to the executor.

[0169] If the interface to be tested is in an abnormal running state, it is prompted that the interface to be tested is in an abnormal running state and cannot be tested.

[0170] In the prior art, a dial test system is formulated to process the pending task before testing the interface to be tested; wherein the processing scheme of the dial test system is to directly execute a jmeter script with a fixed frequency, and script code is written in the jmeter script to execute target tasks and interface response processing. However, the dial test system has weak functions and does not perceive the interface test process, mainly relying on the jmeter script provided by the developer. Therefore, the developer needs to be familiar with jmeter, which requires a lot of learning time, and the interface test relies on jmeter, which needs to be changed every time the interface is tested, and the usability is not high and additional time is required.

[0171] The embodiment only needs to automatically acquire the processor type information in the interface configuration information of the interface to be tested according to the identification information of the interface to be tested, automatically adapt to the corresponding processor, and execute the corresponding target task, which is not only suitable for testing of ordinary interfaces, but also suitable for testing of interfaces with special target tasks before testing, is simple to operate, has strong applicability, can effectively reduce code overhead caused by code writing, and can support multiple types of processors at the same time. During the interface testing stage, the system calls the corresponding processor for processing according to the configuration, and the user does not need to perceive the process.

[0172] The generating module 403 is configured to receive the processing result returned by the processor, and generate test request information of the interface to be tested according to the processing result.

[0173] Optionally, the processing result returned by the processor is received, and the processing result is fused into the request header and the request body in the interface configuration information to form the test request information of the interface to be tested, that is, the request information contains the request parameter and the request address, and also contains the processing result.

[0174] For example, the processing result returned by the processor is a signature verification result, that is, a signature.

[0175] The testing module 404 is configured to test the interface to be tested according to the test request information, and acquire an actual test result of the interface to be tested.

[0176] Optionally, after the request information is acquired, a communication link between the interface to be tested and the executor is established according to the request address in the test request information, the request parameter is sent to the interface to be tested through the communication link, the interface to be tested is called to execute the request parameter, and the actual test result is acquired.

[0177] It should be noted that when the interface to be tested is called for testing, the calling record needs to be recorded in real time, that is, the interface calling record of the interface to be tested is generated.

[0178] The actual test result can be directly returned by the interface to be tested, or can be acquired by querying the interface calling record, which is not limited in the embodiment.

[0179] The data format of the actual test result can be JSON format, which is not limited in the embodiment.

[0180] The embodiment automatically acquires interface configuration information of the interface to be tested in the database according to the identification information of the interface to be tested; then, automatically adapts a corresponding processor according to processor type information in the interface configuration information, automatically processes a pre-task of the interface to be tested through the adapted processor, and automatically generates test request information according to a processing result returned by the processor, so that the interface to be tested can be called according to the test request information to perform testing; the whole testing process is automatically completed, the testing efficiency is high, the manual cost and learning cost caused by manual modification of scripts at each time of testing are effectively avoided; and different configuration information is configured for different interfaces to be tested, so that different pre-tasks of different interfaces can be processed and tested, the testing of different demand interfaces to be tested can be compatible, and the versatility is good; and the configuration file can be modified according to actual needs, and the flexibility is good.

[0181] On the basis of the above-mentioned embodiments, the embodiment further includes a determination module configured to: find a reference test result of the interface to be tested according to identification information of the interface to be tested; match the actual test result with the reference test result; determine that the testing of the interface to be tested fails in a case where the matching result is that the actual test result and the reference test result are different; and determine that the testing of the interface to be tested succeeds in a case where the matching result is that the actual test result and the reference test result are the same.

[0182] On the basis of the above-mentioned embodiments, the embodiment further includes an alarm triggering module configured to: determine whether the number of continuous testing failures of the interface to be tested is greater than a preset value in a case where it is determined that the testing of the interface to be tested fails; and send alarm information to a terminal in a case where the number is greater than the preset value.

[0183] On the basis of the above-mentioned embodiments, the embodiment further includes a positioning module configured to: find configuration information of a service to which the interface to be tested belongs according to identification information of the service in a case where the number is greater than the preset value; and / or find configuration information of a business corresponding to the service according to identification information of the business corresponding to the service; find configuration information of a user corresponding to the service according to the identification information of the service; position the interface to be tested according to the configuration information of the service and / or the configuration information of the business; and send a positioning result to the user according to the configuration information of the user.

[0184] On the basis of the above-mentioned embodiments, the alarm triggering module is further configured to: query whether there is a historical alarm of the interface to be tested in a case where it is determined that the testing of the interface to be tested succeeds; eliminate the historical alarm and notify a user that the historical alarm has been restored in a case where there is the historical alarm.

[0185] On the basis of the above-mentioned embodiments, in the embodiment, the determining module is further configured to: according to the identification information of the to-be-tested interface, search for matching information in interface configuration information of the to-be-tested interface; according to the test request information, execute service logic in the matching information to obtain the reference test result; or according to the test request information, search for the reference test result in the matching information.

[0186] On the basis of the above-mentioned embodiments, in the embodiment, the receiving module is further configured to: receive target tasks at a preset frequency; wherein the target tasks are created according to one or more to-be-tested interfaces of the same category; and receive identification information of each to-be-tested interface in the target tasks in batches.

[0187] Figure 5 An example of an entity structure diagram of an electronic device is shown in Figure 5 As shown in the figure, the electronic device can include a processor 501, a communications interface 502, a memory 503, and a communications bus 504, wherein the processor 501, the communications interface 502, and the memory 503 complete mutual communication through the communications bus 504. The processor 501 can invoke a logical instruction in the memory 503 to execute an interface testing method, which includes: according to identification information of a to-be-tested interface, searching for processor type information corresponding to the to-be-tested interface; determining a processor corresponding to the processor type information, which is used to process a pre-task of the to-be-tested interface by the processor; wherein the pre-task is a to-be-processed task before testing the to-be-tested interface; receiving a processing result returned by the processor, and generating test request information of the to-be-tested interface according to the processing result; testing the to-be-tested interface according to the test request information, and obtaining an actual test result of the to-be-tested interface.

[0188] In addition, the logic instructions in the memory 503 described above can be implemented in the form of a software function unit and sold or used as an independent product, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0189] In another aspect, the present application also provides a computer program product, which comprises a computer program, the computer program can be stored on a non-transitory computer readable storage medium, and the computer program is executed by a processor, so that the computer can execute the interface test method provided by the above-mentioned methods. The method comprises the following steps: according to the identification information of the interface to be tested, the processor type information corresponding to the interface to be tested is found; the processor corresponding to the processor type information is determined, which is used for the processor to process the pre-task of the interface to be tested; wherein the pre-task is a to-be-processed task before the interface to be tested is tested; the processing result returned by the processor is received, and the test request information of the interface to be tested is generated according to the processing result; the interface to be tested is tested according to the test request information, and the actual test result of the interface to be tested is obtained.

[0190] In another aspect, the present application also provides a computer program product, which comprises a computer program, the computer program can be stored on a non-transitory computer readable storage medium, and the computer program is executed by a processor, so that the computer can execute the interface test method provided by the above-mentioned methods. The method comprises the following steps: according to the identification information of the interface to be tested, the processor type information corresponding to the interface to be tested is found; the processor corresponding to the processor type information is determined, which is used for the processor to process the pre-task of the interface to be tested; wherein the pre-task is a to-be-processed task before the interface to be tested is tested; the processing result returned by the processor is received, and the test request information of the interface to be tested is generated according to the processing result; the interface to be tested is tested according to the test request information, and the actual test result of the interface to be tested is obtained.

[0191] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed to multiple network units. Part or all of the modules can be selected to achieve the purposes of the embodiments according to actual needs. Those skilled in the art can understand and implement without creative labor.

[0192] Through the description of the above embodiments, those skilled in the art can clearly understand that the embodiments can be realized by means of software and the necessary general hardware platform, and of course can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.

[0193] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. An interface testing method, characterized in that, include: Based on the identification information of the interface to be tested, find the processor type information corresponding to the interface to be tested; The processor corresponding to the processor type information is determined, and the processor is used to process the pre-processing tasks of the interface to be tested; wherein, the pre-processing tasks are the tasks to be processed before testing the interface to be tested, and the tasks to be processed include replay, signature verification, and token type tasks. The processor returns a processing result, and the processor generates test request information for the interface to be tested based on the processing result. The test request information includes request parameters, request address, and processing result. The interface to be tested is tested according to the test request information, and the actual test results of the interface to be tested are obtained.

2. The interface testing method according to claim 1, characterized in that, Also includes: Based on the identification information of the interface to be tested, find the reference test results of the interface to be tested; The actual test results are matched with the reference test results; If the matching result is different between the actual test result and the reference test result, the test on the interface to be tested is determined to have failed. If the matching result is the same as the actual test result and the reference test result, the test on the interface to be tested is determined to be successful.

3. The interface testing method according to claim 2, characterized in that, Also includes: If it is determined that the test of the interface to be tested has failed, it is determined whether the number of consecutive test failures of the interface to be tested is greater than a preset value. If the number of occurrences exceeds the preset value, an alarm message is sent to the terminal.

4. The interface testing method according to claim 3, characterized in that, Also includes: If the number of attempts exceeds the preset value, the configuration information of the service to which the interface to be tested belongs is retrieved based on the identification information of the service to which the interface to be tested belongs. And / or, based on the identifier information of the service corresponding to the service, find the configuration information of the service corresponding to the service; Based on the service's identifier information, locate the configuration information of the user corresponding to the service; Based on the configuration information of the service and / or the configuration information of the business, the interface to be tested is located, and the location result is sent to the user according to the user's configuration information.

5. The interface testing method according to any one of claims 2-4, characterized in that, Also includes: If the test of the interface to be tested is successful, check whether the interface to be tested has any historical alarms. If the historical alarm exists, clear the historical alarm and notify the user that the historical alarm has been restored.

6. The interface testing method according to any one of claims 2-4, characterized in that, The step of finding the reference test result of the interface to be tested based on the identification information of the interface to be tested includes: Based on the identification information of the interface to be tested, search for matching information in the interface configuration information of the interface to be tested; Execute the business logic in the matching information according to the test request information to obtain the reference test result; or... Based on the test request information, the reference test result is retrieved from the matching information.

7. The interface testing method according to any one of claims 1-4, characterized in that, Also includes: The target task is received at a preset frequency; wherein the target task is created based on one or more interfaces of the same type to be tested. The identification information of each interface to be tested in the target task will be received in batches.

8. An interface testing device, characterized in that, include: The lookup module is used to look up the processor type information corresponding to the interface to be tested based on the identification information of the interface to be tested; The processing module is used to determine the processor corresponding to the processor type information, and the processor is used to process the pre-processing tasks of the interface to be tested; wherein, the pre-processing tasks are the tasks to be processed before testing the interface to be tested, and the tasks to be processed include replay, signature verification, and token type tasks. The generation module is used to receive the processing result returned by the processor and generate test request information for the interface to be tested based on the processing result. The test request information includes request parameters, request address and processing result. The testing module is used to test the interface to be tested according to the test request information and obtain the actual test results of the interface to be tested.

9. 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 program, it implements the steps of the interface testing method as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the interface testing method as described in any one of claims 1 to 7.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the interface testing method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Automatic test platform

    CN110928796A

  • Interface testing method and related device

    CN112667506A

  • Interface testing method and device, electronic equipment and storage medium

    CN112948195A