Interface testing method, device, server and storage medium

By automatically comparing interface information and generating test cases, the frequent writing of test cases caused by interface information changes is solved, which improves development efficiency and testing efficiency and reduces costs.

CN111538651BActive Publication Date: 2025-01-10CHINA PING AN LIFE INSURANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010234220.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-30
Publication Date
2025-01-10
Estimated Expiration
2040-03-30

AI Technical Summary

Technical Problem

During the software development process, with the change of business needs, interface information is frequently changed, resulting in frequent rewriting of test cases, resulting in increased communication costs between the developer and the tester, low efficiency in generating test cases, and low efficiency in relying on labor.

Method used

By obtaining the interface information in the target code, comparing it with the information in the database, automatically determining the interface for information changes, and generating corresponding test cases for functional testing to improve development efficiency.

Benefits of technology

It realizes automated generation of test cases, reduces the dependence of manual writing, improves the efficiency of interface testing, and reduces development and testing costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111538651B_ABST
    Figure CN111538651B_ABST
Patent Text Reader

Abstract

The present application provides an interface testing method, device, server and storage medium, wherein the method comprises: obtaining a target code, wherein the target code comprises information of each interface in at least one interface; obtaining information of each interface from the target code; comparing the information of each interface with information of interfaces included in a first database, and determining interfaces with information changes according to the comparison result; obtaining test cases of the interfaces with information changes, wherein the test cases are used to test the functions of the interfaces with information changes. The present application can improve development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an interface testing method, device, server and storage medium. Background Art

[0002] Each system service in the software development process does not exist independently, but needs to rely on or be relied upon by other systems to jointly complete the service to users. In the system development and testing process, after the developer develops the code, it sends the code to the tester for testing. When the tester is testing, it can call the interface associated with the code by running the test case of the interface associated with the code to complete the test of the code. The test case can be written and provided by the developer, or it can be written by the tester himself.

[0003] However, as business requirements change, interface information often changes, which means that test cases for interfaces with changed interface information often need to be rewritten. In this case, whether the developer provides or the tester writes the test cases themselves, there are some problems. If the tester writes the test cases themselves, although it can reduce the developer's workload and does not require additional support from the developer, it requires the tester to have coding skills and a deeper understanding of code development, which leads to a large learning span for the tester, making this method difficult to implement in reality. If the developer provides the test cases, it will bring a lot of extra work to the developer and increase the communication cost between the developer and the tester. It can be seen that in this case, whether the developer or the tester does this, it will bring unnecessary costs. It relies too much on manual labor, resulting in low efficiency in generating test cases, which in turn reduces development efficiency. Summary of the invention

[0004] The embodiments of the present application provide an interface testing method, device, server and storage medium, which can improve development efficiency.

[0005] In a first aspect, an embodiment of the present application provides an interface testing method, comprising:

[0006] Acquire a target code, wherein the target code includes information of each interface of at least one interface;

[0007] Acquire information of each interface from the target code;

[0008] Comparing the information of each interface with the information of interfaces included in the first database, and determining the interface with information change according to the comparison result;

[0009] A test case of the interface with information change is obtained, where the test case is used to test the function of the interface with information change.

[0010] Optionally, obtaining the target code includes:

[0011] When receiving a code update message for the target code sent by the code hosting device, obtaining the target code from the code hosting device; or,

[0012] The target code sent by the receiving terminal device.

[0013] Optionally, acquiring the information of each interface from the target code includes:

[0014] Acquire, by a preset script, an external header file included in the target code, wherein the external header file includes information of each interface in the at least one interface;

[0015] A regular matching algorithm is called to obtain information of each interface from the external header file.

[0016] Optionally, the method further comprises:

[0017] Determine the type of the interface whose information is changed according to the information of the interface whose information is changed;

[0018] According to the correspondence between the interface type and the test scenario, determine the target test scenario corresponding to the type of the interface with information change; wherein the target test scenario includes at least one of the following: a normal test scenario, an abnormal test scenario, and a stress test scenario;

[0019] The test case of the interface for obtaining the existence information change includes:

[0020] A test case of the interface with information change in the target test scenario is obtained.

[0021] Optionally, after obtaining the test case of the interface with information change, the method further includes:

