Interface test method and device, electronic equipment and storage medium

By using production environment logs to automate the comparison of call results in interface testing, the problem of low efficiency in interface testing was solved, and efficient and stable interface testing was achieved.

CN116303080BActive Publication Date: 2026-03-27GUANGZHOU FANGGUI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing technologies for interface testing are inefficient, requiring manual input of test data and manual comparison of results, and their reliance on external interface services leads to unstable testing.

Method used

By obtaining interface test requests, the interface to be tested and test cases are determined. The production environment's work logs are used as test data to automatically compare the results of the first and second calls, thereby achieving automated testing of the interface.

Benefits of technology

It improves the efficiency of interface testing, reduces manual intervention, and enhances the stability and accuracy of testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116303080B_ABST
    Figure CN116303080B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of interface testing, and proposes an interface testing method and device, an electronic device and a storage medium, the method comprising the following steps: obtaining an interface testing request; determining a to-be-tested interface and a test case of the to-be-tested interface according to the interface testing request; obtaining a work log generated by the to-be-tested interface in a production environment; the work log comprises first request data for calling the to-be-tested interface in the production environment and a first calling result responded by the to-be-tested interface according to the first request data; inputting the first request data into the to-be-tested interface according to the test case to obtain a second calling result responded by the to-be-tested interface; and comparing the first calling result with the second calling result to obtain a test result of the to-be-tested interface. According to the application, the work log in the production environment is used as test data of the to-be-tested interface, the production environment can be simulated, manual test data writing is not needed, and the interface testing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of interface testing and network live broadcast, and in particular to an interface testing method and device, an electronic device, and a storage medium. BACKGROUND

[0002] With the increasing development of computer technology, more and more systems providing various application functions are provided to people. In order to ensure the stability of system operation, the interface of the system is usually tested during development. Interface testing is a test on the interface between systems. Interface testing is mainly used to detect the interaction interface between systems and between various subsystems within a system. For example, in a live broadcast application, the interface object display interface of a live broadcast room interface needs to be tested to ensure that the interface object display interface is called, receives an interface object, and thus displays an interface notification message.

[0003] In related technologies, during interface testing, test data of a to-be-tested interface is often manually input, and then the test results of the interface are manually compared to check whether the calling of the interface meets the requirements, resulting in low interface testing efficiency. SUMMARY

[0004] Embodiments of the present application provide an interface testing method, device, electronic device, and storage medium, which can improve interface testing efficiency. The technical solution is as follows:

[0005] In a first aspect, embodiments of the present application provide an interface testing method, which includes the following steps:

[0006] An interface testing request is obtained, and a to-be-tested interface and a test case of the to-be-tested interface are determined according to the interface testing request;

[0007] A work log generated by the to-be-tested interface in a production environment is obtained. The work log includes first request data for calling the to-be-tested interface in the production environment and a first calling result responded by the to-be-tested interface according to the first request data;

[0008] The first request data is input into the to-be-tested interface according to the test case, and a second calling result responded by the to-be-tested interface is obtained. The first calling result and the second calling result are compared, and a test result of the to-be-tested interface is obtained.

[0009] In a second aspect, embodiments of the present application provide an interface testing device, which includes:

[0010] A test request obtaining module is configured to obtain an interface testing request, and determine a to-be-tested interface and a test case of the to-be-tested interface according to the interface testing request;

[0011] The work log acquisition module is configured to acquire a work log generated by the to-be-tested interface in a production environment, wherein the work log comprises first request data for calling the to-be-tested interface in the production environment and a first calling result responded by the to-be-tested interface according to the first request data.

[0012] The test result acquisition module is configured to input the first request data into the to-be-tested interface according to the test case, acquire a second calling result responded by the to-be-tested interface, compare the first calling result with the second calling result, and acquire a test result of the to-be-tested interface.

[0013] In a third aspect, an electronic device is provided, including a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method in the first aspect when executing the computer program.

