Interface testing method and device, electronic equipment and storage medium

Through interface matching and traffic conversion technology, the playback test problem caused by interface changes after software system upgrade and transformation is solved, and effective testing of the system interface after technical transformation is realized, reducing testing costs and improving testing efficiency.

CN119512917APending Publication Date: 2025-02-25BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311027868.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-15
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

During the upgrade and transformation of the software system, interface changes and interface call changes have caused direct use of recorded traffic data for playback testing, and it is impossible to effectively verify the correctness of the system program.

Method used

Through interface matching and traffic conversion, the recorded historical interface traffic data is used to convert it into the test data of the target interface. During the playback test, the existing interface traffic recording data is used to simulate the calls of the existing interface, and the custom data is used to simulate the calls of the new interface.

Benefits of technology

Effectively respond to the changes in the system interface after technical transformation, reduce testing costs and labor costs, improve testing accuracy and efficiency, and make full use of recorded traffic data for playback testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512917A_ABST
    Figure CN119512917A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an interface test method and device, electronic equipment and a storage medium, and the interface test method comprises the steps: responding to a playback test request for a target interface, searching a historical interface matched with the target interface, and obtaining the traffic recording data of the historical interface; converting the traffic recording data of the historical interface into test data of a target interface; determining a calling interface of the target interface, wherein the calling interface comprises an existing interface and / or a newly added interface; and performing a playback test on the target interface by using the test data, and in the playback test process, simulating calling of the existing interface by using the traffic recording data of the existing interface, and simulating calling of the newly added interface by using the custom data. According to the invention, the recorded traffic data is shaped through interface matching and traffic conversion, and simulation calling is carried out by adopting different methods according to different types of called interfaces, so that conditions such as interface change and interface calling change can be effectively handled, the test cost is reduced, and the test efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to testing technology, and in particular to an interface testing method, device, electronic device and storage medium. Background Art

[0002] It is becoming more and more common to use the recording and playback method to test software systems. The recording and playback testing method omits the cost of building parameters and test assertions, and the process is fully automated, which can effectively improve the testing efficiency. The so-called recording and playback is to record the data generated by calling a certain interface of the system at a certain time in history and the data generated by the interface sub-calls. At a certain time in the future, the recorded data is used to call this interface of the system. The sub-calls generated during the interface execution process will be simulated using the recorded data to verify whether the system program meets expectations.

[0003] However, the software system will be constantly upgraded and modified during use. For example, the software system interface will be changed, the interface call will be changed, etc. In the process of implementing the present invention, the inventor found that due to the technical transformation, there will be many complex code modifications such as interface changes and interface call changes. It is often not feasible to directly use the recorded traffic data to replay the system interface after the technical transformation. Summary of the invention

[0004] The embodiments of the present invention provide an interface testing method, device, electronic device and storage medium, which can fully and effectively utilize recorded traffic data for playback testing, reduce testing costs and improve testing efficiency.

[0005] In a first aspect, an interface testing method provided by an embodiment of the present invention includes:

[0006] In response to a playback test request for a target interface, searching for a historical interface that matches the target interface and obtaining traffic recording data of the historical interface;

[0007] Converting the traffic recording data of the historical interface into test data of the target interface;

[0008] Determine a calling interface of the target interface, wherein the calling interface includes an existing interface and / or a newly added interface;

[0009] The target interface is replayed using the test data, and during the replay test, the traffic recording data of the existing interface is used to simulate the call to the existing interface, and the custom data is used to simulate the call to the newly added interface.

[0010] In a second aspect, an interface testing device provided by an embodiment of the present invention includes:

[0011] A response module, used to respond to a playback test request for a target interface, find a historical interface matching the target interface, and obtain traffic recording data of the historical interface;

[0012] A conversion module, used for converting the traffic recording data of the historical interface into the test data of the target interface;

[0013] A determination module, used to determine a calling interface of the target interface, wherein the calling interface includes an existing interface and / or a newly added interface;

[0014] The test module is used to use the test data to perform a playback test on the target interface, and during the playback test, use the traffic recording data of the existing interface to simulate the call to the existing interface, and use custom data to simulate the call to the newly added interface.

[0015] In a third aspect, an electronic device provided by an embodiment of the present invention comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the interface testing method as described in any embodiment of the present invention is implemented.

[0016] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the interface testing method as described in any embodiment of the present invention is implemented.