[0022] Updating the test cases of the interface with information changes to a second database; the second database includes test cases for each of the multiple interfaces;

[0023] Determining a test case for a first interface from a second database; the first interface is not within the at least one interface;

[0024] The test cases of the first interface included in the second database are deleted.

[0025] Optionally, the obtaining of the test case of the interface having the information changed includes:

[0026] When it is found that the second database includes the test case of the interface with information change, the test case of the interface with information change is acquired from the second database;

[0027] When it is found that the second database does not include the test case of the interface with information change, a blank test case of the interface with information change is generated, and the test case of the interface with information change is obtained according to the blank test case.

[0028] Optionally, after acquiring the test case of the interface with information change from the second database, the method further includes:

[0029] Calling an object acquisition method to acquire information of each interface included in the test case of the interface with information change;

[0030] The information of the interface with information change is matched with the information of each interface included in the test case of the interface with information change, and the test case of the interface with information change is updated according to the matching result.

[0031] In a second aspect, an embodiment of the present application provides an interface testing device, including:

[0032] An acquisition module, used for acquiring a target code, wherein the target code includes information of each interface in at least one interface;

[0033] The acquisition module is further used to acquire the information of each interface from the target code;

[0034] A processing module, used for comparing the information of each interface with the information of interfaces included in the first database, and determining the interface with information change according to the comparison result;

[0035] The acquisition module is further used to obtain a test case of the interface with information change, and the test case is used to test the function of the interface with information change.

[0036] In a third aspect, an embodiment of the present application provides a server comprising a processor and a memory, wherein the processor and the memory are interconnected, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method described in the first aspect.

[0037] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method described in the first aspect.

[0038] To summarize, the server can obtain the target code, which includes information of each interface in at least one interface, and obtain the information of each interface from the target code; the server can compare the information of each interface with the information of the interfaces included in the first database, and determine the interface with information changes based on the comparison result, so as to obtain a test case for the interface with information changes, and the test case is used to test the function of the interface with information changes, thereby improving development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 It is a flowchart of an interface testing method provided in an embodiment of the present application;

[0041] Figure 2 It is a flowchart of another interface testing method provided in an embodiment of the present application;

[0042] Figure 3 is a structural schematic diagram of an interface testing device provided in an embodiment of the present application;

[0043] Figure 4 It is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0044] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0045] In order to solve the problems of the prior art, an embodiment of the present application provides an interface testing solution, which can obtain the target code and analyze the interface that needs to be functionally tested based on the target code, that is, determine the interface with information changes, thereby obtaining a test case for the interface with information changes, so as to test the function of the interface with information changes. The embodiment of the present application uses an incremental method to generate test cases, which can improve the efficiency of test case generation, thereby effectively improving development efficiency.

[0046] See also Figure 1 , is a flow chart of an interface testing method provided in an embodiment of the present application. The method can be applied to a server. The server can be a server or a server cluster. Specifically, the method can include the following steps:

[0047] S101. Obtain a target code, where the target code includes information of each interface in at least one interface.

[0048] The interface may be represented by a function, and the information of the interface may include a function name and parameters.

[0049] In one embodiment, the server may obtain the target code in such a manner that when the server receives a code update message for the target code sent by the code hosting device, the server obtains the target code from the code hosting device. In this manner, the server can obtain the latest code in a timely manner when the code is changed, and further the server can obtain the latest code test cases in a timely manner for interface function testing, thereby improving the efficiency of interface function testing.

[0050] In one application scenario, code developers can host target codes in GitLab through terminal devices. Among them, GitLab's Git Hooks function can be used to send code update messages for target codes to the server. When the server receives the code update message for target codes sent by GitLab, it can obtain the target code from GitLab.

[0051] In one embodiment, in addition to obtaining the target code through the code hosting device, the terminal can also send the target code to the server, so that the server can also receive the target code sent by the terminal device. In this way, the speed at which the server obtains the target code can be improved. S102, obtain the information of each interface from the target code.

[0052] In an embodiment of the present application, the server can obtain the information of each interface from the target code after obtaining the target code.