[0014] In a fourth aspect, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, and the computer program is executable on a processor to implement the steps of the method in the first aspect.

[0015] The embodiments of the present application acquire an interface test request, determine a to-be-tested interface and a test case of the to-be-tested interface according to the interface test request, acquire a work log generated by the to-be-tested interface in a production environment, wherein the work log comprises first request data for calling the to-be-tested interface in the production environment and a first calling result responded by the to-be-tested interface according to the first request data, input the first request data into the to-be-tested interface according to the test case, acquire a second calling result responded by the to-be-tested interface, compare the first calling result with the second calling result, and acquire a test result of the to-be-tested interface. The embodiments of the present application can simulate the production environment by taking the work log in the production environment as test data of the to-be-tested interface, without manually writing test data, and thus the interface test efficiency is improved.

[0016] For better understanding and implementation, the technical solutions of the present application are described in detail below with reference to the drawings. BRIEF DESCRIPTION OF DRAWINGS

[0017] Figure 1 A flowchart of an interface test method provided by an embodiment of the present application;

[0018] Figure 2 A schematic diagram of collecting a work log of a to-be-tested interface provided by an embodiment of the present application;

[0019] Figure 3 A schematic diagram of collecting a work log of a to-be-tested interface provided by another embodiment of the present application;

[0020] Figure 4 A structural schematic diagram of an interface test device provided by an embodiment of the present application;

[0021] Figure 5 A structural schematic diagram of an electronic device provided by an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION

[0022] The exemplary embodiments will be described in detail herein with reference to the attached drawings. In the following description, the same numbers are used to indicate the same or similar components. The embodiments described in the following exemplary embodiments do not represent all the embodiments consistent with the present application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the present application as detailed in the appended claims.

[0023] The terminology used in the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in the present application and the appended claims, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0024] It should be understood that although the terms first, second, third, etc. can be employed in this application to describe various information, such information should not be limited by these terms. These terms are only used to distinguish one piece of information from another. For example, a first information can also be termed a second information without departing from the scope of the present application. Similarly, the second information can also be termed the first information. Depending on the context, the word "if' as used herein can be interpreted as meaning "when" or "if in response to determining."

[0025] In order to better understand the technical solutions of the present application, some interface testing methods in the art are briefly introduced herein.

[0026] In the related art, the request information needs to be manually input to the interface under test for testing, and the processing result is output by the interface under test, and then the consistency between the processing result and the response information corresponding to the request information is compared, that is, whether the logic processing function of the interface under test is abnormal is tested. If the interface under test is called in the production environment, an external interface needs to be called. Therefore, in the testing environment, the request information needs to be manually input to the interface under test, the interface under test calls the external interface to obtain the calling return value output by the external interface, and then the calling return value is processed to output the processing result, and then the consistency between the processing result and the response information corresponding to the request information is compared.

[0027] The above scheme needs to manually input the test data of the to-be-tested interface, and then manually compare the test results of the interface, resulting in low interface test efficiency. At the same time, it needs to rely on the interface calling service provided by the external interface, and if the external interface works abnormally, the test of the to-be-tested interface cannot be performed.

[0028] Therefore, the present application provides an interface test method for automatic testing of an interface. Specifically, it can be applied between a client device and an interface test platform. The client device can be a mobile phone, a tablet computer, a computer, etc. Taking a mobile phone as an example, various applications required by users, such as live streaming applications, video applications, game applications, etc., can be installed in the client device.

[0029] Referring to Figure 1 , Figure 1 The flowchart of the interface test method provided by the embodiment of the present application is shown in the figure. The method comprises the following steps:

[0030] S10: Obtain an interface test request; determine the to-be-tested interface and the test case of the to-be-tested interface according to the interface test request.

[0031] The interface test request is a request of a user for interface testing of a preset interface. The interface test request can include the interface information of the interface to be tested by the user, specifically, the interface test request includes the identifier of the to-be-tested interface. The identifier of the to-be-tested interface can be the interface name, interface type or interface address of the to-be-tested interface.