[0017] The scheme of the embodiment of the present invention can respond to a playback test request for a target interface, search for a historical interface that matches the target interface and obtain traffic recording data of the historical interface; convert the traffic recording data of the historical interface into test data of the target interface; determine a calling interface of the target interface, the calling interface includes an existing interface and / or a newly added interface; use the test data to perform a playback test on the target interface, and during the playback test, use the traffic recording data of the existing interface to simulate the call to the existing interface, and use custom data to simulate the call to the newly added interface. That is, the present invention "shapes" the recorded traffic data through interface matching and traffic conversion to make the recorded traffic data adapt to the test of the system interface after the technical transformation, which can effectively deal with the situation where the interface is modified during the technical transformation process, and can reduce the manpower cost of testers and the cost of writing test cases; for interface calls, different methods can be adopted according to the type of called interface (for example, existing interface, new interface) (for example, using the traffic recording data of the existing interface to simulate the call to the existing interface, and using custom data to simulate the call to the new interface) to simulate the call, which can effectively deal with the situation where the interface call is modified during the technical transformation process, improve the test accuracy, and the entire playback test can fully and effectively use the recorded traffic data to reduce the test cost and improve the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solution of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 It is a flowchart of the interface testing method provided by an embodiment of the present invention;

[0020] Figure 2 is another flow chart of the interface testing method provided by an embodiment of the present invention;

[0021] Figure 3 is a structural schematic diagram of an interface testing device provided by an embodiment of the present invention;

[0022] Figure 4 is a structural diagram of an interface testing system provided by an embodiment of the present invention;