[0053] In one embodiment, the target code may include an external header file. The external header file may also be called an external interface header file, an external interface header file, etc. The external header file may include a definition of each of at least one interface used by the target code. The server may obtain the external header file included in the target code, and obtain information of each of the at least one interface from the external header file.

[0054] In one embodiment, the server may obtain the external header files included in the target code by using a preset script. In one embodiment, the server may obtain the external header files included in the target code from a specified directory, such as a public directory, through a preset script.

[0055] In one embodiment, the server may obtain the information of each interface in the at least one interface from the external header file by invoking a regular matching algorithm to obtain the information of each interface from the external header file. The regular matching algorithm may also be called a regular expression algorithm, a regular expression matching algorithm, and the like.

[0056] S103: Compare the information of each interface with the information of interfaces included in the first database, and determine the interface with information change according to the comparison result.

[0057] In an embodiment of the present application, the server may compare the information of each interface with the information of the interface included in the first database to obtain a comparison result, and may determine the interface with information changes based on the comparison result. In one embodiment, the information of the interface included in the first database may refer to the information of each interface included in the previous version code corresponding to the target code. Among them, the interface with information changes can be divided into the following categories: newly added interface, deleted interface, and modified interface.

[0058] For example, the at least one interface includes interface 1, interface 2, and interface 3, and the first database includes information on interface 2 and interface 3. The server can compare the information on interface 1 and interface 2 included in the target code with the information on interface 2 and interface 3 included in the first database, and determine that the newly added interface is interface 1 based on the comparison result, and determine interface 1 as the interface with information changes.

[0059] In one embodiment, the server compares the information of each interface with the information of the interface included in the first database, which can be performed by the server traversing and comparing the information of each interface with the information of the interface included in the first database. Through the traversing and comparing, the interface with information change can be quickly determined.

[0060] S104: Obtain a test case for the interface with information change, where the test case is used to test a function of the interface with information change.

[0061] In one embodiment, after obtaining the test case of the interface with information change, the server may send the test case to an electronic device corresponding to the tester, which may be a terminal or a server.

[0062] In one embodiment, the server may generate a blank test case for the interface with information change, and obtain a test case for the interface with information change according to the blank test case.

[0063] In one embodiment, the server may query whether the second database includes the test case of the interface with information change, and when the query finds that the second database does not include the test case of the interface with information change, generate a blank test case of the interface with information change, thereby obtaining the test case of the interface with information change according to the blank test case. The second database refers to a database for storing test cases, and the second database may include test cases corresponding to each of the multiple interfaces.

[0064] In one embodiment, the server obtains the test case of the interface with information changes based on the blank test case, can generate test code for the blank test case for the server, add the test code to the blank test case, and use the test case with the added test code as the test case of the interface with information changes.

[0065] In one embodiment, the server can automatically generate test code for the blank test case when running the blank test case. For example, the server can generate test code for the blank test case according to a preset generation rule. The generation rule specifies a code rule for generating the test case, so the test code for the blank test case can be automatically generated according to the generation rule.

[0066] In one embodiment, the server can determine the type of the interface with information change according to the information of the interface with information change, and determine the target test scenario corresponding to the type of the interface with information change according to the correspondence between the type of the interface and the test scenario; the server obtains the test case corresponding to the interface with information change under the target test scenario, wherein the test scenario can be at least one of the following: normal test scenario, abnormal test scenario, and stress test scenario. In one embodiment, the server can obtain an interface type mapping table, which includes the type corresponding to the information of each interface in a plurality of interfaces. Accordingly, the server can query the type corresponding to the information of the interface with information change according to the interface type relationship table as the type of the interface with information change. In one embodiment, the server can also determine the test case of the interface with information change in combination with the business scenario corresponding to the target code. In this case, the correspondence between the type of the interface and the test scenario can be specifically the correspondence between the business scenario, the type of the interface and the test scenario. Accordingly, the server can determine the target test scenario corresponding to the type of the interface with information change according to the business scenario of the target code, the type of the interface and the test scenario.