[0032] The test case information refers to a set of test inputs, execution conditions and expected results prepared for a specific target, in order to verify whether a certain program path or certain specific needs are met, which can include the interface name, request method, request address, request parameter and return parameter of the to-be-tested interface. The request parameter can include the data input to the to-be-tested interface, and the return parameter can include the expected result returned by the to-be-tested interface after receiving the request parameter.

[0033] In the embodiment of the present application, when the user needs to test the to-be-tested interface, the user can log in to the interface test platform through an account and a password, and trigger the interface test request for the to-be-tested interface through the user interaction interface provided by the interface test platform.

[0034] After the interface test platform obtains the interface test request, the interface test request can be directly parsed to obtain the identifier of the interface to be tested in the interface test request, and the interface to be tested is determined according to the identifier of the interface to be tested. At the same time, the test case of the interface to be tested can be determined according to the identifier of the interface to be tested. Specifically, the test case of the interface to be tested can be obtained from the test case library according to the identifier of the interface to be tested. The test case library has pre-stored test cases of various interfaces. Optionally, before the user initiates the interface test request, the user can also edit the test case of the interface to be tested online in the test case editing interface provided by the interface test platform. Correspondingly, the interface test platform receives and stores the test case edited by the user for the interface to be tested.

[0035] S20: Obtain a work log generated by the interface to be tested in a production environment; the work log includes first request data for calling the interface to be tested in the production environment and a first calling result responded by the interface to be tested according to the first request data.

[0036] The production environment is a real online environment, that is, an environment for providing external services formally. The work log is a file for recording the calling condition of the interface to be tested when the interface to be tested is called by a service invoker in the production environment or when the interface to be tested calls an external interface in the production environment. The calling condition includes the first request data received by the interface to be tested and the first calling result responded by the interface to be tested according to the first request data.

[0037] S30: According to the test case, input the first request data into the interface to be tested to obtain a second calling result responded by the interface to be tested; compare the first calling result with the second calling result to obtain a test result of the interface to be tested.

[0038] The first calling result is a processing result of the interface to be tested for the first request data in the production environment, and the second calling result is a processing result of the interface to be tested for the first request data in the test environment.

[0039] In the embodiment of the present application, the test result of the interface to be tested is obtained by comparing whether the first calling result and the second calling result are the same.

[0040] According to the embodiment of the application, the interface test request is acquired, the to-be-tested interface and the test case of the to-be-tested interface are determined according to the interface test request, the working log generated by the to-be-tested interface in the production environment is acquired, the working log includes the first request data for calling the to-be-tested interface in the production environment and the first calling result responded by the to-be-tested interface according to the first request data, the first request data is input into the to-be-tested interface according to the test case, and the second calling result responded by the to-be-tested interface is acquired, the first calling result is compared with the second calling result, and the test result of the to-be-tested interface is acquired. According to the application, the working log in the production environment is used as the test data of the to-be-tested interface, the production environment can be simulated, the test data does not need to be manually written, and the interface test efficiency is improved.

[0041] In an optional embodiment, before step S20, steps S1-S2 are included, and specifically as follows.

[0042] S1: The first request data for calling the to-be-tested interface in the production environment and the first calling result generated by the to-be-tested interface after receiving the first request data and the log tracking identifier are acquired, and the first log of the to-be-tested interface is generated according to the first request data, the first calling result and the log tracking identifier.

[0043] S2: The first log is stored by the interface log storage system as the working log generated by the to-be-tested interface in the production environment.

[0044] Please refer to Figure 2 In the production environment, the service calling party 10 calls the to-be-tested interface 20, the service calling party 10 sends the first request data to the to-be-tested interface 20, the to-be-tested interface 20 receives the first request data, generates the first calling result and the log tracking identifier. Specifically, the service calling party 10 can be a client device. Specifically, the service calling party 10 calls the to-be-tested interface 20, for example, the to-be-tested interface Z, the format of the first log is: {class: Z, method: queryZ, params: pz, resp: rz, traceId: ID}, wherein pz is the first request data, rz is the first calling result, and ID is the log tracking identifier.