[0023] Figure 5 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0026] Before introducing the scheme of the embodiment of the present invention, the playback test process is first introduced by taking an example. Assume that there are two systems A and B, and there is an interface A1 in system A. Interface A1 will call interface B1 and interface B2 of system B, then the calling relationship is A1->B1, A1->B2, and the recording will record the input and return values ​​of interfaces A1, B1, and B2. Assume that the input and return values ​​of interfaces A1, B1, and B2 recorded during recording are A1(REQ, RES), B1(REQ, RES), and B2(REQ, RES) respectively. Assuming that the calling relationship remains unchanged, during playback, the calling relationship is A1'->B1', A1'->B2', A1', B1', B2' are the simulation objects of A1, B1, B2 respectively. Generally speaking, the return value of the subcall will be simulated during playback, so the return value RES of the subcall remains unchanged, and new input and return values ​​A1'(REQ, RES'), B1'(REQ', RES), B2'(REQ', RES) are generated. A1(RES) is compared with A1'(RES'), B1(REQ) is compared with B1'(REQ'), and B2(REQ) is compared with B2'(REQ') to judge the correctness of the system program.

[0027] Ideally, using recording and playback to verify or test the system is very efficient. However, the system is not static. As the business develops, the interface and interface call relationship may change over a sufficiently long time span. In the above example, suppose the call relationship A1->B1, A1->B2 becomes A1'->B2', A1'->B3, A1'->C1 in an iteration six months later. Interface B3 is an upgraded version of interface B1, which includes the capabilities of interface B1 and provides more extended business logic. Interface C1 is a newly added call to the C system. Due to more complex code modifications such as interface replacement, new interface, interface merging, etc., it is not feasible to directly use the recorded historical version of interface A1's traffic data for the playback of the new version of interface A1'.

[0028] The following describes the solution of the embodiment of the present invention. Figure 1 As shown, Figure 1 This is a flowchart of the interface testing method provided by an embodiment of the present invention. The method can be applied in the scenario of replaying the system after technical transformation. The interface testing method can be specifically applied in an interface testing device, which can be implemented in software and / or hardware. In a specific embodiment, the interface testing device can be implemented by an electronic device, which can be a computer, a server, etc. Figure 1 The interface testing method of this embodiment may specifically include the following steps:

[0029] Step 101, responding to a playback test request for a target interface, searching for a historical interface that matches the target interface and obtaining traffic recording data of the historical interface.

[0030] For example, the target interface is the interface to be tested, and the target interface may be the interface of the system after technical transformation. When the target interface needs to be tested, the electronic device may receive a playback test request for the target interface initiated by the terminal. The playback test request is a request to test the target interface by playback using traffic recording data. The playback test request may include the interface identifier of the target interface, which may be identification information such as the interface name and interface number used to distinguish the interface. The terminal may be a mobile phone, a personal computer or other device.

[0031] Since the division of interface definition and interface responsibility boundary may not be clear in the early stage, the interface definition will be modified in the subsequent iterations, resulting in the interface before and after the system technical transformation does not correspond. Therefore, an interface mapping relationship can be maintained in advance, and the interface mapping relationship can include the mapping relationship between the interface of the system before the technical transformation (which can be represented by the interface identifier) ​​and the interface of the system after the technical transformation (which can also be represented by the interface identifier). The interface of the system before the technical transformation can be understood as an existing interface or a historical interface. The historical interface mapped by the target interface can be a mapping relationship in the interface mapping relationship, that is, the interface mapping relationship can be queried based on the interface identifier of the target interface, so as to find the historical interface matching the target interface. The historical interface matching the target interface is the historical interface mapped by the target interface found in the interface mapping relationship. There can be one or more historical interfaces matching the target interface.

[0032] Traffic recording data of historical interfaces can be obtained by recording traffic of historical interfaces in advance. For example, bytecode enhancement technology can be used to record traffic of historical interfaces. By using bytecode enhancement technology for traffic recording, surround events can be added before and after the method to capture the input parameters and return values ​​of the calling method, and the input parameters and return values ​​are serialized and persisted to the storage device to complete the recording of the method. This method can usually achieve zero intrusion on the business code.

[0033] For example, there is the following calling relationship:

[0034] ServiceA#foo

[0035] ->ServiceB#bar

[0036] Assuming that you need to record the traffic of ServiceB#bar, you can use bytecode enhancement technology to embed the surround event onMethodEnter before ServiceB#bar and the surround event onMethodExit after ServiceB#bar. At this time, the call relationship becomes:

[0037] ServiceA#foo

[0038] ->ServiceB#bar$$onMethodEnter

[0039] ->ServiceB#bar

[0040] ->ServiceB#bar$$onMethodExit

[0041] The ServiceB#bar$$onMethodEnter and ServiceB#bar$$onMethodExit methods contain logic for serialization and persistence of ServiceB#bar method parameters, thereby completing the recording of ServiceB#bar.

[0042] Of course, in actual applications, other methods can also be used to record traffic, which are not specifically limited here.

[0043] Step 102: Convert the traffic recording data of the historical interface into test data of the target interface.

[0044] In actual applications, the traffic recording data of the historical interface can be retrieved from the storage device, and the retrieved traffic recording data can be deserialized to parse the input parameters and return values ​​of the historical interface, the calling interface of the historical interface, and the input parameters and return values ​​of the calling interface, etc., so as to be used for playback testing.

[0045] During the process of technical transformation, interfaces may be split or merged, the data type supported by the interfaces may change, the interface class may change, etc. Therefore, the traffic recording data of the parsed historical interfaces may not be directly used for playback testing. The parsed traffic recording data of the historical interfaces need to be split, merged, data type transformed, assembled and packaged, etc., so that the traffic recording data of the historical interfaces can adapt to the playback test of the target interface.

[0046] Step 103: determine the calling interface of the target interface, where the calling interface includes an existing interface and / or a newly added interface.

[0047] The target interface may have one or more calling interfaces, and the calling interfaces may be classified into existing interfaces and newly added interfaces, that is, the calling interfaces of the target interface may include existing interfaces of the system before the technical transformation, or interfaces that the system did not have before the technical transformation (i.e. newly added interfaces), or may include both existing interfaces and newly added interfaces. Existing interfaces have traffic recording data, while newly added interfaces do not have traffic recording data.

[0048] Step 104, perform a playback test on the target interface using the test data, and during the playback test, use the traffic recording data of the existing interface to simulate the call to the existing interface, and use the custom data to simulate the call to the newly added interface.

[0049] Simulate (i.e. mock) interface calls, i.e. simulate the interface call return result. Simulating interface calls can reduce external dependence, speed up testing, reduce testing costs, and can also improve test coverage, facilitate timely discovery of problems, support parallel testing, and improve testing efficiency. Specifically in this embodiment, during the playback test of the target interface, if the target interface needs to call other interfaces, it can be processed by simulating interface calls. Specifically, if the calling interface of the target interface is an existing interface, the traffic recording data pre-recorded for the existing interface can be used to simulate the call to the existing interface. If the calling interface of the target interface is a newly added interface, custom data can be used to simulate the call to the newly added interface. The custom data can be a custom interface call return value.

[0050] Using the traffic recording data of existing interfaces to simulate calls to existing interfaces can reduce the cost of writing and executing test cases, make full use of existing test resources and test data, accurately simulate the actual calls to existing interfaces, and reduce testing costs. Using custom data to simulate calls to new interfaces can avoid a lot of test case writing and debugging costs, better simulate calls to unknown interfaces, and thus improve test coverage and comprehensiveness. Using different methods to simulate calls to different types of interfaces can better adapt to different test scenarios and test requirements, improve test efficiency and test accuracy, and reduce test costs.

[0051] In actual applications, the test data of the target interface may include the historical return value corresponding to the target interface (which may be the actual return value of the corresponding historical interface recorded). After the target interface is replayed using the test data, the current return value of the target interface can be obtained. The current return value and the historical return value of the target interface can be compared to obtain return value difference information. The test result of the target interface can be determined based on the return value difference information, and the test result of the target interface can be fed back to the terminal.

[0052] The solution of this embodiment can respond to a playback test request for a target interface, search for a historical interface that matches the target interface and obtain traffic recording data of the historical interface; convert the traffic recording data of the historical interface into test data of the target interface; determine a calling interface of the target interface, the calling interface includes an existing interface and / or a newly added interface; use the test data to perform a playback test on the target interface, and during the playback test, use the traffic recording data of the existing interface to simulate a call to the existing interface, and use custom data to simulate a call to the newly added interface. That is, the present invention "shapes" the recorded traffic data through interface matching and traffic conversion to make the recorded traffic data adapt to the test of the system interface after the technical transformation, which can effectively deal with the situation where the interface is modified during the technical transformation process, and can reduce the manpower cost of testers and the cost of writing test cases; for interface calls, different methods can be used according to the type of called interface (for example, existing interface, new interface) (for example, using the traffic recording data of the existing interface to simulate the call to the existing interface, and using custom data to simulate the call to the new interface) to simulate the call, which can effectively deal with the situation where the interface call is modified during the technical transformation process, improve the test accuracy, and the entire playback test can fully and effectively use the recorded traffic data to reduce the test cost and improve the test efficiency.

[0053] The interface testing method provided by the embodiment of the present invention is further described below. Figure 2 As shown, the method of this embodiment may include:

[0054] Step 201, responding to a playback test request for a target interface, searching for a historical interface that matches the target interface.

[0055] The target interface may be the interface of the system after the technical transformation, and the playback test request is a request to test the target interface by playback using traffic recording data. Specifically, the historical interface matching the target interface can be found by querying the interface mapping relationship. The interface mapping relationship may include the mapping relationship between the interface of the system before the technical transformation and the interface of the system after the technical transformation. The interface of the system before the technical transformation can be understood as an existing interface or a historical interface. There may be one or more historical interfaces matching the target interface found.

[0056] For example, if the interface definition is not clear in the early stage, and the interface ServiceA#foo is changed to interface ServiceB#bar in the subsequent iteration, the interface mapping relationship ServiceA#foo->ServiceB#bar can be set, and the historical interface matched by the target interface ServiceB#bar is interface ServiceA#foo.

[0057] Step 202, obtaining the traffic recording data of the historical interface.

[0058] The traffic recording data of the historical interface can be retrieved from the storage device, and the retrieved traffic recording data can be deserialized to parse the input parameters and return values ​​of the historical interface, the calling interface of the historical interface, and the input parameters and return values ​​of the calling interface, so as to be used for playback testing.

[0059] Step 203: Convert the traffic recording data of the historical interface into test data of the target interface.

[0060] In the specific implementation, the traffic recording data of the historical interface is converted into the test data of the target interface. There may be the following situations:

[0061] The first type requires data splitting, merging, etc. That is, when the target interface is an interface obtained by splitting a historical interface, the traffic recording data of the historical interface can be split to obtain the test data of the target interface; when the target interface is an interface obtained by merging multiple historical interfaces, the traffic recording data of multiple historical interfaces can be merged to obtain the test data of the target interface.

[0062] In technical transformation, it is very common to split a large interface into multiple small interfaces and merge small interfaces into one large interface. For recording and playback, the former is to use the traffic recording data of one interface for playback of multiple interfaces, while the latter is to use the traffic recording data of multiple interfaces for playback of one interface. In essence, it is a one-to-many or many-to-one mapping relationship of interfaces, which is a variant of traffic adaptation.

[0063] In actual applications, when the target interface is an interface obtained by splitting a historical interface, the traffic recording data of the historical interface can be split, and the traffic recording data corresponding to the target interface can be obtained from the split data, and the traffic recording data corresponding to the target interface can be used as the test data of the target interface, and the test data can include the historical input parameters and historical return values ​​corresponding to the target interface. When the target interface is an interface obtained by merging multiple historical interfaces, the traffic recording data of multiple historical interfaces can be merged, and the merged data can be used as the test data of the target interface. The historical input parameters corresponding to the target interface in the test data can be the merged input parameter data of multiple historical interfaces, and the historical return value corresponding to the target interface in the test data can be the merged return value data of multiple historical interfaces.

[0064] The second type requires data type conversion. For example, if the data type supported by the historical interface is the first data type and the data type supported by the target interface is the second data type, then the traffic recording data of the first data type of the historical interface needs to be converted into the traffic recording data of the second data type, thereby obtaining the test data of the target interface.

[0065] For example, the data type supported by the historical interface is the string type (i.e., String param), and the data type supported by the target interface is the integer type (i.e., Integer param). That is, the traffic recording data of the historical interface is of string type, then the traffic recording data of string type needs to be converted into traffic recording data of integer type.

[0066] The third type requires data mapping assembly. That is, the data assembly path needs to be determined according to the data mapping relationship, which includes the mapping relationship between the data required by the historical interface and the data required by the target interface; the flow recording data of the historical interface is assembled to the target interface according to the data assembly path to obtain the test data of the target interface.

[0067] In software systems, some classes are used as public parameters. The changes and replacements of these classes have a wide impact. From the essence of code modification, one class is replaced by another class, which is a one-to-one mapping. In practical applications, data mapping relationships can be set for this situation, and the classes of the target interface into which the classes of the historical interface should be loaded are determined based on the data mapping relationships. For example, the attribute name of a class in the historical interface is id, which is too vague to reflect the ownership. During the technical transformation, the attribute name of the class in the historical interface is changed to product id, and the data mapping relationship will include id->product id. According to the data mapping relationship, it can be determined that the id data of the class in the historical interface should be assembled into the product id item of the class in the target interface.

[0068] In actual applications, one or more of the above situations may occur, and the corresponding conversion processing solution can be selected according to the actual situation.

[0069] Step 204: determine the calling interface of the target interface, where the calling interface includes an existing interface and / or a newly added interface.

[0070] The target interface may have one or more calling interfaces, and the calling interfaces may be classified into existing interfaces and newly added interfaces, that is, the calling interfaces of the target interface may include existing interfaces of the system before the technical transformation, or interfaces that the system did not have before the technical transformation (i.e. newly added interfaces), or may include both existing interfaces and newly added interfaces. Existing interfaces have traffic recording data, while newly added interfaces do not have traffic recording data.

[0071] Step 205, perform playback test on the target interface using the test data. During the playback test, if an existing interface needs to be called, execute step 206; if a newly added interface needs to be called, execute step 209.

[0072] When using test data to replay the target interface, the input parameters in the test data can be used as the input parameters of the target interface. During the test, an interface call needs to be initiated.

[0073] Step 206: Determine fixed parameters of the existing interface.

[0074] When the interface being called is an existing interface, the input parameters of the existing interface may include fixed parameters and non-fixed parameters. The so-called fixed parameters may refer to parameters with fixed values, and non-fixed parameters may refer to parameters with non-fixed values. For example, the parameter of an interface is student, and students have attributes such as name, age, and score. Among them, the values ​​of age and score are dynamically changing values, and the name is a fixed value. Then the fixed parameter of the interface can be the student's name. In a specific implementation, testers or developers can identify, classify, and mark the parameters of existing interfaces in advance. The categories can include fixed parameters and non-fixed parameters. During the test process, the fixed parameters of the existing interface can be determined based on the classification mark.

[0075] Step 207: Obtain the traffic recording data of the existing interface according to the fixed parameters, and use the traffic recording data of the existing interface to simulate the call to the existing interface.

[0076] That is, the fixed parameter values ​​can be obtained from the traffic recording data of the existing interface, and the fixed parameter values ​​can be used as the result returned by simulating the call to the existing interface. When using non-fixed parameter values ​​to simulate the call to the existing interface, the simulated data may not be matched from the traffic recording data of the existing interface due to the change of parameter values, which may lead to the failure to simulate the call to the existing interface. However, using fixed parameter values ​​to simulate the call to the existing interface can avoid the failure of obtaining simulated data, increase the success rate of obtaining simulated data, and thus improve the success rate of simulating the call to the existing interface.

[0077] Step 208: When the simulation result of simulating the call to the existing interface is a failure, the playback test request is marked as an invalid request.

[0078] During the technical transformation, the historical interface may be upgraded to a target interface that is completely incompatible with the historical interface. The reason for the incompatibility may be that different systems, tools or software use different encoding methods, data protocols, etc. In this case, the test method of using recorded data to play back the target interface is not feasible, that is, when using traffic recording data to simulate the call to the existing interface, the result of the simulated call will be a failure, and other testing methods need to be considered. In actual applications, when the simulation result of simulating the call to the existing interface is a failure, the solution provided by the present invention can be discontinued for testing, and the playback test request can be marked as an invalid request to avoid this test being counted as a test failure, thereby avoiding unnecessary troubleshooting workload. For playback test requests marked as invalid requests, other methods can be used to test the target interface.

[0079] Step 209, determine the calling strategy for the newly added interface, if the calling strategy is direct calling, execute step 210, if the calling strategy is simulated calling, execute step 211.

[0080] Testers or developers can pre-set the calling strategy for the newly added interface based on experiments or experience. The calling strategy can include direct calling and simulated calling. For example, in some cases, it may not be possible to complete the test process by simulating calling the newly added interface, that is, the test of the target interface cannot avoid the direct call of the newly added interface, then the calling strategy for the newly added interface can be set to direct calling; if it is found through experiments or experience that the test process can be completed by simulating calling the newly added interface, then the calling strategy for the newly added interface can be set to simulated calling.

[0081] Step 210, directly call the newly added interface.

[0082] That is, a call is initiated to the real newly added interface. Direct call can also be called penetration, that is, no simulation call is made.

[0083] Step 211, using the custom data to simulate the call to the newly added interface.

[0084] In actual applications, when using custom data to simulate the call to the newly added interface, you can use any of the following methods:

[0085] The first method: Use the fixed return value customized for the new interface to simulate the call to the new interface.

[0086] The second method: Use custom data generation logic to generate dynamic return values ​​for the newly added interface, and use the dynamic return values ​​to simulate calls to the newly added interface.

[0087] The first method is equivalent to hard-coding the return value of the interface call, which is suitable for situations where the interface return value is simple. The second method is equivalent to generating a dynamically variable return value for the interface call, which is suitable for situations where the interface return value is relatively complex. In actual applications, the call to the newly added interface can be simulated according to the pre-set or selected simulation method.

[0088] After the test, the current return value of the target interface can be obtained. If the target interface is an interface obtained by splitting a historical interface, the current return value of the target interface can be compared with a portion of the return values ​​of the historical interface (i.e., the return value of the sub-interface corresponding to the target interface in the historical interface) to obtain a comparison result; if the target interface is an interface obtained by merging multiple historical interfaces, the current return value of the target interface can be compared with the combined return value data of multiple historical interfaces to obtain a comparison result; the test result of the target interface can be determined based on the comparison result, and the test result of the target interface can be fed back to the terminal.

[0089] In addition, after the test, if the preset result comparison logic finds that the traffic recording data obtained by this playback is insufficient to complete the comparison, the playback test request can be marked as an invalid request.

[0090] The solution of this embodiment can respond to a playback test request for a target interface, search for a historical interface that matches the target interface and obtain traffic recording data of the historical interface; convert the traffic recording data of the historical interface into test data of the target interface; determine a calling interface of the target interface, the calling interface includes an existing interface and / or a newly added interface; use the test data to perform a playback test on the target interface, and during the playback test, use the traffic recording data of the existing interface to simulate a call to the existing interface, and use custom data to simulate a call to the newly added interface. That is, the present invention "shapes" the recorded traffic data through interface matching and traffic conversion to make the recorded traffic data adapt to the test of the system interface after the technical transformation, which can effectively deal with the situation where the interface is modified during the technical transformation process, and can reduce the manpower cost of testers and the cost of writing test cases; for interface calls, different methods can be used according to the type of called interface (for example, existing interface, new interface) (for example, using the traffic recording data of the existing interface to simulate the call to the existing interface, and using custom data to simulate the call to the new interface) to simulate the call, which can effectively deal with the situation where the interface call is modified during the technical transformation process, improve the test accuracy, and the entire playback test can fully and effectively use the recorded traffic data to reduce the test cost and improve the test efficiency.

[0091] It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0092] Figure 3 is a schematic diagram of the structure of an interface testing device provided by an embodiment of the present invention, such as Figure 3 As shown, the device may specifically include:

[0093] The response module 301 is used to respond to the playback test request for the target interface, find the historical interface matching the target interface and obtain the traffic recording data of the historical interface;

[0094] A conversion module 302, used to convert the traffic recording data of the historical interface into the test data of the target interface;

[0095] A determination module 303 is used to determine a calling interface of the target interface, wherein the calling interface includes an existing interface and / or a newly added interface;

[0096] The test module 304 is used to perform a playback test on the target interface using the test data, and during the playback test, use the traffic recording data of the existing interface to simulate the call to the existing interface, and use custom data to simulate the call to the newly added interface.

[0097] In one embodiment, the conversion module 302 is specifically used for:

[0098] When the target interface is an interface obtained by splitting the historical interface, splitting the traffic recording data of the historical interface to obtain the test data of the target interface;

[0099] When the target interface is an interface obtained by merging multiple historical interfaces, the traffic recording data of the multiple historical interfaces are merged to obtain the test data of the target interface.

[0100] In one embodiment, the data type supported by the history interface is a first data type, and the data type supported by the target interface is a second data type. The conversion module 302 is specifically configured to:

[0101] The traffic recording data of the first data type of the historical interface is converted into traffic recording data of the second data type to obtain the test data of the target interface.

[0102] In one embodiment, the conversion module 302 is specifically used for:

[0103] Determine a data assembly path according to a data mapping relationship, wherein the data mapping relationship includes a mapping relationship between data required by the historical interface and data required by the target interface;

[0104] The flow recording data of the historical interface is assembled to the target interface according to the data assembly path to obtain the test data of the target interface.

[0105] In one embodiment, the test module 304 uses the traffic recording data of the existing interface to simulate the call of the existing interface, including:

[0106] Determining fixed parameters of the existing interface, wherein the fixed parameters include parameters having fixed values;

[0107] The traffic recording data of the existing interface is obtained according to the fixed parameters, and the traffic recording data of the existing interface is used to simulate the call to the existing interface.

[0108] In one embodiment, before the test module 304 uses the custom data to simulate the call to the newly added interface, it also includes:

[0109] Determine a calling strategy for the newly added interface;

[0110] If the calling strategy is a simulated call, the calling of the newly added interface by using the custom data simulation is triggered.

[0111] In one embodiment, after determining the calling strategy for the newly added interface, the testing module 304 further includes:

[0112] If the calling strategy is direct calling, the newly added interface is called directly.

[0113] In one embodiment, the testing module 304 simulates the call to the newly added interface using the custom data, including:

[0114] Simulate the call to the newly added interface by using a fixed return value customized for the newly added interface;

[0115] Alternatively, a custom data generation logic is used to generate a dynamic return value for the newly added interface, and the dynamic return value is used to simulate the call to the newly added interface.

[0116] In one embodiment, the device further comprises:

[0117] The marking module is used to mark the playback test request as an invalid request when the simulation result of simulating the call to the existing interface is a failure.

[0118] In one embodiment, the response module 301 searches for a historical interface that matches the target interface, including:

[0119] The historical interface matching the target interface is found by querying the interface mapping relationship, wherein the interface mapping relationship includes the historical interface mapped by the target interface.

[0120] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the functional modules described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0121] The device of the embodiment of the present invention can respond to a playback test request for a target interface, search for a historical interface that matches the target interface and obtain traffic recording data of the historical interface; convert the traffic recording data of the historical interface into test data of the target interface; determine a calling interface of the target interface, the calling interface includes an existing interface and / or a newly added interface; use the test data to perform a playback test on the target interface, and during the playback test, use the traffic recording data of the existing interface to simulate the call to the existing interface, and use custom data to simulate the call to the newly added interface. That is, the present invention "shapes" the recorded traffic data through interface matching and traffic conversion to make the recorded traffic data adapt to the test of the system interface after the technical transformation, which can effectively deal with the situation where the interface is modified during the technical transformation process, and can reduce the manpower cost of testers and the cost of writing test cases; for interface calls, different methods can be used according to the type of called interface (for example, existing interface, new interface) (for example, using the traffic recording data of the existing interface to simulate the call to the existing interface, and using custom data to simulate the call to the new interface) to simulate the call, which can effectively deal with the situation where the interface call is modified during the technical transformation process, improve the test accuracy, and the entire playback test can fully and effectively use the recorded traffic data to reduce the test cost and improve the test efficiency.

[0122] An embodiment of the present invention 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 interface testing method provided in any of the above embodiments when executing the program.

[0123] An embodiment of the present invention further provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the interface testing method provided by any of the above embodiments is implemented.

[0124] Figure 4 An exemplary system architecture 400 is shown to which the interface testing method or interface testing device according to the embodiment of the present invention can be applied.

[0125] like Figure 4 As shown, system architecture 400 may include terminals 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminals 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0126] Users can use terminals 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Various client applications can be installed on terminals 401, 402, 403, such as enterprise application clients, e-commerce application clients, web browser applications, search applications, instant messaging tools, and email clients.

[0127] Terminals 401, 402, and 403 may be various terminals having display screens and supporting various clients, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0128] The server 405 may be a server that provides various services, such as a background server that provides support for playback test requests sent by users using the terminals 401, 402, and 403. The background server may process the received playback test requests and feed back the processing results to the terminals.

[0129] It should be noted that the interface testing method provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the interface testing device is generally disposed in the server 405 .

[0130] It should be understood that Figure 4 The number of terminals, networks and servers in the embodiment is only for illustration. Any number of terminals, networks and servers may be provided according to the implementation requirements.

[0131] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of an electronic device suitable for implementing an embodiment of the present invention. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0132] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the computer system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0133] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.