[0067] In one embodiment, the server can determine an interface that meets the preset condition from at least one interface, and compare the information of the interface that meets the preset condition with the information of the interface included in the first database, and determine the interface that has information change among the interfaces that meet the preset condition based on the comparison result. For example, the preset condition can be that at least the number of information changes is greater than or equal to the first preset number, or it can also be an interface with a call number greater than or equal to the second preset number, or it can also refer to an interface with a priority greater than or equal to the preset priority, and this application does not limit it.

[0068] In one embodiment, the server can obtain an interface change record table associated with the target code, the interface change record table includes multiple interface change information recorded within a first preset time range, and each interface change information in the multiple interface change information can include information of the interface before the information change and information of the interface after the information change; the server counts the number of information changes of each interface according to the information of each interface (referring to the information of each interface obtained from the target code) and the interface change record table; the server determines the interface whose number of information changes is greater than or equal to the first preset number from the at least one interface according to the number of information changes of each interface in the at least one interface; the server compares the information of the interface whose number of information changes is greater than or equal to the first preset number with the information of the interface included in the first database, and determines the interface whose number of changes is greater than or equal to the first preset number according to the comparison result, thereby obtaining the test case of the interface whose information change exists. In this way, the interface with information change can be determined by the interface with high information change frequency, so that the determination process of the interface with information change is more targeted. This way focuses on the test case acquisition process when the interface with high change frequency has information change, indicating that the functional test of the interface with high change frequency is relatively important.

[0069] In one embodiment, the server may obtain an interface call record table associated with the target code, and the interface call record table includes interface call data recorded within a second preset time range. For example, the interface call information may refer to the interface call data of at least one version of the code corresponding to the target code (such as the previous version of the code corresponding to the target code). The server may determine the interface whose call times are greater than or equal to the second preset times among the at least one interface based on the interface call record table; the server may compare the information of the interface whose call times are greater than or equal to the second preset times with the information of the interfaces included in the first database, and determine the interface whose call times are greater than or have information changes among the interfaces whose information changes according to the comparison result, thereby obtaining the test case of the interface whose information changes.

[0070] In one embodiment, the server can determine whether there is an information change tag in the target code. If it is determined that the target code has the information change tag, the server can obtain the information of the interface corresponding to the information change tag from the target code; the server can determine the interface corresponding to the information change tag as the interface with information change, thereby obtaining the test case of the interface with information change. In this way, the interface with information change can be determined by the information of the interface corresponding to the information change tag, making the determination process of the interface with information change more targeted. This method focuses on the test case acquisition process when the interface corresponding to the information change tag has information change, indicating that the functional test of the interface corresponding to the information change tag is relatively important.

[0071] In one embodiment, the server may compare the information of the interface corresponding to the information change label with the information of the interface included in the first database, and determine the interface with information change in the interface corresponding to the information change label based on the comparison result, thereby obtaining a test case for the interface with information change. Considering that there may be a situation where the information change label is marked incorrectly, the accuracy of determining the interface with information change can be ensured by comparing the information of the interface corresponding to the information change label with the information of the interface included in the first database. In one embodiment, if it is determined that the target code does not have the information change label, the server may perform the step of comparing the information of each interface with the information of the interface included in the first database, or perform the step of obtaining the interface change record table associated with the target code, or perform the step of obtaining the interface call record table associated with the target code, which is not limited in the embodiments of the present application.

[0072] In one embodiment, after obtaining the test case of the interface with information change, the server may delete redundant test cases in the second database.

[0073] In one embodiment, the server may update the test case of the interface with information change to the second database. Furthermore, the server may determine the test case of the first interface from the second database; and delete the test case of the first interface included in the second database. The first interface is not included in the at least one interface. In this way, test cases irrelevant to the target code can be deleted, thereby reducing the consumption of storage resources of the second database.

[0074] In one embodiment, the server may also determine the test case of the second interface from the second database, and delete the test case of the second interface included in the second database. Deleting the test case with a reference relationship in this way can reduce the consumption of storage resources of the second data.

[0075] In one embodiment, when the server finds that the second database includes the test case of the interface with information change, the server may obtain the test case of the interface with information change from the second database.

[0076] visible, Figure 1 In the embodiment shown, the server can obtain the target code and obtain the interface information from the target code; the server compares the interface information with the interface information included in the first database, and determines the interface with information changes based on the comparison result, so as to obtain the test case of the interface with information changes for testing the function of the interface with information changes, thereby improving development efficiency by automatically generating test cases for the corresponding interfaces.