[0045] The interface log storage system 30 is used for storing the working log recording the calling situation of each interface in the production environment. Specifically, the interface log storage system is a distributed storage search component ElasticSearch. The ElasticSearch is a distributed, high-extensible and high-real-time search and data analysis engine. It can conveniently enable a large amount of data to have the ability of search, analysis and exploration. When the to-be-tested interface is tested, the test data of the to-be-tested interface can be efficiently acquired through the distributed storage search component ElasticSearch.

[0046] By collecting the working log of the to-be-tested interface 20 in the production environment in real time, the working log is used as the test data of the to-be-tested interface 20 in the test environment.

[0047] In an optional embodiment, the first call result includes at least one first processing result and a third processing result; the first processing result is a processing result of the to-be-tested interface processing the first request data in the production environment, and the third processing result is a processing result of the to-be-tested interface processing a call return value fed back by the external interface based on the first processing result, where the to-be-tested interface calls the external interface with the first processing result as the input of the external interface; the first log includes a first sub-log, a second sub-log and a third sub-log. Step S1 includes steps S11-S13, and the details are as follows.

[0048] S11: Collecting the first request data for calling the to-be-tested interface in the production environment and at least one first processing result and a log tracking identifier generated after the to-be-tested interface receives the first request data; and generating the first sub-log of the to-be-tested interface according to the first request data, the at least one first processing result and the log tracking identifier.

[0049] Please refer to Figure 3 In the production environment, if the to-be-tested interface 20 needs to call at least one external interface 40 after being called by the service invoker 10, the first call result includes at least one first processing result and a third processing result, the third processing result is the response data finally returned to the service invoker 10, and the first processing result is the request data for calling the at least one external interface 40 by the to-be-tested interface.

[0050] Specifically, the to-be-tested interface 20 calls the external interface 40, for example, the external interface A, and the format of the first sub-log is: {class: Z, method: queryZ, params: pz, resp: pa, traceId: ID}, where pz is the first request data, pa is the first processing result, and ID is the log tracking identifier. The to-be-tested interface 20 calls the external interface 30, for example, the external interfaces A, B and C, and the formats of the first sub-logs are: {class: Z, method: queryZ, params: pz, resp: pa, pb, pc, traceId: ID}, respectively, where pz is the first request data, and pa, pb and pc are the first processing results.

[0051] S12: Collecting a call return value generated after the to-be-tested interface calls at least one external interface with the first processing result and the external interface receives the first processing result in the production environment; and generating the second sub-log of the to-be-tested interface according to the first processing result, the call return value and the log tracking identifier.

[0052] Specifically, the to-be-tested interface 20 calls the external interface 40, for example, the external interface A, and the format of the second sub-log is: {class: A, method: queryA, params: pa, resp: ra, traceId: ID}, where pa is the first processing result, and ra is the call return value. Optionally, the to-be-tested interface 20 calls the external interface 30, for example, the external interfaces A, B, and C, and the formats of the second sub-logs are: {class: A, method: queryA, params: pa, resp: ra, traceId: ID}, {class: B, method: queryA, params: pb, resp: rb, traceId: ID}, and {class: C, method: queryC, params: pc, resp: rc, traceId: ID}, respectively, where ra, rb, and rc are call return values.

[0053] S13: Collecting a third processing result of the to-be-tested interface after receiving and processing the call return value in the production environment; and generating a third sub-log of the to-be-tested interface according to the call return value, the third processing result, and the log trace identifier.