[0134] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.

[0135] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0136] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0137] The modules and / or units involved in the description of the present invention may be implemented by software or hardware. The modules and / or units described may also be arranged in a processor, for example, it may be described as follows: a processor includes a response module, a conversion module, a determination module and a test module. The names of these modules do not constitute limitations on the modules themselves in some cases.

[0138] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:

[0139] In response to a playback test request for a target interface, a historical interface matching the target interface is searched and traffic recording data of the historical interface is obtained; the traffic recording data of the historical interface is converted into test data of the target interface; a calling interface of the target interface is determined, wherein the calling interface includes an existing interface and / or a newly added interface; a playback test is performed on the target interface using the test data, and during the playback test, a call to the existing interface is simulated using the traffic recording data of the existing interface, and a call to the newly added interface is simulated using custom data.

[0140] According to the technical solution of the present invention, it is possible to respond to a playback test request for a target interface, find a historical interface that matches the target interface and obtain traffic recording data of the historical interface; convert the traffic recording data of the historical interface into test data of the target interface; determine the calling interface of the target interface, the calling interface includes an existing interface and / or a newly added interface; use the test data to perform a playback test on the target interface, and during the playback test, use the traffic recording data of the existing interface to simulate the call to the existing interface, and use custom data to simulate the call to the newly added interface. That is, the present invention "shapes" the recorded traffic data through interface matching and traffic conversion to make the recorded traffic data adapt to the test of the system interface after the technical transformation, which can effectively deal with the situation where the interface is modified during the technical transformation process, and can reduce the manpower cost of testers and the cost of writing test cases; for interface calls, different methods can be used according to the type of called interface (for example, existing interface, new interface) (for example, using the traffic recording data of the existing interface to simulate the call to the existing interface, and using custom data to simulate the call to the new interface) to simulate the call, which can effectively deal with the situation where the interface call is modified during the technical transformation process, improve the test accuracy, and the entire playback test can fully and effectively use the recorded traffic data to reduce the test cost and improve the test efficiency.