[0077] See also Figure 2 , is a flow chart of another interface testing method provided in an embodiment of the present application. The method can be applied to a server. The server can be a server or a server cluster. Specifically, the method can include the following steps:

[0078] S201. Obtain a target code, where the target code includes information of each interface in at least one interface.

[0079] S202: Acquire information of each interface from the target code.

[0080] S203: Compare the information of each interface with the information of interfaces included in the first database, and determine the interface with information change according to the comparison result.

[0081] Among them, steps S201-S203 can be found in Figure 1 Steps S101-S103 in the embodiment are not described in detail in the embodiment of the present application.

[0082] S204: When it is found that the second database includes the test case of the interface with information change, the test case of the interface with information change is obtained from the second database.

[0083] S205: Call an object acquisition method to acquire information of each interface included in the test case of the interface with information change.

[0084] In steps S204-S205, when querying whether the second database includes the test case of the interface with information change, the server can obtain the test case of the interface with information change from the second database. In addition, the server can call the object acquisition method to obtain the information of each interface included in the test case of the interface with information change, so as to execute step S206.

[0085] In one embodiment, the server calls the object acquisition method to acquire the information of each interface included in the test case of the interface with information changes. The server can run the test case of the interface with information changes through the RunTime mechanism of Object-C to acquire the information of each interface included in the test case of the interface with information changes. The code used in this process can include: class_copyMethodList(Class,&methodCount).

[0086] S206: Match the information of the interface with information change with the information of each interface included in the test case of the interface with information change, and update the test case of the interface with information change according to the matching result.

[0087] Since the test case of the interface with information change obtained from the second database may have the following problem: part of the information in the test case of the interface with information change does not match the information of the interface with information change. In order to solve this problem, the server can match the information of the interface with information change with the information of each interface included in the test case of the interface with information change, and update the test case with information change according to the matching result, so that the test case of the interface with information change matches the information of the interface with information change.

[0088] In one embodiment, the server matches the information of the interface with information changes with the information of each interface included in the test case of the interface with information changes, and the way to obtain the matching result is that the server uses a string matching method to match the information of the interface with information changes with the information of each interface included in the test case of the interface with information changes to obtain the matching result.

[0089] In one embodiment, the matching result may include information of a third interface with information changes (such as parameter changes), and the information of the third interface is inconsistent with the information of the third interface included in the test case of the third interface. Accordingly, the server may update the test case with information changes using the information of the third interface.

[0090] In one embodiment, the matching result includes information about the existence of the first interface, and the server can determine the test case of the first interface from the second database and delete the test case of the first interface included in the second database. Figure 1 The method mentioned in the embodiment deletes the test case of the second interface, which will not be described in detail in the embodiment of the present application.

[0091] visible, Figure 2In the illustrated embodiment, when the server queries the second database to include a test case for the interface with information changes, it can match the information of the interface with information changes included in the target code with the information of each interface included in the test case with information changes, and update the information of each interface included in the test case with information changes based on the matching result, thereby improving development efficiency.

[0092] See also Figure 3 , is a schematic diagram of the structure of an interface testing device provided in an embodiment of the present application. The device can apply the aforementioned server. Specifically, the device may include:

[0093] The acquisition module 301 is used to acquire a target code, where the target code includes information of each interface in at least one interface.

[0094] The acquisition module 301 is further used to acquire the information of each interface from the target code.

[0095] The processing module 302 is used to compare the information of each interface with the information of interfaces included in the first database, and determine the interface with information change according to the comparison result.

[0096] The acquisition module 301 is further used to obtain a test case of the interface with information change, wherein the test case is used to test the function of the interface with information change.

[0097] In an optional implementation, the acquisition module 301 acquires the target code, specifically, when a code update message for the target code sent by the code hosting device is received, the target code is acquired from the code hosting device; or, the target code is received by the terminal device.

[0098] In an optional implementation, the acquisition module 301 acquires the information of each interface from the target code, specifically by acquiring the external header file included in the target code through a preset script, wherein the external header file includes the information of each interface in the at least one interface; and calling a regular matching algorithm to acquire the information of each interface from the external header file.