[0054] Specifically, the to-be-tested interface 20 calls the external interface 40, for example, the external interface A, and the format of the second sub-log is: {class: A, method: queryA, params: pa, resp: ra, traceId: ID}, where pa is the first processing result, and ra is the call return value. Optionally, the to-be-tested interface 20 calls the external interface 30, for example, the external interfaces A, B, and C, and the formats of the second sub-logs are: {class: A, method: queryA, params: pa, resp: ra, traceId: ID}, {class: B, method: queryA, params: pb, resp: rb, traceId: ID}, and {class: C, method: queryC, params: pc, resp: rc, traceId: ID}, respectively, where ra, rb, and rc are call return values.

[0055] In the embodiment of the present application, the working log of the to-be-tested interface 20 in the production environment is collected in real time, so as to be used as test data of the to-be-tested interface 20 in the test environment subsequently.

[0056] In an optional embodiment, the step S20 includes steps S201-S203, and the details are as follows.

[0057] S201: Obtaining a fourth log from the interface log storage system, where the fourth log is any log in the interface log storage system;

[0058] S202: Determining whether the fourth log is a log of the to-be-tested interface;

[0059] S203: If yes, according to the log tracking identifier of the fourth log, all logs including the log tracking identifier in the interface log storage system are determined as the working logs of the to-be-tested interface in the production environment.

[0060] In the embodiments of the present application, any log is acquired from the interface log storage system, the tracking identifier in the log is identified, and if the tracking identifier is the tracking identifier of the to-be-tested interface, the working logs of the to-be-tested interface in the production environment can be automatically and quickly acquired according to the tracking identifier.

[0061] In an optional embodiment, the first calling result includes a first processing result, the first processing result being a processing result after the to-be-tested interface processes the first request data in the production environment; the second calling result includes a second processing result, the second processing result being a processing result after the to-be-tested interface processes the first request data in the test environment, and step S30 includes steps S301-S302, which are specifically as follows:

[0062] S301: If the second processing result is consistent with the first processing result, it is determined that the to-be-tested interface passes the test.

[0063] S302: If the second processing result is inconsistent with the first processing result, it is determined that the to-be-tested interface fails the test.

[0064] In the embodiments of the present application, if the to-be-tested interface is called by the service calling party, the to-be-tested interface does not need to call the external interface. Specifically, in the production environment, the to-be-tested interface Z is a service interface for querying the order amount, the service calling party sends the first request data to the to-be-tested interface Z, the first request data includes an order number, and then the to-be-tested interface outputs the order amount corresponding to the order number to the service calling party according to the order number.

[0065] By comparing whether the second processing result is consistent with the first processing result, it can be automatically and quickly determined whether the logic processing function of the to-be-tested interface is normal.

[0066] In an optional embodiment, the first calling result includes at least one first processing result and a third processing result; the first processing result is a processing result after the to-be-tested interface processes the first request data in the production environment, and the third processing result is a processing result after the to-be-tested interface processes the calling return value of the external interface based on the first processing result, wherein the to-be-tested interface calls the external interface with the first processing result as the input of the external interface in the production environment.

[0067] The second calling result includes a second processing result and a fourth processing result, the second processing result is a processing result of the to-be-tested interface processing the first request data in the test environment, and the fourth processing result is a processing result of the to-be-tested interface processing a calling return value fed back by the external interface based on the second processing result, where the to-be-tested interface calls the external interface with the second processing result as input of the external interface. Step S30 includes steps S303-S305, and details are as follows:

[0068] S303: If the second processing result is consistent with the first processing result, it is determined whether the fourth processing result is consistent with the third processing result.

[0069] S304: If the fourth processing result is consistent with the third processing result, it is determined that the to-be-tested interface passes the test.

[0070] S305: If the fourth processing result is not consistent with the third processing result, it is determined that the to-be-tested interface fails the test.

