Interface testing method, system and device and electronic equipment
By selecting a target test server in the interface test to store the pending code and generate interface information, the problem of low interface testing efficiency caused by the deployment of multiple back-end functions on different servers is solved, and automated interface testing is realized, which improves the testing efficiency.
Patent Information
- Application Number
- CN202510606524.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2045-05-12
AI Technical Summary
When multiple backend functions are deployed on different servers separately, the interface testing efficiency is inefficient, and developers need to determine the service address in the calling interface of each backend function one by one.
By selecting a target test server from multiple test servers, the pending code is stored to the server, and the interface information containing the target test server address and the subfunction code storage path is generated, for calling the interface of the subfunction code.
This avoids manually determining the call interface of back-end functions one by one, improves the overall efficiency of interface testing, and realizes an automated interface testing process.
Smart Images

Figure CN120179563A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and particularly to an interface testing method, system, device, and electronic device. Background Art
[0002] A front-end page can be associated with multiple back-end functions. When a user triggers a back-end function in the front-end page displayed on the client, the client will send a service request to the server represented by the service address in the call interface of the back-end function according to the service address, and the server can implement the back-end function after receiving the service request.
[0003] However, when it is necessary to test the call interfaces of multiple back-end functions, since these multiple back-end functions may be deployed in multiple different servers respectively, correspondingly, developers need to determine the service addresses in the call interfaces of each back-end function one by one according to the back-end functions deployed in each server, resulting in low overall efficiency of interface testing. Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide an interface testing method, system, device, and electronic device to improve the overall efficiency of interface testing. The specific technical solutions are as follows:
[0005] In a first aspect, the embodiments of the present invention provide an interface testing method applied to a master control server. The method includes:
[0006] Select a target test server from multiple test servers;
[0007] Send the code to be processed to the target test server so that the target test server stores the code to be processed and obtains the storage path of each sub-function code in the code to be processed in the target test server;
[0008] For each sub-function code in the code to be processed, generate interface information for calling the call interface of the sub-function code; wherein, the generated interface information includes: the address of the target test server and the storage path of the sub-function code in the target test server;
[0009] Send the generated interface information to a first terminal so that the first terminal generates a front-end page integrated with a target function based on the received interface information, and the target function is implemented based on the sub-function code corresponding to the received interface information; the front-end page is displayed on a second terminal;
[0010] Determine whether the call result obtained from the second terminal is the same as the preset call result, and obtain a test result indicating whether the call interface of at least one sub-function code included in the code to be processed is abnormal; wherein, the call result is the call result returned by the target test server to the second terminal after calling the code to be processed stored locally based on the storage path in the test request sent by the second terminal; the test request is sent in response to the trigger of the target function.
[0011] Optionally, before sending the code to be processed to the target test server so that the target test server stores the code to be processed, the method further includes:
[0012] For each sub-function code included in the code to be processed, determine whether it is necessary to test the call interface for calling the sub-function code, and obtain a determination result for the sub-function code;
[0013] The step of sending the code to be processed to the target test server so that the target test server stores the code to be processed includes:
[0014] Send the code to be processed and the determination results of at least one sub-function code included in the code to be processed to the target test server, so that the target test server calls at least one sub-function code included in the code to be processed stored locally according to the determination results and the storage path in the test request, and returns a call result to the second terminal.
[0015] Optionally, for each sub-function code included in the code to be processed, determining whether it is necessary to test the call interface for calling the sub-function code and obtaining a determination result for the sub-function code includes:
[0016] For each sub-function code included in the code to be processed, if there is no previously submitted sub-function code before the code to be processed is submitted, determine that the determination result of the sub-function code indicates that it is necessary to test the call interface for calling the sub-function code;
[0017] If there is a previously submitted sub-function code before the code to be processed is submitted, determine the currently effective sub-function codes and the currently non-abnormal sub-function codes; wherein, the currently effective sub-function codes are: sub-function codes whose determination results indicate that the corresponding call interfaces need to be tested and no test results have been obtained currently; the currently non-abnormal sub-function codes are: sub-function codes that are recorded in the current non-abnormal sub-function code library, have obtained test results, and the test results indicate no abnormality;
[0018] If among the currently effective sub - function codes and the sub - function codes without exceptions, there is no sub - function code with the same storage path as this sub - function code, determine that the determination result of this sub - function code indicates that the call interface for calling this sub - function code needs to be tested;
[0019] and / or,
[0020] The method further includes:
[0021] For each sub - function code in the to - be - processed code, if the test result of each sub - function code indicates no exception, add the to - be - processed code to the current sub - function code library without exceptions to update the version of the current sub - function code library without exceptions.
[0022] Optionally, the interface information of the call interface of a sub - function code further includes format sub - information indicating the format of the test request and the format of the call result;
[0023] The method further includes: For each sub - function code included in the to - be - processed code, if among the currently effective sub - function codes, there is no sub - function code with the same storage path as this sub - function code, and among the currently effective sub - function codes with the same storage path as this sub - function code, there is no sub - function code with the same format sub - information as that in the interface information of this sub - function code, then determine the historical sub - function codes without exceptions in the historical sub - function code library without exceptions;
[0024] If among the historical sub - function codes without exceptions, there is no sub - function code with the same storage path as this sub - function code and the same format sub - information as that in the interface information of this sub - function code, determine that the determination result of this sub - function code indicates that the call interface for calling this sub - function code needs to be tested;
[0025] If among the historical sub - function codes without exceptions, there is a sub - function code with the same storage path as this sub - function code and the same format sub - information as that in the interface information of this sub - function code, then determine the first number and the second number; where the first number is: the number of sub - function codes with the same format sub - information as that in the interface information of this sub - function code among the historical sub - function codes without exceptions with the same storage path as this sub - function code; the second number is: the number of sub - function codes with the same format sub - data as that in the interface information of the currently effective sub - function code among the historical sub - function codes without exceptions with the same storage path as this sub - function code;
[0026] If the determined first number is less than the second number, determine that the determination result of this sub - function code indicates that the call interface for calling this sub - function code needs to be tested.
[0027] Second aspect, an embodiment of the present invention provides an interface testing method, which is applied to a target test server among multiple test servers, and the method includes:
[0028] When receiving a test request sent by a second terminal, call the locally stored code to be processed based on the storage path in the test request; wherein, the storage path in the test request is the storage path of the sub-function code in the code to be processed in the target test server; the code to be processed sent by the master server is stored in the target test server, and the target test server is selected by the master server from multiple test servers; the test request is sent in response to the trigger of the target function integrated in the front-end page displayed by the second terminal; the front-end page is a front-end page integrated with the target function generated by the first terminal based on the interface information received from the master server; the target function is implemented based on the sub-function code corresponding to the received interface information; the received interface information includes: the address of the target test server and the storage path of the sub-function code in the target test server; return the call result to the second terminal.
[0029] Optionally, the calling the locally stored code to be processed based on the storage path in the test request includes: calling at least one sub-function code included in the locally stored code to be processed according to the determination result and the storage path in the test request; wherein, the determination result is obtained by the master server judging whether it is necessary to test the call interface for calling each sub-function code included in the code to be processed.
[0030] Third aspect, an embodiment of the present invention provides an interface testing system, and the system includes: a master server and multiple test servers; the master server is used to execute the interface testing method in the first aspect above; any test server among the multiple test servers is used to execute the interface testing method in the second aspect above.
[0031] Fourth aspect, an embodiment of the present invention provides an interface testing device, which is applied to a master server, and the device includes: a selection module, configured to select a target test server from multiple test servers;
[0032] A storage module, configured to send the code to be processed to the target test server, so that the target test server stores the code to be processed, and obtain the storage path of each sub-function code in the target test server in the code to be processed;
[0033] A generation module, configured to generate interface information for a call interface for calling each sub - function code in the to - be - processed code; wherein, the generated interface information includes: the address of the target test server and the storage path of the sub - function code in the target test server;
[0034] A first sending module, configured to send the generated interface information to a first terminal, so that the first terminal generates a front - end page integrated with a target function based on the received interface information, and the target function is implemented based on the sub - function code corresponding to the received interface information; the front - end page is displayed on a second terminal;
[0035] A first judgment module, configured to judge whether a call result obtained from the second terminal is the same as a preset call result, and obtain a test result indicating whether the call interfaces of at least one sub - function code included in the to - be - processed code are abnormal; wherein, the call result is the call result returned by the target test server to the second terminal after calling the to - be - processed code stored locally based on the storage path in the test request sent by the second terminal, and the test request is sent in response to the trigger of the target function;
[0036] In a fifth aspect, an embodiment of the present invention provides an interface testing device, which is applied to a target test server among multiple test servers, and the device includes:
[0037] A calling module, configured to call the to - be - processed code stored locally based on the storage path in the test request when receiving a test request sent by a second terminal; wherein, the storage path in the test request is the storage path of the sub - function code in the to - be - processed code in the target test server, the target test server stores the to - be - processed code sent by a main control server, and the target test server is selected by the main control server from multiple test servers; the test request is sent in response to the trigger of the target function integrated in the front - end page displayed on the second terminal; the front - end page is a front - end page integrated with a target function generated by a first terminal based on the interface information received from the main control server; the target function is implemented based on the sub - function code corresponding to the received interface information; the received interface information includes: the address of the target test server and the storage path of the sub - function code in the target test server; a return module, configured to return the call result to the second terminal.
[0038] An embodiment of the present invention further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus; the memory is used to store a computer program; the processor is configured to implement the above - mentioned interface testing method when executing the program stored on the memory.
[0039] Advantages of the embodiments of the present invention:
[0040] In the embodiments of the present invention, a target test server is selected from multiple test servers; then the code to be processed is stored in the target test server, that is, the sub-function code in the code to be processed is deployed to the target test server; then interface information for calling the call interface of the sub-function code is generated. Since the interface information of each sub-function code includes: the address of the target test server and the storage path of the sub-function code in the target test server, the interface information is sent to the first terminal, and the first terminal can generate a front-end page based on the received interface information. The front-end page can be displayed on the second terminal, and when the target function in the front-end page on the second terminal is triggered, the second terminal can automatically send a test request to the target test server according to the address in the interface information of the sub-function code corresponding to the target function (that is, the address of the target test server), without the need for manual determination of the address of the target test server. When the target test server receives the test request sent by the second terminal, it calls the sub-function code stored locally based on the storage path carried in the test request and returns the call result to complete the entire process of triggering the backend function response through the front-end page. Finally, the main control server determines whether the call result obtained from the second terminal is the same as the preset call result to obtain a test result indicating whether the call interface of at least one sub-function code included in the code to be processed is abnormal.
[0041] In the embodiments of the present invention, the sub-function code in the code to be processed is stored in the target test server selected by the machine, and interface information including the address of the target test server and the storage path of the sub-function code in the target test server is generated. Thus, when testing the call interface of each sub-function code, the test request can be sent to the address of the target test server, and when calling the call interface, the sub-function code stored locally in the target test server can be called based on the storage path in the test request, and the call result is returned, avoiding manual determination of the service address in the call interface of each backend function one by one, completing the test of the call interface of the sub-function code, and improving the overall efficiency of interface testing.
[0042] Of course, when implementing any product or method of the present invention, it is not necessarily required to achieve all the above-mentioned advantages simultaneously. Description of the Drawings
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other embodiments based on these drawings.
[0044] Figure 1 Schematic diagram of the first interface test system provided by the embodiment of the present invention;
[0045] Figure 2 Schematic diagram of the second interface test system provided by the embodiment of the present invention;
[0046] Figure 3 Schematic diagram of the process of obtaining a determination result in the first interface test method provided by the embodiment of the present invention;
[0047] Figure 4 Schematic diagram of the process of obtaining a determination result in the second interface test method provided by the embodiment of the present invention;
[0048] Figure 5 Schematic diagram of the principle of an interface test method provided by the embodiment of the present invention;
[0049] Figure 6 Schematic diagram of the process of the first interface test method provided by the embodiment of the present invention;
[0050] Figure 7 Schematic diagram of the process of the second interface test method provided by the embodiment of the present invention;
[0051] Figure 8 Schematic diagram of the structure of the first interface test device provided by the embodiment of the present invention;
[0052] Figure 9 Schematic diagram of the structure of the second interface test device provided by the embodiment of the present invention;
[0053] Figure 10 Schematic diagram of the structure of the first electronic device provided by the embodiment of the present invention. Detailed implementation manners
[0054] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art based on the present invention belong to the scope of protection of the present invention.
[0055] A front - end page can involve the logic of multiple back - end functions, and the logic of each back - end function is implemented by the function code of that back - end function. The development work of a software involving front - end and back - end interaction can be assigned to different developers. Exemplarily, the development work of the front - end page can be assigned to front - end developers for processing, and the development work of each back - end function can be assigned to multiple back - end developers for processing. The way of parallel development by multiple people can improve development efficiency and ensure the delivery schedule of the development work.
[0056] For example, in order to provide service X to users, back - end developer 1 can develop the code to be processed (denoted as feature - 1 for this code to be processed), and the code to be processed is used to implement function X1. The code to be processed includes sub - function code a and sub - function code b. Sub - function code a corresponds to call interface A, and sub - function code b corresponds to call interface B. The functions of sub - function code a and b can be sub - functions under function X1. Back - end developer 2 can develop the code to be processed (denoted as feature - 2 for this code to be processed), and the code to be processed is used to implement function X2. The code to be processed includes sub - function code c and sub - function code d. Sub - function code c corresponds to call interface C, and sub - function code d corresponds to call interface D. The functions of sub - function code c and d can be sub - functions under function X2. The front - end developer can develop the front - end code of the front - end page (denoted as feature - fe for this code to be processed). Among them, X1 and X2 are sub - functions of function X.
[0057] However, when it is necessary to test the call interfaces of multiple back - end functions, since these multiple back - end functions may be deployed in multiple different servers respectively, and the servers are shared servers for each developer, the servers used for each test are not fixed. Correspondingly, for each test, developers need to determine the service addresses in the call interfaces of each back - end function one by one according to the back - end functions deployed in each server, resulting in low overall efficiency of interface testing.
[0058] In order to improve the overall efficiency of interface testing, embodiments of the present invention provide an interface testing method, system, device, and electronic device.
[0059] Among them, the interface testing method provided by the embodiments of the present invention can be applied to a master server. The master server can detect and generate interface information for calling the call interfaces of sub - function codes, and send the generated interface information to the first terminal. It can also obtain the call result from the second terminal. The target test server can receive the test request sent by the second terminal and return the call result to the second terminal. The master server and the target test server can be the same device or different devices.
[0060] The first terminal can be a device used by developers, such as a desktop computer or a laptop. Developers can develop a front-end page on the first terminal based on the received interface information, so that the first terminal generates a front-end page. The second terminal can be a device for displaying the developed front-end page, such as a desktop computer or a laptop. Developers can trigger the function of the sub-function code in the front-end page displayed on the second terminal to perform interface testing. The first terminal and the second terminal can be the same device or different devices.
[0061] An interface testing method provided by an embodiment of the present invention may include the following steps:
[0062] Select a target test server from multiple test servers;
[0063] Send the code to be processed to the target test server, so that the target test server stores the code to be processed and obtains the storage path of each sub-function code in the code to be processed in the target test server;
[0064] For each sub-function code in the code to be processed, generate interface information for calling the call interface of the sub-function code; wherein, the generated interface information includes: the address of the target test server and the storage path of the sub-function code in the target test server;
[0065] Send the generated interface information to the first terminal, so that the first terminal generates a front-end page integrated with the target function based on the received interface information. The target function is implemented based on the sub-function code corresponding to the received interface information; the front-end page is displayed on the second terminal;
[0066] Determine whether the call result obtained from the second terminal is the same as the preset call result, and obtain a test result indicating whether the call interface of at least one sub-function code included in the code to be processed is abnormal; wherein, the call result is the call result returned by the target test server to the second terminal after calling the code to be processed stored locally based on the storage path in the test request sent by the second terminal; the test request is sent in response to the triggering of the target function.
[0067] In an embodiment of the present invention, the sub-function code in the code to be processed is stored in the target test server selected by the machine, and interface information including the address of the target test server and the storage path of the sub-function code in the target test server is generated. Thus, when testing the call interface of each sub-function code, the test request can be sent to the address of the target test server, and when calling the call interface, the sub-function code stored locally in the target test server can be called based on the storage path in the test request, and the call result can be returned, avoiding manually determining the service address in the call interface of each backend function one by one, completing the test of the call interface of the sub-function code, and improving the overall efficiency of interface testing.
[0068] The following Figure 1 introduces an interface testing system provided by an embodiment of the present invention. As Figure 1 shown, the interface testing system includes: a main control server 110, a first terminal 120, a second terminal 130, and a target test server 140. In the process of interaction between the main control server 110 and the first terminal 120, the main control server 110 and the second terminal 130, and the second terminal 130 and the target test server 140, steps S101-S109 may be included.
[0069] S101, the main control server 110 selects a target test server from multiple test servers.
[0070] It can be understood that the development work of each backend function can be assigned to different developers for processing. When a developer completes the development of the backend function he is responsible for, the code to be processed written by himself can be submitted to the code database. In order to test the call interface for calling the sub-function code in the code to be processed, the main control server 110 can select a target test server for each code to be processed. Exemplarily, when the main control server 110 detects that a new code to be processed is submitted to the code database, it selects a target test server from multiple test servers.
[0071] Among them, the code to be processed may include at least one sub-function code. Each sub-function code can implement a sub-function. In one implementation, the code to be processed may contain more than one sub-function code. For example, the code to be processed may contain 2, 3, or 4 or more sub-function codes; the sub-functions implemented by any two sub-function codes may be different. For example, sub-function code 1 can implement the function of obtaining student grades, and sub-function code 2 can obtain the teacher's salary. In another implementation, the code to be processed may only contain one sub-function code, that is, the code to be processed submitted by the developer only implements one function.
[0072] The call interface for each sub - function code in the code to be processed is used to call the sub - function code. The code to be processed also includes the identifier of the call interface for each sub - function code. The interface information of the call interface may include the address, port number, and storage path of the target test server. When developers write sub - function code, they can pre - define the identifier of the call interface for the sub - function code. Subsequently, when storing the sub - function code in the target test server, the target test server can establish a storage path containing the identifier and store the sub - function code in the established storage path. For example, developers can write the function name for the interface that calls the sub - function code and use the function name as the storage path in the interface information of the sub - function code. When writing sub - function code, developers do not need to determine the address and port number in the interface information of the call interface for the sub - function code, and the address and port number in the interface information are assigned by the subsequent main control server. Among them, the address of the interface information can be the Internet Protocol (IP) address of the target test server. The port number in the interface information of each call interface is used to represent the network connection through the port characterized by the port number.
[0073] The main control server 110 can detect whether there is new code to be processed submitted to the code database. In one implementation, the server where the code database is located and the main control server 110 are different devices. When there is new code to be processed submitted, the server where the code database is located can send a signal indicating that new code to be processed has been submitted to the main control server 110, so that the main control server 110 can detect that new code to be processed has been submitted to the code database. In another implementation, the server where the code database is located and the main control server 110 are the same device. When new code to be processed is stored in the code database, the main control server 110 can detect that new code to be processed has been submitted to the code database. When detecting that new code to be processed has been submitted to the code database, the main control server 110 can select a target test server from multiple servers.
[0074] Among them, multiple test servers are public servers for interface testing by each developer. In the first implementation, the main control server 110 can select a server that does not store the code to be processed as the target test server from multiple test servers. In the second implementation, the main control server 110 can select the server with the largest remaining storage space as the target test server from multiple test servers. In the third implementation, the main control server 110 can arbitrarily select a server from multiple test servers as the target test server. In the fourth implementation, the main control server 110 can select a server with the least amount of code to be processed stored as the target test server from multiple test servers.
[0075] S102. The main control server 110 sends the code to be processed to the target test server 140, so that the target test server 140 stores the code to be processed and obtains the storage path of each sub-function code in the code to be processed in the target test server 140.
[0076] It can be understood that the main control server 110 can access the code database according to the address of the preset code database, obtain the code to be processed, and then send the code to be processed to the target test server 140, and the target test server stores the code to be processed. Exemplarily, the main control server 110 can copy the new code to be processed in the code database, send the copy result to the target test server 140, and the target test server 140 can store the received copy result, that is, store the new code to be processed. After the target test server 140 obtains the code to be processed, it can store the code to be processed and send the storage path of each sub-function code in the code to be processed in the target test server to the main control server.
[0077] S103. The main control server 110 generates interface information for the call interface used to call each sub-function code in the code to be processed.
[0078] It can be understood that the main control server 110 can generate interface information for the call interface used to call each sub-function code in the code to be processed, and the generated interface information includes the address of the target test server and the storage path of the sub-function code in the target test server. Exemplarily, the main control server 110 can generate an interface document including the interface information of each sub-call code call interface. Specifically, the main control server 110 can use an interface document generation component such as Swagger to generate an interface document. Developers can understand the interface information of each call interface through the interface document, so as to accurately use the call interface in the developed code.
[0079] S104. The main control server 110 sends the generated interface information to the first terminal 120.
[0080] It can be understood that the first terminal 120 is a device used by developers. The first terminal 120 can receive the interface information sent by the master control server 110. Developers can develop a front-end page that can call the sub-function code in the code to be processed based on the interface information received by the first terminal 120, so that the first terminal 120 generates a front-end page integrated with the target function. Among them, the target function is implemented based on the sub-function code corresponding to the interface information. For the interface information of the call interface for each sub-function code, the target function corresponding to the interface information is implemented based on the sub-function code. Exemplarily, developers can develop a front-end page associated with the functions represented by the sub-function codes in the code to be processed. Specifically, developers can write the front-end code of a front-end page, and the execution logic of the front-end code is that when the function represented by the code to be processed in the front-end page is triggered, a test request is sent to the first terminal 120. For example, developers can write a front-end code, and the execution logic of the front-end code is that when the function of viewing student grades on the page is triggered, the call interface for obtaining student grades is called, and a request for obtaining student grades is sent to the target test server 140.
[0081] S105. The second terminal 130 sends a test request to the target test server 140.
[0082] It can be understood that the second terminal 130 can display the front-end page generated by the first terminal 120. In one implementation, the first terminal 120 and the second terminal 130 are different devices. After the developer develops a front-end page on the first terminal 120, the first terminal 120 can send the front-end code of the front-end page to the second terminal 130. The second terminal 130 can receive the front-end code and display the front-end page based on the received front-end code. In another implementation, the first terminal 120 and the second terminal 130 are the same device. After the developer develops a front-end page on the first terminal 120, the first terminal 120 can directly display the developed front-end page.
[0083] Developers can trigger the target function in the front-end page of the second terminal 130. Exemplarily, the code to be processed contains multiple sub-function codes, and the front-end page is associated with each sub-function code. Developers can perform trigger operations on the functions of each sub-function code in the front-end page. For example, there is a data viewing button on the front-end page. When the developer clicks the data viewing button, the function represented by the sub-function code for obtaining data is triggered, and then the call interface of the sub-function code is called to send a test request to the target test server.
[0084] In one implementation, in an architecture in a service-less state, each request sent by the terminal to the server is independent and does not depend on the information carried in other requests. The server's processing of each received request does not depend on the state of the previous received request, and the call interfaces invoked when sending each request do not affect each other. The testing of each call interface is independent, and when each call interface is invoked, it will not be affected by other call interfaces. That is to say, in the test requests sent by the second terminal 130, each test request is sent by invoking a call interface, and the call interfaces invoked by different test requests are different.
[0085] In one implementation, the main control server 110 can select a port (which can be called port Px) from the unoccupied ports as the port for the target test server 140 to interact with the second terminal 130, and maintain the network connection established between the target test server 140 and the second terminal 130 through this port, that is, keep this port alive to ensure that the transmission of test requests and call results between the target test server 140 and the second terminal 130 is not interfered with.
[0086] The main control server 110 can select a port from the unoccupied ports as the port of this call interface (which can be called P1) for each call interface of the sub-function code in the code to be processed. After the target test server 140 receives a test request for a sub-function code through port Px, it can pass the test request to port P1 to pass the test request to the call interface of this sub-function code.
[0087] S106. The target test server 140 invokes the code to be processed stored locally based on the storage path in the test request sent by the second terminal 130.
[0088] S107. The target test server 140 returns the call result to the second terminal 130.
[0089] It can be understood that the test request is sent by the second terminal 130 by invoking the call interface of the sub-function code. The test request may carry the address of the target test server 140 and the storage path of the sub-function code to be invoked in the target test server. The target test server 140 can invoke the sub-function code stored locally based on the storage path in the test request to obtain the call result.
[0090] Exemplarily, the interface information of the call interface further includes format sub-information indicating the format of the test request and the format of the call result. After generating the interface information of each sub-function code, the master control server 110 may store the interface information in the target test server 140. The second terminal 130 may generate a test request according to the format of the test request indicated by the format sub-information and send the test request to the target test server 140. After calling the sub-function code stored locally, the target test server 140 may obtain the running result of the sub-function code. Then, the target test server 140 generates a call result including the running result according to the format of the call result indicated by the format sub-information.
[0091] Among them, the format sub-information indicating the format of the test request may be referred to as the input parameter model. The format sub-information indicating the format of the test request may include the data type of the data in the test request. For example, if the data type of the data included in the format sub-information indicating the format of the test request is a string type, then the data in the test request sent by the second terminal 130 is of the string type. The format sub-information indicating the format of the call result may be referred to as the response model. The format sub-information indicating the format of the call result may indicate that the call result needs to include the running result and the response status code, etc. The response status code indicates the processing result of the request. For example, the response status code 404 indicates that the resource requested by the second terminal 130 is not found in the target test server 140, and the response status code 500 indicates that an error has occurred inside the target test server. Developers can determine the reason for the exception according to the response status code and make adjustments. For example, if the response status code is 404, developers can check whether there is any missing code in the storage path of the sub-function code in the target test server 404.
[0092] S108, the master control server 110 obtains the call result from the second terminal 130.
[0093] S109, the master control server 110 determines whether the call result is the same as the preset call result, and obtains a test result indicating whether the call interface of at least one sub-function code included in the code to be processed is abnormal.
[0094] It can be understood that after the second terminal 130 obtains the call result, it may send the obtained call result to the master control server 110. After the master control server 110 obtains the call result from the second terminal 130, it may determine whether the call result is the same as the preset call result of the code to be processed. Among them, the preset call result of the code to be processed includes the preset call result of each sub-function code. The preset call result of each sub-function code includes the running result obtained after the sub-function code runs and conforms to the format of the call result indicated by the format sub-information in the interface information of the call interface of the sub-function code.
[0095] For each sub - function code in the code to be processed, if the test result of the sub - function code is the same as the preset call result of the sub - function code, a test result indicating that the call interface of the sub - function code included in the code to be processed is normal can be obtained. If the test result of the sub - function code is different from the preset call result of the sub - function code, a test result indicating that the call interface of the sub - function code included in the code to be processed has an exception can be obtained.
[0096] In one implementation, if the test results of all sub - function codes in the code to be processed all indicate no exception, the code to be processed is added to the current library of sub - function codes without exception to update the version of the current library of sub - function codes without exception. For example, if there are sub - function codes 1 and 2 in the current library of sub - function codes without exception and the version number of the current library of sub - function codes without exception is dev1, and if the test results of the newly submitted sub - function codes 3 and 4 indicate no exception, then sub - function codes 3 and 4 are added to the library of sub - function codes without exception to obtain the current library of sub - function codes without exception containing sub - function codes 1, 2, 3, and 4, and the version number of the current library of sub - function codes without exception is updated to dev2; at this time, the library of sub - function codes without exception with version number dev1 and containing sub - function codes 1 and 2 can be called the historical library of sub - function codes without exception.
[0097] In one implementation, if the test results of all sub - function codes in the code to be processed all indicate no exception, the code to be processed is added to the current library of sub - function codes without exception, the code to be processed in the main control server 110 is deleted, and the ports of the call interfaces of all sub - function codes in the code to be processed are set to unoccupied to release the storage resources and port resources of the main control server.
[0098] Among them, the code in the current library of sub - function codes without exception does not need to be retested by the developer who developed the code to be processed and can be put into use in subsequent actual projects or further tested by other testers.
[0099] If there are test results indicating exceptions among the test results of all sub - function codes in the code to be processed, the developer who developed the code to be processed needs to check the sub - function code whose test result indicates an exception and the interface information of the call interface of the sub - function code to find the cause of the exception and make adjustments.
[0100] In one implementation, the master server 110 may detect whether the identifier (such as the name) of the newly submitted sub - function code is the same as that of the already submitted sub - function code to determine whether the sub - function code is resubmitted. If the sub - function code is resubmitted, the sub - function code stored in the master server is deleted, and the address of the sub - function code and the port of the call interface are set to the address and port of the newly submitted sub - function code. Then, the sub - function code stored in the target test server is replaced with the newly submitted sub - function code.
[0101] It can be understood that in interface joint debugging, developers need to jointly test the usage of the call interfaces of each sub - function code in the front - end running environment, and debug the call interfaces and sub - function codes to ensure that the call interfaces are normal.
[0102] In the embodiments of the present invention, developers do not need to pay attention to service deployment details such as addresses in the call interfaces, and do not need to communicate with front - end developers to determine the addresses of the call interfaces. Developers only need to normally develop and submit business codes, and the call interfaces can be automatically tested, reducing the labor costs required for testing.
[0103] In one embodiment, as Figure 2 shown, in the Figure 1 interface test system shown, the master server 110 may also execute step S201. Step S102 includes step S1021, and S106 includes step S1061.
[0104] S201. For each sub - function code included in the code to be processed, the master server 110 determines whether it is necessary to test the call interface used to call the sub - function code to obtain the determination result of the sub - function code.
[0105] It can be understood that since there are differences in the times when each developer submits the code to be processed, the testing of the sub - function codes in the code to be processed submitted by each developer has a sequence. If there are sub - function codes with the same interface information of the call interface in the code to be processed submitted by each developer, in order to avoid repeated testing of the same call interface, when processing each sub - function code in the newly submitted code to be processed, it is determined whether it is necessary to test the call interface used to call the sub - function code to obtain the determination result of the sub - function code.
[0106] Exemplarily, if there are other interface information that has been uploaded and is the same as the interface information of each sub - function code in the code to be processed before testing the interface information of each sub - function code, it can be determined that the determination result indicates that there is no need to test the call interface for calling the sub - function code. If there are no other interface information that has been uploaded and is the same as the interface information before testing the interface information of the sub - function code, it can be determined that the determination result indicates that it is necessary to test the call interface for calling the sub - function code.
[0107] S1021, the main control server 110 sends the code to be processed and the determination results of at least one sub - function code included in the code to be processed to the target test server 140.
[0108] S1061, the target test server 140 calls at least one sub - function code included in the code to be processed stored locally according to the determination result and the storage path in the test request.
[0109] It can be understood that while the main control server 110 stores the code to be processed in the target test server 140, it also stores the determination results of at least one sub - function code included in the code to be processed in the target test server 140. For each sub - function code in the code to be processed, when the target test server 140 receives a test request for calling the sub - function code, if the determination result of the sub - function code indicates that it is necessary to test the call interface for calling the sub - function code, it calls the sub - function code stored locally according to the storage path carried in the test request; if the determination result of the sub - function code indicates that there is no need to test the call interface for calling the sub - function code, it does not call the sub - function code and does not return call data to the second terminal 130, that is, it does not perform subsequent processing.
[0110] In the embodiment of the present invention, the target test server 140 can determine whether to perform subsequent processing according to the determination result, which can avoid repeated testing of the same interface information and reduce the waste of running resources.
[0111] In one embodiment, in order to obtain the determination result, the main control server 110 can obtain the determination result according to whether there are other interface information that needs to be tested and is the same as the interface information before obtaining the test result of the sub - function code. Specifically, as Figure 3 shown, step S201 executed by the main control server 110 may include steps S2011 - S2013.
[0112] S2011, for each sub - function code included in the code to be processed, if there is no submitted sub - function code before the code to be processed is submitted, it is determined that the determination result of the sub - function code indicates that it is necessary to test the call interface for calling the sub - function code.
[0113] It can be understood that the submitted sub - function code is the sub - function code submitted before the newly submitted code to be processed. If there is no submitted sub - function code in the code database before the submission of the new code to be processed, that is, there is no sub - function code with the same interface information as the call interface of the sub - function code in the new code to be processed, it can be determined that the determination result of each sub - function code included in the code to be processed indicates that the call interface used to call the sub - function code needs to be tested.
[0114] S2012, if there is a submitted sub - function code before the submission of the code to be processed, determine the currently effective sub - function code and the currently non - abnormal sub - function code.
[0115] Among them, the currently effective sub - function code is: the sub - function code whose determination result indicates that the corresponding call interface needs to be tested and has not obtained the test result currently; the currently non - abnormal sub - function code is: the sub - function code recorded in the current non - abnormal sub - function code library that has obtained the test result and the test result indicates no abnormality.
[0116] It can be understood that if there is a submitted sub - function code before the submission of the code to be processed, it is still impossible to determine whether there is a sub - function code with the same interface information as the call interface of the sub - function code in the new code to be processed. More information is needed for further determination.
[0117] To obtain more information, the main control server 110 can determine the currently effective sub - function code and the currently non - abnormal sub - function code.
[0118] The currently effective sub - function code belongs to the submitted sub - function code, but the currently effective sub - function code has a determination result, and the determination result indicates that the corresponding call interface needs to be tested, and the currently effective sub - function code has not obtained the test result currently. That is to say, it has been determined that the currently effective sub - function code will be tested. The currently non - abnormal sub - function code is: the sub - function code recorded in the current non - abnormal sub - function code library that has obtained the test result and the test result indicates no abnormality. In the foregoing embodiments, how the sub - function codes in the current non - abnormal sub - function code library are specifically obtained has been described. The sub - function codes in the current non - abnormal sub - function code library have all obtained the test result and the test result indicates no abnormality.
[0119] In the update method of the non - abnormal sub - function code library, in addition to adding the code to be processed with the test result of no abnormality of each sub - function code to the current non - abnormal sub - function code library as described in the foregoing embodiments, there may also be other update methods.
[0120] In one implementation, a developer can delete the sub - function code in the current exception - free sub - function code library to update the version of the current exception - free sub - function code library. For example, in the current exception - free sub - function code library, there are sub - function codes 1 and 2, and the version number of the current exception - free sub - function code library is dev1. If the developer deletes sub - function code 1 in the exception - free sub - function code library, the current exception - free sub - function code library containing sub - function code 2 is obtained, and the version number of the current exception - free sub - function code library is updated to dev2. At this time, the exception - free sub - function code library with version number dev1 and containing sub - function codes 1 and 2 can be called the historical exception - free sub - function code library.
[0121] In another implementation, a developer can modify the sub - function code in the current exception - free sub - function code library to update the version of the current exception - free sub - function code library. For example, in the current exception - free sub - function code library, there are sub - function codes 1 and 2, and the version number of the current exception - free sub - function code library is dev1. If the developer modifies sub - function code 1 in the exception - free sub - function code library to sub - function code 11, the current exception - free sub - function code library containing sub - function codes 11 and 2 is obtained, and the version number of the current exception - free sub - function code library is updated to dev2. At this time, the exception - free sub - function code library with version number dev2 and containing sub - function codes 1 and 2 can be called the historical exception - free sub - function code library.
[0122] S2013, if there is no sub - function code with the same storage path as the sub - function code among the currently effective sub - function codes and the exception - free sub - function codes, it is determined that the determination result of the sub - function code indicates that the call interface used to call the sub - function code needs to be tested.
[0123] It can be understood that the storage path and the format sub - information in the interface information of a call interface can jointly serve as the unique identifier of the call interface. If the storage paths and the format sub - information of two call interfaces are both the same, it can be considered that these two call interfaces are the same. If there is a difference in either the storage path or the format sub - information, it can be considered that the two call interfaces are different. For example, if the storage path of call interface A is 1 and the format sub - information is 1, and the storage path of call interface B is 1 and the format sub - information is 2, then call interfaces A and B are not the same; if the storage path of call interface A is 1 and the format sub - information is data1, and the storage path of call interface B is 2 and the format sub - information is data1, then call interfaces A and B are not the same; if the storage path of call interface A is 1 and the format sub - information is data1, and the storage path of call interface B is 1 and the format sub - information is data1, then call interfaces A and B are the same.
[0124] If among the currently effective sub - function codes and the sub - function codes without exceptions, there is no sub - function code with the same storage path as this sub - function code, it can be determined that among the currently effective sub - function codes and the sub - function codes without exceptions, there is no sub - function code identical to this sub - function code. That is, there is no sub - function code with the same interface information as the call interface of the sub - function code in the new code to be processed. Furthermore, a determination result indicating that the call interface used to call this sub - function code needs to be tested is determined.
[0125] In one implementation, if among the currently effective sub - function codes and the sub - function codes without exceptions, there are sub - function codes with the same storage path as this sub - function code, no subsequent processing is performed.
[0126] In the embodiment of the present invention, the main control server 110 can accurately obtain a determination result based on whether there is a sub - function code with the same interface information as the call interface of the sub - function code in the new code to be processed. Subsequently, according to the accurate determination result, it is judged whether to perform subsequent processing, and the call interface that needs to be tested can be accurately determined. While avoiding testing the call interfaces with duplicate interface information, it also avoids missing the testing of the call interfaces that need to be tested, reduces the waste of running resources, and ensures the execution of the testing for the call interfaces that need to be tested.
[0127] In one embodiment, on the basis of the above - mentioned embodiment, the main control server 110 can obtain a determination result by combining the storage path and the format sub - information. Specifically, as Figure 4 shown, the main control server 110 can also execute steps S401 - S404.
[0128] S401, for each sub - function code included in the code to be processed, if among the currently sub - function codes without exceptions, there is no sub - function code with the same storage path as this sub - function code, and among the currently effective sub - function codes with the same storage path as this sub - function code, there is no sub - function code with the same format sub - information as the interface information of this sub - function code, then determine the historical sub - function codes without exceptions in the historical sub - function code library without exceptions.
[0129] It can be understood that if there are sub - function codes in the current sub - function code library without exceptions, there are two development methods for developers when developing the code to be processed.
[0130] In the first development method, developers can synchronize all the sub-function codes in the current exception-free sub-function code library to the first terminal used by the developers, and develop based on the synchronized sub-function codes to obtain new code to be processed. Since the code to be processed obtained is inherited from the current exception-free sub-function code library, the interface information of the inherited sub-function codes has been tested, so the inherited code to be processed does not need to be tested.
[0131] In the second development method, developers can develop based on the sub-function codes in the historical exception-free sub-function code library to obtain new code to be processed. That is to say, the sub-function codes in the historical exception-free sub-function code library are rolled back as the new code to be processed. There are very few sub-function codes in the historical exception-free sub-function code library that are the same as those in the current exception-free sub-function code library. Since it is unknown whether the call interfaces of the rolled-back sub-function codes are suitable for the current front-end running environment, the call interfaces of the rolled-back sub-function codes need to be retested. Since in the first method, most of the content in the new code to be processed is inherited from the current exception-free sub-function code library, thus, compared with the second method, among the sub-function codes in the current exception-free sub-function code library, the number of sub-function codes that are the same as those of the new code to be processed obtained by the first method is larger.
[0132] In step S401, if there is no sub-function code in the current exception-free sub-function code that has the same storage path as this sub-function code, it can be determined that there is no call interface in the call interface of the current exception-free sub-function code that is the same as the call interface of this sub-function code. If there is no sub-function code in the currently effective sub-function codes that has the same storage path as this sub-function code and has the same format sub-information as the interface information of this sub-function code, it can be determined that there is no call interface in the call interface of the currently effective sub-function codes that is the same as the call interface of this sub-function code. At this time, it is necessary to further consider the impact of the development method used by the developers on the code to be processed.
[0133] The main control server 110 can determine the historical exception-free sub-function codes in the historical exception-free sub-function code library. Exemplarily, the main control server 110 can determine the historical exception-free sub-function code library with a version lower than the current exception-free sub-function code library, and determine the historical exception-free sub-function codes from the historical exception-free sub-function code library. For example, if the version number of the current exception-free sub-function code library is 2 and the version number of the historical exception-free sub-function code library is 1, the exception-free sub-function code library with version number 1 can be determined as the historical exception-free sub-function code library.
[0134] S402. If there is no sub - function code in the historical non - abnormal sub - function codes that has the same storage path as this sub - function code and the same format sub - information in the interface information of this sub - function code, then determine that the determination result of this sub - function code indicates that the call interface used to call this sub - function code needs to be tested.
[0135] It can be understood that if there is no sub - function code in the historical non - abnormal sub - function codes that has the same storage path as this sub - function code and the same format sub - information in the interface information of this sub - function code, that is to say, there is no call interface in the call interfaces of the historical non - abnormal sub - function codes that is the same as the call interface of this sub - function code, it can be determined that the determination result indicating that the call interface used to call this sub - function code needs to be tested.
[0136] S403. If there is a sub - function code in the historical non - abnormal sub - function codes that has the same storage path as this sub - function code and the same format sub - information in the interface information of this sub - function code, then determine the first number and the second number.
[0137] Among them, the first number is: the number of sub - function codes in the historical non - abnormal sub - function codes with the same storage path as this sub - function code and the same format sub - information in the interface information of this sub - function code; the second number is: the number of sub - function codes in the historical non - abnormal sub - function codes with the same storage path as this sub - function code and the same format sub - data in the interface information of the currently effective sub - function code.
[0138] S404. If the determined first number is less than the second number, determine that the determination result of this sub - function code indicates that the call interface used to call this sub - function code needs to be tested.
[0139] It can be understood that on the basis of step S401, it has been determined that there is no call interface in the call interfaces of the currently non - abnormal sub - function code and the currently effective sub - function code that is the same as the call interface of this sub - function code. At this time, if there is a sub - function code in the historical non - abnormal sub - function codes that has the same storage path as this sub - function code and the same format sub - information in the interface information of this sub - function code, it is also necessary to combine the number of sub - function codes with the same call interface as this sub - function code in the historical non - abnormal sub - function codes to judge the development method. That is to say, it cannot be determined whether this sub - function code is obtained by rolling back the historical non - abnormal sub - function code, and it cannot be determined whether the call interface used to call this sub - function code needs to be tested.
[0140] To determine whether the sub - function code is obtained by rolling back a historical non - abnormal sub - function code, the master server 110 can determine the first number of sub - function codes in the historical non - abnormal sub - function codes with the same storage path as that of the sub - function code, which have the same format sub - information in the interface information of the sub - function code; the first number is the number of call interfaces in the historical non - abnormal sub - function codes that are the same as the call interface of the sub - function code.
[0141] The master server 110 can determine the second number of sub - function codes in the historical non - abnormal sub - function codes with the same storage path as that of the sub - function code, which have the same format sub - data in the interface information of the currently effective sub - function code; the call interface of the currently effective sub - function code needs to be tested, and the currently effective sub - function code is obtained by rolling back. That is to say, since the number of sub - function codes obtained by rolling back that are the same as the historical sub - function codes is small, and the number of sub - function codes obtained by synchronization that are the same as the historical sub - function codes is large, thus, the second number reflects the number of historical call interfaces that are the same as the call interface of the sub - function code obtained by rolling back.
[0142] Taking the second number as a standard, if the first number is less than the second number, that is, the number of historical call interfaces that are the same as this call interface is less than the number of historical call interfaces that are the same as the call interface to be tested, it can be determined that the sub - function code is obtained by rolling back. The call interface of the sub - function code obtained by rolling back needs to be tested, and then a determination result indicating that the call interface used to call the sub - function code needs to be tested is determined.
[0143] If the first number is not less than the second number, it can be determined that the call interface of the sub - function code is newly added or changed among the call interfaces of the effective sub - function codes. When the test of the call interface of the effective sub - function code is completed, the call interface of this sub - function code has actually been tested. Therefore, the test of the call interface of this sub - function code can be ignored, and no subsequent processing is performed on this sub - function code.
[0144] In the embodiments of the present invention, the master server 110 can accurately determine the determination result by combining the call interfaces of historical sub - function codes and the characteristics of sub - function codes and their call interfaces obtained by developing sub - function codes in different ways. Subsequently, according to the accurate determination result, it is judged whether to perform subsequent processing, and the call interfaces that need to be tested can be accurately determined. While avoiding testing the call interfaces with duplicate interface information, it also avoids missing the testing of call interfaces that need to be tested, reduces the waste of operating resources, and ensures the execution of the test for call interfaces that need to be tested.
[0145] Figure 5Schematic diagram of the principle of an interface testing method provided by an embodiment of the present invention.
[0146] Each back-end developer can develop the back-end function for the back-end function he is responsible for to obtain the code to be processed, and then submit the developed code to be processed to the code database. For example, back-end developer 1 and back-end developer 2 can submit code to the code database normally. The master server can detect whether there is new code to be processed submitted to the code database by listening for events of new code to be processed submitted, that is, listening for trigger events.
[0147] When the master server detects that there is new code to be processed submitted to the code database, it selects a target test server from multiple test servers; the master server can store each sub-function code in the code to be processed in the target test server; for each sub-function code in the code to be processed, generate interface information for calling the call interface of the sub-function code; wherein, the generated interface information includes: the address of the target test server, and the storage path of the sub-function code in the target test server. That is, obtain the deployable address and notify the service deployment result, and then execute the service deployment.
[0148] The target test server can also be called a dedicated test server. The target test server can process multiple codes to be processed. For example, the master server can process the code to be processed for implementing function X and the code to be processed for implementing function Y. Among them, the code to be processed for implementing function X can include sub-function codes for implementing sub-function X1, sub-function codes for implementing sub-function X2, and sub-function codes for implementing sub-function X3. The code to be processed for implementing function Y can include sub-function codes for implementing function Y1.
[0149] The master server can send the generated interface information to the first terminal, and the first terminal is the device used by the front-end developer. The front-end developer can use the address of the target test server as the address of the call interface to implement subsequent joint debugging processing. That is, the joint debugging address is fixedly written with a value.
[0150] When the target test server receives a test request sent by the second terminal, it calls at least one sub-function code included in the code to be processed stored locally based on the storage path carried in the test request, and returns a call result to the second terminal; wherein, the test request is sent by the second terminal in response to the trigger of the target function integrated in the front-end page displayed. The target function is implemented based on the sub-function code corresponding to the interface information received by the first terminal.
[0151] The master server can obtain the call result from the second terminal, and determine whether the call result is the same as the preset call result, so as to obtain a test result indicating whether the call interface of at least one sub-function code included in the code to be processed is abnormal.
[0152] Figure 6 It is a schematic flowchart of the first interface detection method provided by an embodiment of the present invention. As Figure 6 shown, the interface detection method is applied to the master server, and includes the following steps:
[0153] S601, select a target test server from multiple test servers.
[0154] S602, send the code to be processed to the target test server, so that the target test server stores the code to be processed, and obtain the storage path of each sub-function code in the code to be processed in the target test server.
[0155] S603, for each sub-function code in the code to be processed, generate interface information for the call interface used to call the sub-function code.
[0156] Among them, the generated interface information includes: the address of the target test server and the storage path of the sub-function code in the target test server.
[0157] S604, send the generated interface information to the first terminal, so that the first terminal generates a front-end page integrated with the target function based on the received interface information.
[0158] S605, determine whether the call result obtained from the second terminal is the same as the preset call result, so as to obtain a test result indicating whether the call interface of at least one sub-function code included in the code to be processed is abnormal.
[0159] Among them, the target function is implemented based on the sub-function code corresponding to the received interface information; the front-end page is displayed on the second terminal. The call result is the call result returned by the target test server to the second terminal after calling the locally stored code to be processed based on the storage path in the test request sent by the second terminal; the test request is sent in response to the trigger of the target function.
[0160] Figure 7 It is a schematic flowchart of the second interface detection method provided by an embodiment of the present invention. As Figure 7 shown, the interface detection method is applied to the target test server among multiple test servers, and the method includes the following steps:
[0161] S701, when receiving the test request sent by the second terminal, call the locally stored code to be processed based on the storage path in the test request.
[0162] Among them, the storage path in the test request is the storage path of the sub-function code in the to-be-processed code on the target test server; the to-be-processed code sent by the master server is stored in the target test server, and the target test server is selected by the master server from multiple test servers; the test request is sent in response to the trigger of the target function integrated in the front-end page displayed by the second terminal; the front-end page is a front-end page integrated with the target function generated by the first terminal based on the interface information received from the master server; the target function is implemented based on the sub-function code corresponding to the received interface information; the received interface information includes the address of the target test server and the storage path of the sub-function code on the target test server.
[0163] S702, return the call result to the second terminal.
[0164] In the embodiment of the present invention, the sub-function code in the to-be-processed code is stored in the target test server selected by the machine, and interface information including the address of the target test server and the storage path of the sub-function code on the target test server is generated. Thus, when testing the call interface of each sub-function code, the test request can be sent to the address of the target test server, and when calling the call interface, the sub-function code stored locally on the target test server can be called based on the storage path in the test request, and the call result can be returned, avoiding manually determining the service address in the call interface of each backend function one by one, completing the test of the call interface of the sub-function code, and improving the overall efficiency of interface testing.
[0165] Figure 8 It is a schematic structural diagram of the first interface detection device provided by the embodiment of the present invention.
[0166] The interface detection device is applied to the master server, as Figure 8 shown, the device includes:
[0167] A selection module 810, configured to select a target test server from multiple test servers;
[0168] A storage module 820, configured to generate interface information for calling the call interface of each sub-function code in the to-be-processed code; wherein, the generated interface information includes: the address of the target test server and the storage path of the sub-function code on the target test server;
[0169] A generation module 830, configured to generate interface information for calling the call interface of each sub-function code in the to-be-processed code; wherein, the generated interface information includes: the address of the target test server and the storage path of the sub-function code on the target test server;
[0170] A first sending module 840, configured to send the generated interface information to a first terminal, so that the first terminal generates a front-end page integrated with a target function based on the received interface information, and the target function is implemented based on sub-function codes corresponding to the received interface information; the front-end page is displayed on a second terminal;
[0171] A first judgment module 850, configured to judge whether a call result obtained from the second terminal is the same as a preset call result, and obtain a test result indicating whether a call interface of at least one sub-function code included in the to-be-processed code is abnormal; wherein, the call result is a call result returned by the target test server to the second terminal after calling the to-be-processed code stored locally based on a storage path in a test request sent by the second terminal; the test request is sent in response to the triggering of the target function.
[0172] Optionally, the device further includes:
[0173] A second judgment module, configured to judge, for each sub-function code included in the to-be-processed code, whether it is necessary to test a call interface for calling the sub-function code, and obtain a determination result of the sub-function code;
[0174] The storage module 820 is specifically configured to send the to-be-processed code and the determination result of at least one sub-function code included in the to-be-processed code to the target test server, so that the target test server calls at least one sub-function code included in the to-be-processed code stored locally according to the determination result and the storage path in the test request, and returns a call result to the second terminal.
[0175] Optionally, the second judgment module includes:
[0176] A first determination unit, configured to, for each sub-function code included in the to-be-processed code, if there is no previously submitted sub-function code before the to-be-processed code is submitted, determine that the determination result of the sub-function code indicates that it is necessary to test a call interface for calling the sub-function code;
[0177] A second determination unit, configured to, if there is a previously submitted sub-function code before the to-be-processed code is submitted, determine the currently effective sub-function codes and the currently non-abnormal sub-function codes; wherein, the currently effective sub-function codes are: sub-function codes whose determination results indicate that it is necessary to test the corresponding call interfaces and for which no test results have been obtained currently; the currently non-abnormal sub-function codes are: sub-function codes recorded in the currently non-abnormal sub-function code library that have obtained test results and the test results indicate no abnormality;
[0178] A third determination unit, configured to determine that the determination result of the sub-function code indicates that the call interface for calling the sub-function code needs to be tested if there is no sub-function code with the same storage path as the sub-function code among the currently effective sub-function codes and the sub-function codes without exceptions.
[0179] The apparatus further includes:
[0180] An adding module, configured to add the to-be-processed code to the current exception-free sub-function code library for each sub-function code in the to-be-processed code if the test results of the sub-function codes indicate no exceptions, so as to update the version of the current exception-free sub-function code library.
[0181] Optionally, the interface information of the call interface of a sub-function code further includes format sub-information indicating the format of the test request and the format of the call result; the apparatus further includes:
[0182] A first determination module, configured to determine the historical exception-free sub-function codes in the historical exception-free sub-function code library for each sub-function code included in the to-be-processed code if there is no sub-function code with the same storage path as the sub-function code among the currently exception-free sub-function codes, and there is no sub-function code with the same format sub-information in the interface information of the sub-function code among the currently effective sub-function codes with the same storage path as the sub-function code.
[0183] A second determination module, configured to determine that the determination result of the sub-function code indicates that the call interface for calling the sub-function code needs to be tested if there is no sub-function code with the same storage path as the sub-function code and the same format sub-information in the interface information of the sub-function code among the historical exception-free sub-function codes.
[0184] A third determination module, configured to determine a first number and a second number if there is a sub-function code with the same storage path as the sub-function code and the same format sub-information in the interface information of the sub-function code among the historical exception-free sub-function codes; wherein, the first number is the number of sub-function codes with the same format sub-information in the interface information of the sub-function code among the historical exception-free sub-function codes with the same storage path as the sub-function code; the second number is the number of sub-function codes with the same format sub-data in the interface information of the currently effective sub-function codes among the historical exception-free sub-function codes with the same storage path as the sub-function code.
[0185] A fourth determination module, configured to determine that the determination result of the sub-function code indicates that the call interface for calling the sub-function code needs to be tested if the determined first number is less than the second number.
[0186] Figure 9 This is a schematic structural diagram of the second interface detection device provided by an embodiment of the present invention.
[0187] The interface detection device is applied to a target test server among multiple test servers. As Figure 9 shown, the device includes:
[0188] A calling module 910, configured to, when receiving a test request sent by a second terminal, call the to-be-processed code stored locally based on the storage path in the test request; wherein, the storage path in the test request is the storage path of the sub-function code in the to-be-processed code in the target test server; the to-be-processed code sent by a main control server is stored in the target test server, and the target test server is selected by the main control server from multiple test servers; the test request is sent in response to the triggering of a target function integrated in the front-end page displayed by the second terminal; the front-end page is a front-end page integrated with the target function generated by a first terminal based on the interface information received from the main control server; the target function is implemented based on the sub-function code corresponding to the received interface information; the received interface information includes: the address of the target test server and the storage path of the sub-function code in the target test server;
[0189] A return module 920, configured to return a call result to the second terminal.
[0190] Optionally, the calling module 910 is specifically configured to, according to the determination result and the storage path in the test request, call at least one sub-function code included in the to-be-processed code stored locally; wherein, the determination result is obtained by the main control server determining whether it is necessary to test the call interface for calling each sub-function code included in the to-be-processed code.
[0191] In an embodiment of the present invention, the sub-function code in the to-be-processed code is stored in the target test server selected by the machine, and interface information including the address of the target test server and the storage path of the sub-function code in the target test server is generated. Thus, when testing the call interface of each sub-function code, the test request can be sent to the address of the target test server, and when calling the call interface, the sub-function code stored locally in the target test server can be called based on the storage path in the test request, and the call result is returned, avoiding manually determining the service address in the call interface of each backend function one by one, completing the test of the call interface of the sub-function code, and improving the overall efficiency of interface testing.
[0192] An embodiment of the present invention further provides an electronic device, as Figure 10As shown in the figure, it includes a processor 1001, a communication interface 1002, a memory 1003, and a communication bus 1004. Among them, the processor 1001, the communication interface 1002, and the memory 1003 complete their mutual communication through the communication bus 1004.
[0193] The memory 1003 is used to store computer programs.
[0194] The processor 1001 is used to implement the above interface test method when executing the program stored on the memory 1003.
[0195] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0196] The communication interface is used for the communication between the above electronic device and other devices.
[0197] The memory may include a Random Access Memory (RAM), or may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0198] The above processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0199] In another embodiment provided by the present invention, a computer-readable storage medium is also provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above interface test methods are implemented.
[0200] In another embodiment provided by the present invention, a computer program product including instructions is further provided. When it runs on a computer, it causes the computer to execute any of the interface test methods in the above embodiments.
[0201] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can access, or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
[0202] It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including", or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or device including a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article, or device including the element.
[0203] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple. For the related parts, reference can be made to the corresponding descriptions in the method embodiments.
[0204] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included in the protection scope of the present invention.
Claims
1. An interface testing method, characterized in that: Applied to a master control server, the method comprises: Select a target test server from multiple test servers; Sending the code to be processed to the target test server so that the target test server stores the code to be processed, and obtaining a storage path of each sub-function code in the code to be processed in the target test server; For each sub-function code in the code to be processed, interface information of a calling interface for calling the sub-function code is generated; wherein the generated interface information includes: the address of the target test server and the storage path of the sub-function code in the target test server; Sending the generated interface information to the first terminal, so that the first terminal generates a front-end page integrating a target function based on the received interface information, wherein the target function is implemented based on a sub-function code corresponding to the received interface information; and the front-end page is displayed on the second terminal; Determine whether the calling result obtained from the second terminal is the same as the preset calling result, and obtain a test result indicating whether the calling interface of at least one sub-function code contained in the code to be processed is abnormal; wherein, the calling result is the calling result returned to the second terminal by the target test server calling the locally stored code to be processed based on the storage path in the test request sent by the second terminal; and the test request is sent in response to the triggering of the target function.
2. The method according to claim 1, characterized in that: Before sending the code to be processed to the target test server so that the target test server stores the code to be processed, the method further includes: For each sub-function code included in the code to be processed, determine whether it is necessary to test the calling interface for calling the sub-function code, and obtain a determination result of the sub-function code; The sending the code to be processed to the target test server so that the target test server stores the code to be processed includes: The code to be processed and the determination result of at least one sub-function code contained in the code to be processed are sent to the target test server, so that the target test server calls at least one sub-function code contained in the code to be processed stored locally according to the determination result and the storage path in the test request, and returns the calling result to the second terminal.
3. The method according to claim 2, characterized in that For each sub-function code included in the code to be processed, determining whether it is necessary to test the calling interface for calling the sub-function code, and obtaining the determination result of the sub-function code includes: For each sub-function code included in the code to be processed, if there is no submitted sub-function code before the code to be processed is submitted, determining that the determination result of the sub-function code indicates that a calling interface for calling the sub-function code needs to be tested; If there is a submitted sub-function code before the pending code is submitted, determine the currently effective sub-function code and the currently normal sub-function code; wherein the currently effective sub-function code is: the determination result indicates that the corresponding calling interface needs to be tested, and the sub-function code currently has no test result; the currently normal sub-function code is: the sub-function code recorded in the current normal sub-function code library that has obtained the test result and the test result indicates that there is no abnormality; If there is no sub-function code with the same storage path as the sub-function code among the currently effective sub-function codes and the sub-function codes without exception, it is determined that the determination result of the sub-function code indicates that the calling interface for calling the sub-function code needs to be tested; and / or, The method further comprises: For each sub-function code in the code to be processed, if the test result of each sub-function code indicates no abnormality, the code to be processed is added to the current sub-function code library without abnormality to update the version of the current sub-function code library without abnormality.
4. The method according to claim 3, characterized in that The interface information of the calling interface of a sub-function code also includes format sub-information indicating the format of the test request and the format of the calling result; The method further comprises: For each sub-function code included in the code to be processed, if there is no sub-function code with the same storage path as the sub-function code among the sub-function codes without exception, and there is no sub-function code with the same format sub-information in the interface information of the sub-function code among the sub-function codes with the same storage path as the sub-function code that are currently in effect, then determine the historical sub-function codes without exception in the historical sub-function code library without exception; If there is no sub-function code in the historical non-abnormal sub-function codes that has the same storage path as the sub-function code and the same format sub-information as that in the interface information of the sub-function code, then the determination result of the sub-function code indicates that the calling interface for calling the sub-function code needs to be tested; If there is a sub-function code in the history without abnormality that has the same storage path as the sub-function code and the same format sub-information as that in the interface information of the sub-function code, a first number and a second number are determined; wherein the first number is: the number of sub-function codes in the history without abnormality that has the same storage path as the sub-function code and the same format sub-information as that in the interface information of the sub-function code; the second number is: the number of sub-function codes in the history without abnormality that has the same storage path as the sub-function code and the same format sub-data as that in the interface information of the currently effective sub-function code; If the determined first number is smaller than the second number, the determination result of the sub-function code indicates that a calling interface for calling the sub-function code needs to be tested.
5. An interface testing method, characterized in that: The method is applied to a target test server among multiple test servers, and the method comprises: Upon receiving a test request sent by a second terminal, calling a locally stored code to be processed based on a storage path in the test request; wherein the storage path in the test request is a storage path of a sub-function code in the code to be processed in the target test server; the target test server stores the code to be processed sent by the master control server, and the target test server is selected by the master control server from a plurality of test servers; the test request is sent in response to a trigger of a target function integrated in a front-end page displayed by the second terminal; the front-end page is a front-end page integrated with a target function generated by the first terminal based on interface information received from the master control server; the target function is implemented by a sub-function code corresponding to the received interface information; the received interface information includes: an address of the target test server and a storage path of the sub-function code in the target test server; The calling result is returned to the second terminal.
6. The method according to claim 5, characterized in that The calling the locally stored to-be-processed code based on the storage path in the test request includes: According to the determination result and the storage path in the test request, at least one sub-function code contained in the locally stored code to be processed is called; wherein, the determination result is obtained by the main control server determining, for each sub-function code contained in the code to be processed, whether it is necessary to test the calling interface used to call the sub-function code.
7. An interface testing system, characterized in that: The system comprises: a main control server and a plurality of test servers; The master control server is used to execute the method described in any one of claims 1 to 4 above; Any one of the multiple test servers is used to execute the method described in claim 5 or 6 above.
8. An interface testing device, characterized in that: Applied to a master control server, the device comprises: A selection module is used to select a target test server from multiple test servers; A storage module, used for sending the code to be processed to the target test server so that the target test server stores the code to be processed, and obtaining a storage path of each sub-function code in the code to be processed in the target test server; A generating module, for generating, for each sub-function code in the code to be processed, interface information of a calling interface for calling the sub-function code; wherein the generated interface information includes: the address of the target test server and the storage path of the sub-function code in the target test server; A first sending module, configured to send the generated interface information to a first terminal, so that the first terminal generates a front-end page integrating a target function based on the received interface information, wherein the target function is implemented based on a sub-function code corresponding to the received interface information; and the front-end page is displayed on a second terminal; The first judgment module is used to judge whether the calling result obtained from the second terminal is the same as the preset calling result, and obtain a test result indicating whether the calling interface of at least one sub-function code contained in the code to be processed is abnormal; wherein, the calling result is the calling result returned to the second terminal by the target test server calling the locally stored code to be processed based on the storage path in the test request sent by the second terminal; and the test request is sent in response to the triggering of the target function.
9. An interface testing device, characterized in that: The device is applied to a target test server among multiple test servers, and the device includes: A calling module, used for calling the locally stored to-be-processed code based on the storage path in the test request when receiving a test request sent by the second terminal; wherein the storage path in the test request is the storage path of the sub-function code in the to-be-processed code in the target test server; the target test server stores the to-be-processed code sent by the master control server, and the target test server is selected by the master control server from multiple test servers; the test request is sent in response to the triggering of the target function integrated in the front-end page displayed by the second terminal; the front-end page is a front-end page integrated with the target function generated by the first terminal based on the interface information received from the master control server; the target function is implemented by the sub-function code corresponding to the received interface information; the received interface information includes: the address of the target test server and the storage path of the sub-function code in the target test server; A returning module is used to return the calling result to the second terminal.
10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-6 when executing a program stored in a memory.
Citation Information
Patent Citations
Interface testing method and device
CN105099811A
Software testing method, device, server and system
CN113760763A
Code testing method and device
CN115129574A
Test code generation method, automatic regression test method and device
CN118132419A
Front-end modular development method and device, electronic equipment, storage medium and computer program
CN118550538A