[0099] In an optional embodiment, the processing module 302 is also used to determine the type of the interface with information change based on the information of the interface with information change; determine the target test scenario corresponding to the type of the interface with information change based on the correspondence between the type of interface and the test scenario; wherein the target test scenario includes at least one of the following: a normal test scenario, an abnormal test scenario, and a stress test scenario.

[0100] In an optional implementation, the acquisition module 301 obtains the test case of the interface with information change, specifically obtains the test case of the interface with information change in the target test scenario.

[0101] In an optional embodiment, the processing module 302 is also used to update the test cases of the interface with information changes to a second database after the acquisition module 301 obtains the test cases of the interface with information changes; the second database includes test cases for each of multiple interfaces; the test cases of the first interface are determined from the second database; the first interface is not within the at least one interface; and the test cases of the first interface included in the second database are deleted.

[0102] In an optional implementation, the acquisition module 301 obtains the test case of the interface with information change, specifically, when it is queried that the second database includes the test case of the interface with information change, the test case of the interface with information change is acquired from the second database; when it is queried that the second database does not include the test case of the interface with information change, a blank test case of the interface with information change is generated, and the test case of the interface with information change is acquired based on the blank test case.

[0103] In an optional embodiment, the processing module 302 is also used to call the object acquisition method to obtain the information of each interface included in the test case of the interface with information changes after the acquisition module 301 obtains the test case of the interface with information changes from the second database; match the information of the interface with information changes with the information of each interface included in the test case of the interface with information changes, and update the test case of the interface with information changes according to the matching result.

[0104] visible, Figure 3 In the illustrated embodiment, the server can obtain the target code and obtain the interface information from the target code; the server compares the interface information with the interface information included in the first database, and determines the interface with information changes based on the comparison result, so as to obtain the test case of the interface with information changes for testing the function of the interface with information changes, thereby improving development efficiency by automatically generating test cases for the corresponding interface.

[0105] See also Figure 4, is a schematic diagram of the structure of a server provided in an embodiment of the present application. The server described in this embodiment may include: a processor 1000, an input device 2000, an output device 3000, and a memory 4000. The processor 1000, the input device 2000, the output device 3000, and the memory 4000 may be connected via a bus or other means. In one embodiment, the input device 2000 and the output device 3000 are optional devices. The input device 2000 and the output device 3000 may be standard wired or wireless communication interfaces.

[0106] The processor 1000 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.

[0107] The memory 4000 may be a high-speed RAM memory or a non-volatile memory, such as a disk memory. The memory 4000 is used to store a set of program codes, and the processor 1000, the input device 2000, and the output device 3000 may call the program codes stored in the memory 4000. Specifically:

[0108] Processor 1000 is used to obtain a target code, wherein the target code includes information of each interface in at least one interface; obtain the information of each interface from the target code; compare the information of each interface with the information of interfaces included in a first database, and determine the interface with information change based on the comparison result; obtain a test case for the interface with information change, wherein the test case is used to test the function of the interface with information change.

[0109] Optionally, the processor 1000 obtains the target code, specifically, when receiving a code update message for the target code sent by the code hosting device, obtains the target code from the code hosting device; or, receives the target code sent by the terminal device through the input device 2000.

[0110] Optionally, the processor 1000 obtains the information of each interface from the target code, specifically by obtaining the external header file included in the target code through a preset script, wherein the external header file includes the information of each interface in the at least one interface; and calling a regular matching algorithm to obtain the information of each interface from the external header file.

[0111] Optionally, processor 1000 is further used to determine the type of the interface with information change based on the information of the interface with information change; determine the target test scenario corresponding to the type of the interface with information change based on the correspondence between the type of interface and the test scenario; wherein the target test scenario includes at least one of the following: a normal test scenario, an abnormal test scenario, and a stress test scenario.

[0112] Optionally, the processor 1000 obtains a test case of the interface with information change, specifically obtains a test case of the interface with information change in the target test scenario.

[0113] Optionally, processor 1000 is further used to update the test cases of the interface with information changes to a second database after obtaining the test cases of the interface with information changes; the second database includes test cases for each of multiple interfaces; determine the test cases of the first interface from the second database; the first interface is not within the at least one interface; and delete the test cases of the first interface included in the second database.