[0071] In the embodiment of the present application, if the to-be-tested interface needs to call at least an external interface when being called by the service calling party, specifically, in the production environment, the to-be-tested interface Z is a service interface for querying an order amount, the service calling party sends first request data to the to-be-tested interface Z, the first request data pz includes an order number, the to-be-tested interface needs to call external interfaces A, B and C to output an order amount rz corresponding to the order number according to the order number, the external interface A is a service interface for obtaining an order commodity price, the external interface B is a service interface for obtaining a user activity discount, and the external interface C is a service interface for obtaining a freight, the to-be-tested interface outputs first processing results pa, pb and pc according to the order number, takes the first processing results pa, pb and pc as input of the external interfaces A, B and C respectively, calls the external interfaces A, B and C, the external interfaces A, B and C output calling return values ra, rb and rc to the to-be-tested interface according to the first processing results pa, pb and pc, and the to-be-tested interface processes the calling return values ra, rb and rc and outputs a third processing result rz to the service calling party.

[0072] By comparing whether the second processing result is consistent with the first processing result, if the second processing result is not consistent with the first processing result, the to-be-tested interface passes the test. If the second processing result is consistent with the first processing result, it is further compared whether the fourth processing result is consistent with the third processing result, so as to automatically and quickly determine whether the logic processing function of the to-be-tested interface is normal.

[0073] Please refer to Figure 4 , Figure 4A structural diagram of an interface testing device provided by an embodiment of the present application is shown. The device can be implemented by software, hardware, or a combination of both to become all or part of a computer device. An interface testing device 4 provided by an embodiment of the present application includes:

[0074] A test request obtaining module 41 is configured to obtain an interface testing request, and determine a to-be-tested interface and a test case of the to-be-tested interface according to the interface testing request.

[0075] A work log obtaining module 42 is configured to obtain a work log of the to-be-tested interface generated in a production environment. The work log includes first request data for calling the to-be-tested interface in the production environment and a first calling result of the to-be-tested interface in response to the first request data.

[0076] A test result obtaining module 43 is configured to input the first request data into the to-be-tested interface according to the test case, and obtain a second calling result of the to-be-tested interface in response. The first calling result and the second calling result are compared to obtain a test result of the to-be-tested interface.

[0077] It should be noted that the interface testing device provided by the above embodiment in executing the virtual face generation method is only exemplified by the division of the above functional modules. In actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above described functions. In addition, the interface testing device and the interface testing method provided by the above embodiment belong to the same concept, and the implementation process is detailed in the method embodiment. Here, it is not repeated.

[0078] Please refer to Figure 5 , Figure 5 A structural diagram of an electronic device provided by the present application is shown. As shown in Figure 5 , the electronic device 21 can include a processor 210, a memory 211, and a computer program 212 stored in the memory 211 and executable on the processor 210, such as an interface testing program. The processor 210 executes the computer program 212 to implement the steps in the above embodiments.

[0079] The processor 210 can include one or more processing cores. The processor 210 connects various parts within the computer device 21 by various interfaces and lines, executes various functions of the computer device 21 and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 211, and calling data in the memory 211. Optionally, the processor 210 can be implemented in at least one of a hardware form of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programable logic array (PLA). The processor 210 can be integrated with a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes operating systems, user interfaces, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the touch display screen; and the modem is used for processing wireless communication. It can be understood that the above-mentioned modem can also not be integrated into the processor 210, but can be implemented by a separate chip.

[0080] The memory 211 can include a random access memory (RAM) and a read-only memory (ROM). Optionally, the memory 211 includes a non-transitory computer-readable storage medium. The memory 211 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 211 can include a program storage area and a data storage area. The program storage area can store instructions for implementing an operating system, instructions for at least one function (such as touch instructions, etc.), instructions for implementing the above-mentioned various method embodiments, etc. The data storage area can store data related to the above-mentioned various method embodiments, etc. The memory 211 can also be at least one storage device located away from the above-mentioned processor 210.

[0081] The embodiments of the present application also provide a computer storage medium, which can store a plurality of instructions. The instructions are suitable for being loaded and executed by a processor to execute the method steps of the above-mentioned embodiments. The specific execution process can be referred to the specific description of the above-mentioned embodiments, which will not be described here.