[0141] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0142] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.

[0143] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. An interface testing method, characterized in that: include: In response to a playback test request for a target interface, searching for a historical interface that matches the target interface and obtaining traffic recording data of the historical interface; Converting the traffic recording data of the historical interface into test data of the target interface; Determine a calling interface of the target interface, wherein the calling interface includes an existing interface and / or a newly added interface; The target interface is replayed using the test data, and during the replay test, the traffic recording data of the existing interface is used to simulate the call to the existing interface, and the custom data is used to simulate the call to the newly added interface.

2. The interface testing method according to claim 1, characterized in that: The converting the traffic recording data of the historical interface into the test data of the target interface includes: When the target interface is an interface obtained by splitting the historical interface, splitting the traffic recording data of the historical interface to obtain the test data of the target interface; When the target interface is an interface obtained by merging multiple historical interfaces, the traffic recording data of the multiple historical interfaces are merged to obtain the test data of the target interface.

3. The interface testing method according to claim 1, characterized in that: The data type supported by the history interface is a first data type, the data type supported by the target interface is a second data type, and the converting of the traffic recording data of the history interface into the test data of the target interface includes: The traffic recording data of the first data type of the historical interface is converted into traffic recording data of the second data type to obtain the test data of the target interface.

4. The interface testing method according to claim 1, characterized in that: The converting the traffic recording data of the historical interface into the test data of the target interface includes: Determine a data assembly path according to a data mapping relationship, wherein the data mapping relationship includes a mapping relationship between data required by the historical interface and data required by the target interface; The flow recording data of the historical interface is assembled to the target interface according to the data assembly path to obtain the test data of the target interface.