[0114] Optionally, the processor 1000 obtains a test case for the interface with information changes, specifically, when it is queried that the second database includes a test case for the interface with information changes, the test case for the interface with information changes is obtained from the second database; when it is queried that the second database does not include a test case for the interface with information changes, a blank test case for the interface with information changes is generated, and the test case for the interface with information changes is obtained based on the blank test case.

[0115] Optionally, the processor 1000 is further used to, after obtaining the test case of the interface with information changes from the second database, call the object acquisition method to obtain information of each interface included in the test case of the interface with information changes; match the information of the interface with information changes with the information of each interface included in the test case of the interface with information changes, and update the test case of the interface with information changes according to the matching result.

[0116] In a specific implementation, the processor 1000, the input device 2000, and the output device 3000 described in the embodiments of the present application may execute Figure 1 and Figure 2 The implementation method described in the embodiment can also execute the implementation method described in the embodiment of the present application, which will not be repeated here.

[0117] Each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of sampling hardware or in the form of sampling software functional unit.

[0118] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The computer-readable storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0119] What is disclosed above is only a preferred embodiment of the present application, and it certainly cannot be used to limit the scope of rights of the present application. Ordinary technicians in this field can understand that all or part of the processes of implementing the above embodiment and equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. An interface testing method, characterized in that: include: Acquire a target code, wherein the target code includes information of each interface of at least one interface; Acquire information of each interface from the target code; Comparing the information of each interface with the information of interfaces included in the first database, and determining the interface with information change according to the comparison result; The method for determining an interface with information change includes: judging whether there is an information change tag in the target code; if it is determined that the target code has the information change tag, obtaining information of the interface corresponding to the information change tag from the target code, and determining the interface corresponding to the information change tag as the interface with information change; if it is determined that the target code does not have the information change tag, obtaining an interface change record table associated with the target code, the interface change record table including multiple interface change information recorded within a first preset time range, each of the multiple interface change information including information of the interface before the information change and information of the interface after the information change; counting the number of information changes of each interface according to the information of each interface obtained from the target code and the interface change record table, and according to the number of information changes of each interface in the at least one interface, Determine from the at least one interface an interface whose number of information changes is greater than or equal to a first preset number of times, compare the information of the interface whose number of information changes is greater than or equal to the first preset number of times with the information of the interfaces included in the first database, and determine, based on the comparison result, the interface whose number of changes is greater than or equal to the first preset number of times and has information changes among the interfaces; obtain an interface call record table associated with the target code, the interface call record table including interface call data recorded within a second preset time range, determine, based on the interface call record table, an interface whose number of calls is greater than or equal to a second preset number of times among the at least one interface, compare the information of the interface whose number of calls is greater than or equal to the second preset number of times with the information of the interfaces included in the first database, and determine, based on the comparison result, the interface whose number of calls is greater than or equal to the information changes and has information changes among the interfaces whose number of calls is greater than or equal to the first preset number of times; Determine the type of the interface where the information is changed according to the information of the interface where the information is changed, and obtain the business scenario corresponding to the target code; According to the correspondence between the business scenario, the type of interface and the test scenario, determine the type of the interface with information change and the target test scenario corresponding to the business scenario corresponding to the target code; wherein the test scenario includes: normal test scenario, abnormal test scenario and stress test scenario; the type of interface includes: newly added interface type, deleted interface type and modified interface type; Obtaining, in an incremental manner, a test case for the interface with information changes in the target test scenario, the test case being used to test a function of the interface with information changes; The step of obtaining the test case of the interface with information change in an incremental manner includes: If it is found in the query that the second database includes the test case of the interface with information change in the target test scenario, the test case of the interface with information change is obtained from the second database; Calling an object acquisition method to obtain information about each interface included in the test case of the interface with information changes in the target test scenario; matching the information about the interface with information changes with the information about each interface included in the test case of the interface with information changes in the target test scenario, and updating the test case of the interface with information changes according to the matching result, so that the information about each interface included in the test case of the interface with information changes in the target test scenario matches the information about the interface with information changes; If it is found that the second database does not include the test case of the interface with information change, a blank test case of the interface with information change is generated, and the test case of the interface with information change is obtained according to the blank test case.