[0082] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional units and modules is taken as an example, and in actual application, the above functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or software. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the application. The specific working process of the units and modules in the above system can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.

[0083] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the related description of other embodiments.

[0084] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0085] In the embodiments provided by the present application, it should be understood that the disclosed apparatus / terminal device and method can be implemented in other ways. For example, the above-described apparatus / terminal device embodiments are only schematic. The division of the modules or units is only a logical function division, and there can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between the units can be indirect couplings or communication connections through some interfaces, devices or units, and can be electrical, mechanical or in other forms.

[0086] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0087] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.

[0088] If the integrated module / unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by a computer program instructing related hardware, and the computer program can be stored in a computer readable storage medium. When the computer program is executed by a processor, the steps of each method embodiment described above can be implemented. The computer program includes computer program code, which can be in the form of source code, object code, an executable file, or some intermediate form.

[0089] The present application is not limited to the above-described embodiments, and various modifications or changes can be made to the present application without departing from the spirit and scope of the present application. If the modifications and changes belong to the scope of the claims of the present application and the equivalent technical scope, the present application also intends to include the modifications and changes.

Claims

1. An interface test method characterized by, The method comprises the following steps: obtaining an interface test request; determining a to-be-tested interface and a test case of the to-be-tested interface according to the interface test request; obtaining a work log generated by the to-be-tested interface in a production environment; the work log comprises first request data for calling the to-be-tested interface in the production environment and a first calling result responded by the to-be-tested interface according to the first request data; inputting the first request data into the to-be-tested interface according to the test case to obtain a second calling result responded by the to-be-tested interface; the first calling result comprises a first processing result, which is a processing result of the to-be-tested interface on the first request data in the production environment; the second calling result comprises a second processing result, which is a processing result of the to-be-tested interface on the first request data in a test environment; comparing the first calling result with the second calling result to obtain a test result of the to-be-tested interface, comprising: if the second processing result is consistent with the first processing result, determining that the to-be-tested interface passes the test; if the second processing result is inconsistent with the first processing result, determining that the to-be-tested interface fails the test; alternatively, the first calling result comprises at least one first processing result and a third processing result; the first processing result is a processing result of the to-be-tested interface on the first request data in the production environment, and the third processing result is a processing result of the to-be-tested interface on a calling return value of at least one external interface fed back based on the first processing result, wherein the to-be-tested interface calls the external interface with the first processing result as input of the external interface in the production environment; the second calling result comprises a second processing result and a fourth processing result; the second processing result is a processing result of the to-be-tested interface on the first request data in the test environment, and the fourth processing result is a processing result of the to-be-tested interface on a calling return value of at least one external interface fed back based on the second processing result, wherein the to-be-tested interface calls the external interface with the second processing result as input of the external interface in the test environment; the step of comparing the first calling result with the second calling result to obtain the test result of the to-be-tested interface comprises: if the second processing result is consistent with the first processing result, determining whether the fourth processing result is consistent with the third processing result; if the fourth processing result is consistent with the third processing result, determining that the to-be-tested interface passes the test; if the fourth processing result is inconsistent with the third processing result, determining that the to-be-tested interface fails the test.

2. The interface test method according to claim 1, wherein before the step of obtaining the work log generated by the to-be-tested interface in the production environment, the method comprises: ​ collecting first request data of calling the to-be-tested interface in a production environment and a first calling result and a log tracking identifier generated by the to-be-tested interface after receiving the first request data; storing the first log as a working log of the to-be-tested interface generated in the production environment by an interface log storage system.