5. The interface testing method according to claim 1, characterized in that: The using the traffic recording data of the existing interface to simulate the call of the existing interface includes: Determining fixed parameters of the existing interface, wherein the fixed parameters include parameters having fixed values; The traffic recording data of the existing interface is obtained according to the fixed parameters, and the traffic recording data of the existing interface is used to simulate the call to the existing interface.

6. The interface testing method according to claim 1, characterized in that: Before using the custom data to simulate the call to the newly added interface, the method further includes: Determine a calling strategy for the newly added interface; If the calling strategy is a simulated call, the calling of the newly added interface by using the custom data simulation is triggered.

7. The interface testing method according to claim 6, characterized in that: After determining the calling strategy for the newly added interface, the method further includes: If the calling strategy is direct calling, the newly added interface is called directly.

8. The interface testing method according to claim 6, characterized in that: The using of the custom data to simulate the call to the newly added interface includes: Simulate the call to the newly added interface by using a fixed return value customized for the newly added interface; Alternatively, a custom data generation logic is used to generate a dynamic return value for the newly added interface, and the dynamic return value is used to simulate the call to the newly added interface.

9. The interface testing method according to claim 1, characterized in that: After simulating the call to the existing interface by using the traffic recording data of the existing interface, the method further includes: When the simulation result of simulating the call to the existing interface is failure, the playback test request is marked as an invalid request.

10. The interface testing method according to claim 1, characterized in that: The searching for a historical interface that matches the target interface includes: The historical interface matching the target interface is found by querying the interface mapping relationship, wherein the interface mapping relationship includes the historical interface mapped by the target interface.

11. An interface testing device, characterized in that: include: A response module, used to respond to a playback test request for a target interface, find a historical interface matching the target interface, and obtain traffic recording data of the historical interface; A conversion module, used for converting the traffic recording data of the historical interface into the test data of the target interface; A determination module, used to determine a calling interface of the target interface, wherein the calling interface includes an existing interface and / or a newly added interface; The test module is used to use the test data to perform a playback test on the target interface, and during the playback test, use the traffic recording data of the existing interface to simulate the call to the existing interface, and use custom data to simulate the call to the newly added interface.

12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the interface testing method according to any one of claims 1 to 10 is implemented.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the interface testing method according to any one of claims 1 to 10 is implemented.