2. The method according to claim 1, characterized in that The obtaining of the target code comprises: When receiving a code update message for the target code sent by the code hosting device, obtaining the target code from the code hosting device; or, The target code sent by the receiving terminal device.

3. The method according to claim 1 or 2, characterized in that: The obtaining the information of each interface from the target code comprises: Acquire, by a preset script, an external header file included in the target code, wherein the external header file includes information of each interface in the at least one interface; A regular matching algorithm is called to obtain information of each interface from the external header file.

4. The method according to claim 1, characterized in that: After obtaining the test case of the interface with information change, the method further includes: Updating the test cases of the interface with information changes to a second database; the second database includes test cases for each of the multiple interfaces; Determining a test case for a first interface from a second database; the first interface is not within the at least one interface; The test cases of the first interface included in the second database are deleted.

5. An interface testing device, characterized in that: include: An acquisition module, used for acquiring a target code, wherein the target code includes information of each interface in at least one interface; The acquisition module is further used to acquire the information of each interface from the target code; A processing module, used for comparing the information of each interface with the information of interfaces included in the first database, and determining the interface with information change according to the comparison result; The method for determining an interface with information change includes: judging whether there is an information change tag in the target code; if it is determined that the target code has the information change tag, obtaining information of the interface corresponding to the information change tag from the target code, and determining the interface corresponding to the information change tag as the interface with information change; if it is determined that the target code does not have the information change tag, obtaining an interface change record table associated with the target code, the interface change record table including multiple interface change information recorded within a first preset time range, each of the multiple interface change information including information of the interface before the information change and information of the interface after the information change; counting the number of information changes of each interface according to the information of each interface obtained from the target code and the interface change record table, and according to the number of information changes of each interface in the at least one interface, Determine from the at least one interface an interface whose number of information changes is greater than or equal to a first preset number of times, compare the information of the interface whose number of information changes is greater than or equal to the first preset number of times with the information of the interfaces included in the first database, and determine, based on the comparison result, the interface whose number of changes is greater than or equal to the first preset number of times and has information changes among the interfaces; obtain an interface call record table associated with the target code, the interface call record table including interface call data recorded within a second preset time range, determine, based on the interface call record table, an interface whose number of calls is greater than or equal to a second preset number of times among the at least one interface, compare the information of the interface whose number of calls is greater than or equal to the second preset number of times with the information of the interfaces included in the first database, and determine, based on the comparison result, the interface whose number of calls is greater than or equal to the information changes and has information changes among the interfaces whose number of calls is greater than or equal to the first preset number of times; The processing module is further used to determine the type of the interface with information change according to the information of the interface with information change, and to obtain the business scenario corresponding to the target code; determine the type of the interface with information change and the target test scenario corresponding to the business scenario corresponding to the target code according to the correspondence between the business scenario, the type of interface and the test scenario; wherein the test scenario includes: normal test scenario, abnormal test scenario and stress test scenario; the type of interface includes: newly added interface type, deleted interface type and modified interface type; The acquisition module is further used to obtain, in an incremental manner, a test case of the interface with information change in the target test scenario, wherein the test case is used to test the function of the interface with information change; The acquisition module acquires the test cases of the interface with information changes in an incremental manner, specifically for: If it is found in the query that the second database includes the test case of the interface with information change in the target test scenario, the test case of the interface with information change is obtained from the second database; Calling an object acquisition method to obtain information about each interface included in the test case of the interface with information changes in the target test scenario; matching the information about the interface with information changes with the information about each interface included in the test case of the interface with information changes in the target test scenario, and updating the test case of the interface with information changes according to the matching result, so that the information about each interface included in the test case of the interface with information changes in the target test scenario matches the information about the interface with information changes; If it is found that the second database does not include the test case of the interface with information change, a blank test case of the interface with information change is generated, and the test case of the interface with information change is obtained according to the blank test case.

6. A server, characterized in that: The method comprises a processor and a memory, wherein the processor and the memory are connected to each other, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Interface test method and device, computer equipment and storage medium

    CN109947646A