3. The interface testing method of claim 2, wherein: the first calling result comprises at least one first processing result and a third processing result; the first processing result is a processing result of the to-be-tested interface after processing the first request data in the production environment, and the third processing result is a processing result of the to-be-tested interface after processing a calling return value fed back by at least one external interface based on the first processing result, wherein the to-be-tested interface calls the external interface with the first processing result as input of the external interface in the production environment; the first log comprises a first sub-log, a second sub-log and a third sub-log; the collecting of the first request data of calling the to-be-tested interface in the production environment and the first calling result and the log tracking identifier generated by the to-be-tested interface after receiving the first request data; the step of generating the first log of the to-be-tested interface according to the first request data, the first calling result and the log tracking identifier comprises: collecting the first request data of calling the to-be-tested interface in the production environment and at least one first processing result and the log tracking identifier generated by the to-be-tested interface after receiving the first request data; and generating the first sub-log of the to-be-tested interface according to the first request data, the at least one first processing result and the log tracking identifier; collecting a calling return value generated by the external interface after receiving the first processing result, wherein the to-be-tested interface calls at least one external interface with the first processing result in the production environment; and generating the second sub-log of the to-be-tested interface according to the first processing result, the calling return value and the log tracking identifier; collecting a third processing result of the to-be-tested interface after processing the calling return value; and generating the third sub-log of the to-be-tested interface according to the calling return value, the third processing result and the log tracking identifier.

4. The interface testing method of claim 2, wherein: the step of obtaining the working log of the to-be-tested interface generated in the production environment comprises: obtaining a fourth log from an interface log storage system, wherein the fourth log is any log in the interface log storage system; determining whether the fourth log is a log of the to-be-tested interface; if yes, determining all logs including the log tracking identifier in the interface log storage system as the working log of the to-be-tested interface generated in the production environment according to the log tracking identifier of the fourth log.

5. An interface testing device, characterized by ​ The test request acquisition module is configured to acquire an interface test request. According to the interface test request, a to-be-tested interface and a test case of the to-be-tested interface are determined. The work log acquisition module is configured to acquire a work log of the to-be-tested interface generated in a production environment, wherein the work log comprises first request data for calling the to-be-tested interface in the production environment and a first calling result of the to-be-tested interface in response to the first request data. The test result obtaining module is configured to input the first request data into the to-be-tested interface according to the test case, and obtain a second calling result of the to-be-tested interface in response. The first calling result comprises a first processing result, which is a processing result of the to-be-tested interface in the production environment in response to the first request data. The second calling result comprises a second processing result, which is a processing result of the to-be-tested interface in the test environment in response to the first request data. The first calling result and the second calling result are compared to obtain a test result of the to-be-tested interface, including: if the second processing result is consistent with the first processing result, it is determined that the to-be-tested interface passes the test; if the second processing result is inconsistent with the first processing result, it is determined that the to-be-tested interface fails the test. Alternatively, the first calling result comprises at least one first processing result and a third processing result; the first processing result is a processing result of the to-be-tested interface in the production environment in response to the first request data, and the third processing result is a processing result of the to-be-tested interface in the production environment in response to a calling return value of at least one external interface based on the first processing result. The second calling result comprises a second processing result and a fourth processing result; the second processing result is a processing result of the to-be-tested interface in the test environment in response to the first request data, and the fourth processing result is a processing result of the to-be-tested interface in the test environment in response to a calling return value of at least one external interface based on the second processing result. The step of comparing the first calling result and the second calling result to obtain the test result of the to-be-tested interface comprises: If the second processing result is consistent with the first processing result, it is determined whether the fourth processing result is consistent with the third processing result. If the fourth processing result is consistent with the third processing result, it is determined that the to-be-tested interface passes the test. If the fourth processing result is inconsistent with the third processing result, it is determined that the to-be-tested interface fails the test.

6. An electronic device comprising: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 4 when executing the computer program.

7. A computer-readable storage medium storing a computer program, wherein the computer program comprises the following steps of: receiving a request for a resource from a client; determining whether the client is authorized to access the resource; and if the client is authorized to access the resource, providing the resource to the client. The computer program, which is executed by a processor, implements the steps of the method as claimed in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Interface testing method and device

    CN111552632A

  • Interface testing method, device and system and medium

    CN114003451A