Interface testing method, device, electronic device and storage medium
Through the overall testing process in the interface testing method, the problem of inefficiency caused by successive calls when testing multiple interfaces is solved, and efficient testing of multiple interfaces and automated result determination are achieved.
Patent Information
- Application Number
- CN202010681672.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-15
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-07-15
AI Technical Summary
Existing interface testing methods need to be called one after another when multiple interrelated interfaces need to be tested, resulting in reduced testing efficiency.
By receiving instructions from the target user, determine the test information of the interface to be tested, including interface identification, input parameters and parameter transfer relationships, obtain the target server address information, and send an access request to receive response data, and determine the test results based on the response data and target result information. , to achieve overall testing of multiple interfaces.
It improves the efficiency of interface testing, reduces the operation of testing multiple interfaces separately, and can directly determine the test results through response data and target result information, avoiding manual comparison, and improving the automation and accuracy of testing.
Smart Images

Figure CN113760697B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, electronic equipment and storage medium for interface testing. Background Art
[0002] Interface testing is a test method that is performed during the development and operation of business systems. Through interface testing, it is possible to detect whether the interface of the business system can operate normally, so as to avoid system errors due to interface errors. Currently, the interface testing method is usually to determine and input the test data for the interface to be tested, run the test interface to be tested, and obtain the test data.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] In current interface testing, only one test interface can be called. When multiple interrelated test interfaces are required for testing, the tests can only be implemented by calling them one by one, which reduces the efficiency of interface testing. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method, device, system and storage medium for interface testing, which can solve the problem that when multiple interrelated test interfaces are required for testing, the test can only be implemented by calling the test one by one, which reduces the efficiency of interface testing.
[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for interface testing is provided.
[0007] A method for interface testing in an embodiment of the present invention includes: determining test information of each interface to be tested based on a received target user instruction, the test information including an interface identifier and input parameters of the interface to be tested, a parameter transfer relationship between the interfaces to be tested, and target result information; obtaining address information of a target server corresponding to each interface to be tested based on the interface identifier of the interface to be tested; sending an access request to the target server based on the address information and the parameter transfer relationship, the access request including the interface identifier and input parameters of the interface to be tested corresponding to the target server; receiving response data sent by the target server, and determining the test result based on the response data and the target result information.
[0008] In one embodiment, determining the test information of each interface to be tested according to the received target user instruction includes:
[0009] Receive a target user instruction, wherein the target user instruction includes an interface identifier of the interface to be tested, a target interface method corresponding to the interface to be tested, a target input parameter of the interface to be tested, and a parameter transfer relationship between the interfaces to be tested;
[0010] According to the interface identifier and the target interface method, query the input parameter template of the interface to be tested;
[0011] Determine the input parameters of the interface to be tested according to the parameter transfer relationship between the input parameter template, the target input parameter and the interface to be tested.
[0012] In yet another embodiment, before determining the input parameters of the interface to be tested according to the parameter transfer relationship between the input parameter template, the target input parameter and the interface to be tested, the method further includes:
[0013] According to the interface identifier, query the parsing data packet corresponding to the interface to be tested, wherein the parsing data packet is used to parse the input parameter template corresponding to the interface to be tested;
[0014] The input parameter template corresponding to the interface to be tested is parsed by the parsing data packet.
[0015] In yet another embodiment, the parameter transfer relationship includes a correspondence between input parameters of the interface to be tested and response data of other interfaces to be tested;
[0016] The step of determining, according to the parameter transfer relationship between the input parameter template, the target input parameter, and the interface to be tested, that the test information includes the input parameters of the interface to be tested comprises:
[0017] According to the first preset identifier, the target input parameter replaces the parameter to be replaced in the input parameter template, and according to the second preset identifier and the corresponding relationship, the input parameter corresponding to the response data of other interfaces to be tested in the input parameter template is replaced with the response data of other interfaces to be tested, so as to obtain the input parameters of the interface to be tested.
[0018] In yet another embodiment, acquiring address information of a target server corresponding to each interface to be tested according to the interface identifier of the interface to be tested includes:
[0019] Sending an address request to an interface center, wherein the address request includes an interface identifier of the interface to be tested;
[0020] Receive and display the group information returned by the interface center, the group information including the grouping information and identification of the server corresponding to the interface to be tested;
[0021] Receive a test server instruction, the test server instruction including target server information corresponding to the interface to be tested determined from the group information, the target server information including information of the group to which the target server belongs and / or an identifier of the target server;
[0022] Sending target server information to the interface center;
[0023] Receive the address information of each target server sent by the interface center.
[0024] In yet another embodiment, the target result information includes a to-be-compared data identifier and an expected result corresponding to the to-be-compared data identifier;
[0025] The determining of the test result according to the response data and the expected test result includes:
[0026] Filtering the response result corresponding to the identifier of the data to be compared from the response data;
[0027] Comparing the difference between the response result and the expected result according to the data identifier to be compared;
[0028] The difference between the response result and the expected result is determined as the test result.
[0029] In yet another embodiment, determining the test information of each interface to be tested according to the received target user instruction includes:
[0030] receiving a target user instruction, wherein the target user instruction includes an identifier of a target test case, and the target test case is pre-stored;
[0031] According to the identifier of the target test case, obtaining the test information of the target test case;
[0032] The test information of the target test case is determined as the test information of the interface to be tested.
[0033] In yet another embodiment, determining the test information of each interface to be tested according to the received target user instruction includes:
[0034] Receive a target user instruction, the target user instruction including an identifier of a target test case and a target input parameter of the interface to be tested, the target test case being pre-stored;
[0035] According to the identifier of the target test case, obtaining the interface identifier, parameter transfer relationship and input parameters of the test interface in the target test case, and the target result information of the target test case;
[0036] Determine the input parameters of the interface to be tested according to the input parameters of the test interface in the target test case and the target input parameters of the interface to be tested;
[0037] The test information of each interface to be tested is determined according to the input parameters of the interface to be tested, the interface identifier and parameter transfer relationship of the test interface in the target test case, and the target result information of the target test case.
[0038] In yet another embodiment, the target result information includes an interface identifier and input parameters of the target interface, and a parameter transfer relationship between the target interfaces;
[0039] Before determining the test result according to the response data and the target result information, the method further includes:
[0040] According to the interface identifier of the target interface, acquiring the address information of the server corresponding to each of the target interfaces;
[0041] According to the server address information corresponding to the target interface and the parameter transmission relationship of the target interface, a target access request is sent to the server corresponding to the target interface, and response data corresponding to the target interface sent by the server corresponding to the target interface is received, wherein the target access request includes an interface identifier and input parameters of the target interface;
[0042] Determining the test result according to the response data and the target result information includes:
[0043] A test result is determined according to the response data corresponding to the target interface and the response data sent by the target server.
[0044] In yet another embodiment, after determining the test result according to the response data and the target result information, the method further includes:
[0045] The test result is sent to a target address, which is preset.
[0046] To achieve the above objective, according to another aspect of an embodiment of the present invention, a device for interface testing is provided.
[0047] An interface testing device according to an embodiment of the present invention comprises: a determination unit, for determining test information of each interface to be tested according to a received target user instruction, the test information comprising an interface identifier and input parameters of the interface to be tested, a parameter transfer relationship between the interfaces to be tested and target result information; an acquisition unit, for acquiring address information of a target server corresponding to each interface to be tested according to the interface identifier of the interface to be tested; a sending unit, for sending an access request to the target server according to the address information and the parameter transfer relationship, the access request comprising the interface identifier and input parameters of the interface to be tested corresponding to the target server; the determination unit is also for receiving response data sent by the target server, and determining the test result according to the response data and the target result information.
[0048] In one embodiment, the determining unit is specifically configured to:
[0049] Receive a target user instruction, wherein the target user instruction includes an interface identifier of the interface to be tested, a target interface method corresponding to the interface to be tested, a target input parameter of the interface to be tested, and a parameter transfer relationship between the interfaces to be tested;
[0050] According to the interface identifier and the target interface method, query the input parameter template of the interface to be tested;
[0051] Determine the input parameters of the interface to be tested according to the parameter transfer relationship between the input parameter template, the target input parameter and the interface to be tested.
[0052] In yet another embodiment, the determining unit is specifically configured to:
[0053] According to the interface identifier, query the parsing data packet corresponding to the interface to be tested, wherein the parsing data packet is used to parse the input parameter template corresponding to the interface to be tested;
[0054] The input parameter template corresponding to the interface to be tested is parsed by the parsing data packet.
[0055] In yet another embodiment, the parameter transfer relationship includes a correspondence between input parameters of the interface to be tested and response data of other interfaces to be tested;
[0056] The determining unit is specifically configured to:
[0057] According to the first preset identifier, the target input parameter replaces the parameter to be replaced in the input parameter template, and according to the second preset identifier and the corresponding relationship, the input parameter corresponding to the response data of other interfaces to be tested in the input parameter template is replaced with the response data of other interfaces to be tested, so as to obtain the input parameters of the interface to be tested.
[0058] In yet another embodiment, the acquisition unit is specifically configured to:
[0059] Sending an address request to an interface center, wherein the address request includes an interface identifier of the interface to be tested;
[0060] Receive and display the group information returned by the interface center, wherein the group information includes the grouping information and identification of the server corresponding to the interface to be tested;
[0061] Receive a test server instruction, the test server instruction including target server information corresponding to the interface to be tested determined from the group information, the target server information including information of the group to which the target server belongs and / or an identifier of the target server;
[0062] Sending target server information to the interface center;
[0063] Receive the address information of each target server sent by the interface center.
[0064] In yet another embodiment, the target result information includes a to-be-compared data identifier and an expected result corresponding to the to-be-compared data identifier;
[0065] The determining unit is specifically configured to:
[0066] Filtering the response result corresponding to the identifier of the data to be compared from the response data;
[0067] Comparing the difference between the response result and the expected result according to the data identifier to be compared;
[0068] The difference between the response result and the expected result is determined as the test result.
[0069] In yet another embodiment, the determining unit is specifically configured to:
[0070] receiving a target user instruction, wherein the target user instruction includes an identifier of a target test case, and the target test case is pre-stored;
[0071] According to the identifier of the target test case, obtaining the test information of the target test case;
[0072] The test information of the target test case is determined as the test information of each interface to be tested.
[0073] In yet another embodiment, the determining unit is specifically configured to:
[0074] Receive a target user instruction, the target user instruction including an identifier of a target test case and a target input parameter of the interface to be tested, the target test case being pre-stored;
[0075] According to the identifier of the target test case, obtaining the interface identifier, parameter transfer relationship and input parameters of the test interface in the target test case, and the target result information of the target test case;
[0076] Determine the input parameters of the interface to be tested according to the input parameters of the test interface in the target test case and the target input parameters of the interface to be tested;
[0077] The test information of the interface to be tested is determined according to the input parameters of the interface to be tested, the interface identifier and parameter transfer relationship of the test interface in the target test case, and the target result information of the target test case.
[0078] In yet another embodiment, the target result information includes an interface identifier and input parameters of the target interface, and a parameter transfer relationship between the target interfaces;
[0079] The acquisition unit is further configured to acquire address information of a server corresponding to each of the target interfaces according to the interface identifier of the target interface;
[0080] The sending unit is further used to send a target access request to the server corresponding to the target interface according to the address information of the server corresponding to the target interface and the parameter transmission relationship of the target interface, and receive response data corresponding to the target interface sent by the server corresponding to the target interface, wherein the target access request includes an interface identifier and input parameters of the target interface;
[0081] The determining unit is specifically configured to determine a test result according to the response data corresponding to the target interface and the response data sent by the target server.
[0082] In yet another embodiment, the sending unit is further configured to send the test result to a target address, and the target address is preset.
[0083] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.
[0084] An electronic device according to an embodiment of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the interface testing method provided by the embodiment of the present invention.
[0085] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer readable medium is provided.
[0086] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, the interface testing method provided by the embodiment of the present invention is implemented.
[0087] An embodiment of the above invention has the following advantages or beneficial effects: In the embodiment of the present invention, according to the target user instruction, the test information of each interface to be tested can be determined, such as the interface identification and input parameters of each interface to be tested, the parameter transfer relationship between the interfaces to be tested, and the target result information; then, according to the interface identification of the interface to be tested, the address information of the server corresponding to each interface to be tested can be obtained; then, according to the address information and the parameter transfer relationship, after sending an access request to the server, the response data returned by the server can be received, and the test result can be determined according to the response data and the target result information. In this way, in the embodiment of the present invention, for the interface to be tested, the parameter transfer relationship between the test interfaces can be tested, and multiple interfaces to be tested can be tested simultaneously in an overall test manner, and the test results of multiple interfaces to be tested can be obtained, thereby reducing the operation of testing multiple interfaces to be tested separately and improving the efficiency of interface testing. In addition, in the embodiment of the present invention, the target result information can be determined in advance, so that after obtaining the response data of the interface to be tested during the test, the test result can be directly determined by the response data and the target result information, without the need to perform manual comparison and other operations, thereby improving the efficiency of interface testing.
[0088] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0090] Figure 1 is a schematic diagram of a main process of a method for interface testing according to an embodiment of the present invention;
[0091] Figure 2 is a schematic diagram of a setting interface of various input parameters according to an embodiment of the present invention;
[0092] Figure 3 is a schematic diagram of an interface input interface according to an embodiment of the present invention;
[0093] Figure 4 is a schematic diagram of an interface for setting a test case periodic execution mode according to an embodiment of the present invention;
[0094] Figure 5is a schematic diagram of a main process of a method for determining a test result according to an embodiment of the present invention;
[0095] Figure 6 This is a schematic diagram of a test case entry interface of an HTTP interface according to an embodiment of the present invention;
[0096] Figure 7 is a schematic diagram of an interface for setting batch execution of test cases according to an embodiment of the present invention;
[0097] Figure 8 is a schematic diagram of main units of an interface testing device according to an embodiment of the present invention;
[0098] Fig. 9 is another exemplary system architecture diagram to which the embodiments of the present invention can be applied;
[0099] Fig.10 It is a schematic diagram of the structure of a computer system suitable for implementing the embodiment of the present invention. DETAILED DESCRIPTION
[0100] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0101] It should be pointed out that the embodiments of the present invention and the features in the embodiments may be combined with each other if there is no conflict.
[0102] An embodiment of the present invention provides an interface testing platform, which can be used to test an interface and is suitable for testing one or more interfaces. In an embodiment of the present invention, each interface can be pre-configured in the interface testing platform, and the configuration content includes the interface information of each interface. In the interface testing platform, the interface can usually be configured according to different business systems, so the interface information may include an interface identifier, a business system and business line to which the interface belongs, an interface method corresponding to the interface, and an input parameter template corresponding to the interface method. The interface identifier can be used to uniquely identify the interface, which may include the interface name, the business system and / or business line to which the interface belongs, and the like. The business line can be divided according to the functions included in the business, for example, it may include inventory, order management, and the like. Each business line includes one or more business systems. For example, when the business line is inventory, it may include business systems such as inventory pre-occupancy and inventory deduction. Each interface may correspond to one or more interface methods. For example, the interface method corresponding to the order query interface includes order details query, order fission query, and the like. Each interface method can correspond to an input parameter template. The input parameter template is a template for the input parameters corresponding to the interface method. The input parameter template includes parameters that need to be replaced. The parameters that need to be replaced are the parameters specifically input during interface testing. In the input parameter template, a replacement identifier can be set for the parameters that need to be replaced. During interface testing, the parameters that need to be replaced in the input parameter template are replaced by the replacement identifier.
[0103] In the embodiment of the present invention, the interface may include an HTTP type interface, a JSF type interface, etc. The input parameter template of each interface may include multiple expressions, for example, ordinary variables, array variables, simple functions, and simple functions may include UUID, random numbers, current date, timestamp, etc.
[0104] Among them, ordinary variables can define the variable type used to replace the expression in the input parameter at one time. For example, the variable name is pin. Since pin is a string type, the expression in the input template can be expressed as {"pin":"${pin}"}. If it is a numeric type variable, the expression in the input template can be expressed without quotation marks. Ordinary array variables can define the variable type used to cyclically replace the expression in the input parameter. For example, the variable name can be orderIds, and the variable value can enter multiple values, using "," or carriage return as a separator. The expression in the input template can be expressed as {"orderId":"${orderIds}"}. When the interface test is executed, the variable value of each orderId can be traversed, and the expression of the input parameter can be replaced to run the test. JSON array variables can be defined to replace the variable type in the input parameter expression in a loop. For example, the variable name is pinAndOrderIds, and the variable value can be entered into multiple groups of json objects, such as {"orderId":56289232320,"pin":"sunya06"}, with "#" or carriage return as separators. The expression in the input parameter template can be expressed as "orderId":${pinAndOrderIds.orderId} and "pin":"${pinAndOrderIds.pin}". When the interface test is running, it will loop through each orderId and replace the input parameter expression to run (orderId is a numeric type, the expression can be unquoted, pin is a string type, and the expression is quoted). UUID can be defined as a variable type that can generate a 32-bit hexadecimal random number, which can replace the fields that are not allowed to be repeated in the input parameter template. For example, the variable name is myUUID, and the expression in the input parameter template can be expressed as {"uuid":"${myUUID}"}. Random number can define a variable type that generates 11 random digits by default. The number of random digits can be specified by the variable value. For example, if the variable name is random, the variable value can be set to 1 to 16, which means that a random number of 1 to 16 digits is generated. The expression in the input template can be expressed as {"orderId":${random}}. Current date can define a variable type that generates the current time in the format of yyyy-MM-dd HH:mm:ss by default. The time format can be specified by the variable value. For example, if the variable name is now, the variable value can be set to yyyy-MM-dd, and the expression in the input template can be expressed as {"createDate":"${now}"}. Timestamp can define a variable type that generates the current timestamp by default. For example, if the variable name is timestamp, the expression in the parameter template can be expressed as {"systemtime":${timestamp}}.
[0105] In addition, system-defined functions such as UUID, random number, current date, and timestamp can also be written into the input template directly using the function name instead of variables. The details are as follows: UUID function: {"uuid":"${uuid()}"}; random number function: {"random":${random()}}, or specify the number of digits {"random":${random(9)}}; current date function: 1. {"createTime":"${date()}"}, 2. Specify the date format {"createDate":"${date('yyyy-MM-dd')}"}, 3. Specify the number of days to add or subtract {"expectDate":"${date('yyyy-MM-dd',10)}"}, which is the current date + 10 days; timestamp function: {"timestamp":${timestamp}}.
[0106] After configuring each interface in the interface test platform, an input interface for the test information of the interface to be tested can be provided to the user. Through the input interface, the user can input information related to the test information of the interface to be tested to implement the test of the interface to be tested.
[0107] It should be noted that since each interface in the interface testing platform is configured according to different business systems, the interface calling permissions can be set for each interface test user so that each interface can be tested safely. Usually, interface calls can be controlled by permission according to business lines. Under the business line or business system corresponding to each interface configuration, if a user needs to call an interface that is not within his or her permission, he or she can obtain the calling permission through permission application and other methods, such as adding the user to the group member list corresponding to the interface.
[0108] The embodiment of the present invention provides a method for interface testing, which can be executed by an interface testing platform, such as Figure 1 As shown, the method includes the following steps.
[0109] S101: Determine test information of each interface to be tested according to a received target user instruction.
[0110] The test information includes the interface identifier and input parameters of the interface to be tested, the parameter transfer relationship between the interfaces to be tested, and the target result information. When multiple interfaces are tested simultaneously, the corresponding test information can be determined for each interface to be tested.
[0111] When the user performs interface testing, he can input instructions, i.e., user instructions, through the interface provided by the interface testing platform. The target user instructions are user instructions related to the test information. The input parameters are the input parameters of the interface to be tested corresponding to this interface test. In the embodiment of the present invention, multiple interfaces are tested, and there is a logical order between the interfaces, that is, the input parameters of an interface can include the response data of other interface test runs, that is, there is a transfer relationship between the parameters of the interfaces to be tested. Therefore, in order to ensure the accurate execution of the interface test, the parameter transfer relationship between the interfaces to be tested is also required in the test information.
[0112] In the embodiment of the present invention, the target result information is used to compare with the response data of the interface to be tested, which may specifically be an ideal result, a comparison result, an expected result or a correct result, etc. corresponding to the interface to be tested.
[0113] When the target result information is result information for comparison, since sometimes the interface test does not need to compare the response data of all interfaces to be tested, in the embodiment of the present invention, the target result information may only include the result information that needs to be compared.
[0114] In one implementation of an embodiment of the present invention, this step can be executed as follows: receiving a target user instruction, the target user instruction including an interface identifier of the interface to be tested, a target interface method corresponding to the interface to be tested, a target input parameter of the interface to be tested, and a parameter transfer relationship between the interfaces to be tested; querying an input parameter template of the interface to be tested according to the interface identifier and the target interface method; determining the input parameters of the interface to be tested according to the parameter transfer relationship between the input parameter template, the target input parameter, and the interface to be tested.
[0115] The interface testing platform receives target user instructions input by the user. The target user instructions include the interface identifier of the interface to be tested, the target interface method corresponding to the interface to be tested, the target input parameters of the interface to be tested, and the parameter transfer relationship between the interface to be tested. Therefore, the interface identifier of the interface to be tested and the parameter transfer relationship between the interface to be tested can be directly determined according to the target user instructions. The interface testing platform can determine the function to be tested of the interface to be tested according to the interface identifier of the interface to be tested and the target interface method corresponding to the interface to be tested. At the same time, the input parameter template corresponding to this test can be queried according to the interface identifier of the interface to be tested and the target interface method corresponding to the interface to be tested. Then, the parameters that need to be replaced in the input parameter template can be replaced according to the parameter transfer relationship between the target input parameters and the interface to be tested, and the input parameters corresponding to this test can be obtained. Figure 2 As shown in the figure, it is a schematic diagram of an interface for users to input target input parameters. The interface test platform can parse the input parameter template and display it by parsing the interface identifier and the target interface method, such as Figure 2 As shown in the interface, users can Figure 2 In the interface shown, the target parameters are entered based on the input parameter template, and the personalized input parameters, i.e., input parameters, of this interface test are saved by clicking the Save button.
[0116] In an embodiment of the present invention, an identifier can be pre-set in the input parameter template to indicate which ones need to be replaced. Specifically, the parameters in the input parameter template that need to be replaced by the target input parameter can be set to a first preset identifier, so that according to the first preset identifier, the target input parameter can be replaced with the parameters to be replaced in the input parameter template. The parameter transfer relationship can include the corresponding relationship between the input parameters of the interface to be tested and the test results of other interfaces to be tested, that is to say, the response data after some interfaces to be tested are the input parameters of other interfaces to be tested, so when determining the input parameters of each interface to be tested, it is necessary to consider whether the input parameters have a corresponding relationship with the response data of other interfaces to be tested. If so, when determining the input parameters, it is necessary to replace them according to the corresponding relationship. Specifically, the parameters in the input parameter template that need to be replaced according to the parameter transfer relationship can be set to a second preset identifier, so according to the second preset identifier and the corresponding relationship, the input parameters corresponding to the response data of other interfaces to be tested in the input parameter template are replaced with the response data of other interfaces to be tested. The input parameters of the interfaces to be tested can be obtained through the above process.
[0117] For example, there is a parameter passing relationship between the interface to be tested A and the interface to be tested B, and a response data in the interface to be tested A is an input parameter in the interface to be tested B. At this time, the input parameter in the interface to be tested B can be replaced with an expression representing the corresponding response data in the interface to be tested A in the input parameter template of the interface to be tested B, which can be achieved through the ${{}} format.
[0118] Specifically, the response result after the tested interface A runs may include: "orderState":{"orderId":77658266781,}. At this time, the orderId value in the above response data is the input parameter of the tested interface B, and the input parameter of the tested interface B can be expressed as: {"orderId": "${{orderState.orderId}}" ,}, through the above expression, the parameter transfer between the interface to be tested A and the interface to be tested B can be realized.
[0119] It should be noted that, in an embodiment of the present invention, the input parameter template of each interface to be tested sometimes needs to be parsed by the corresponding parsing data packet, so before determining the input parameters of the interface to be tested, the parsing data packet corresponding to the interface to be tested can also be queried according to the interface identifier. The parsing data packet can specifically be a jar package, which can be provided to the interface testing platform by the server corresponding to the interface to be tested. The interface testing platform can obtain the parsing data packet by configuring the maven dependency corresponding to the interface to be tested. The interface testing platform can also query the parsing data packet according to the user's instructions, specifically after receiving the user's instruction to call the parsing data packet, query the parsing data packet corresponding to the interface to be tested, if the parsing data packet corresponding to the interface to be tested is queried, it can be prompted to the user by lighting up the display icon; if the parsing data packet corresponding to the interface to be tested is not queried, it can be prompted to the user by not lighting up the display icon. The interface testing platform can also be provided by setting an icon for the user to click, and the user clicking the icon indicates that the user sends an instruction to call the parsing data packet.
[0120] In another implementation of the embodiment of the present invention, each interface test executed can be stored as a test case, and the test case can store the input data and test results of the interface test, so as to query or re-execute the completed interface test. The input data may include the test information of each interface to be tested, and the address information of the server corresponding to each interface to be tested. The interface testing platform may set the identification of the test case for the stored test case, so the input data and test results included by the test user can be queried through the identification of the test case. Therefore, in the embodiment of the present invention, this step can also be specifically performed as follows: receiving a target user instruction, the target user instruction includes the identification of a target test case, and the target test case is pre-stored; according to the identification of the target test case, obtaining the test information of the target test case; determining the test information of the target test case as the test information of each interface to be tested.
[0121] After the interface testing platform receives the target user instruction, the target user instruction includes the identification of the target test case, so the interface testing platform can directly obtain the test information of the target test case according to the identification of the target test case, and can also determine the test information of each interface to be tested. In this way, the test information of the interface to be tested can be determined directly by copying the existing test case, without the need for the user to re-enter it, thereby saving user operations when repeatedly testing the interface to be tested and improving test efficiency.
[0122] In some scenarios, it is sometimes necessary to perform different interface tests on each interface to be tested by inputting different input parameters. In these interface tests, only the input parameters are different in the test information of each interface to be tested. At this time, the user can redetermine the input parameters for the existing test cases through the interface testing platform to implement the test of each interface to be tested. So specifically, this step can be specifically performed as follows: receiving the target user instruction, the target user instruction includes the identification of the target test case and the target input parameters of the interface to be tested, and the target test case is pre-stored; according to the identification of the target test case, obtain the interface identification, parameter transfer relationship and input parameters of the test interface in the target test case, and the target result information of the target test case; according to the input parameters of the test interface in the target test case and the target input parameters of the interface to be tested, determine the input parameters of the interface to be tested; according to the input parameters of the interface to be tested, the interface identification and parameter transfer relationship of the test interface in the target test case, and the target result information of the target test case, determine the test information of each interface to be tested.
[0123] In the above process, the target user instruction includes the identification of the target test case and the target input parameter of the interface to be tested, indicating that the existing test case is used but the input parameters are modified. At this time, the test interface platform can query the information of the target test case according to the identification of the target test case, including the interface identification, parameter transfer relationship and input parameters of the test interface in the target test case, and the target result information of the target test case. Since the input parameters of the target test case need to be modified in this test, the input parameters of the test interface in the target test case can be modified according to the target input parameter of the interface to be tested in the embodiment of the present invention, and the input parameters of the interface to be tested can be determined, and then the input parameters of the interface to be tested, the interface identification and parameter transfer relationship of the test interface in the target test case, and the target result information of the target test case are determined as the test information of each interface to be tested. In this way, when the interface to be tested with only different input parameters is repeatedly tested, the user input operation can be reduced and the efficiency of the interface test can be improved.
[0124] S102: Acquire address information of a target server corresponding to each interface to be tested according to the interface identifier of the interface to be tested.
[0125] After the interface identifiers of the interfaces to be tested are determined, address information of target servers corresponding to the interfaces to be tested may be obtained based on the interface identifiers of the interfaces to be tested.
[0126] In the embodiment of the present invention, the address information of the target server corresponding to each interface can be pre-stored in the interface testing platform, so the address information of the target server corresponding to each interface to be tested can be directly obtained through the interface identifier.
[0127] Each interface is usually published to the interface center, and the interface center can store the information of each interface, including the interface identifier, interface grouping, and the address information of the server corresponding to the interface. Since there are multiple servers that can provide the same interface service, that is, multiple servers can provide services corresponding to the same interface, that is, one interface corresponds to multiple servers, so the interface center can divide these servers corresponding to the same interface into one or more groups. During the interface test, the interface corresponding to a certain server can be tested, or the interfaces corresponding to a group of servers can be tested. Therefore, in this step, after determining the interface identifier of the interface to be tested, the interface identifier can be sent to the interface center, and the interface center can return the address information of the target server corresponding to the interface identifier to the interface testing platform, so that the interface testing platform obtains the address information of the target server corresponding to each interface to be tested.
[0128] Therefore, this step can also be executed as: sending an address request to the interface center, the address request includes the interface identifier of the interface to be tested; receiving and displaying the group information returned by the interface center, the group information includes the group information and identifier of the server corresponding to the interface to be tested; receiving the test server instruction, the test server instruction includes the target server information corresponding to the interface to be tested determined from the group information; sending the target server information to the interface center; receiving the address information of the target server sent by the interface center.
[0129] After the interface test platform sends an address request to the interface center, the interface center can query the corresponding server group information according to the interface identifier and return it to the interface test platform. The interface test platform can display the group information returned by the interface center so that the user can select the server to be tested. Then the interface test platform can receive the test server instruction input by the user. The test server instruction indicates the target server information corresponding to the interface to be tested. The interface test platform can determine the target server information corresponding to the interface to be tested according to the server instruction, that is, the server corresponding to the interface to be tested. In this way, the interface test platform sends the target server information to the interface center, so that the address information of the target server can be obtained. Among them, the group information may include the grouping information of the server corresponding to the interface to be tested, and the address information of the server included in each group. If the server corresponding to the interface to be tested is not grouped, it can be assumed that the server corresponding to the interface to be tested belongs to the same group. The target server information includes the information of the group to which the target server belongs and / or the identifier of the target server. The user can select a group of servers as the target server. In this case, the target server information only needs to include the information of the group to which the target server belongs. The user can also select one or more servers as the target server. In this case, if the identifiers of the servers are different, the target server information can include only the identifier of the target server, or can include the information of the group to which the target server belongs and the identifier of the target server. If there are servers with the same identifier between the groups, the target server information needs to include the information of the group to which the target server belongs and the identifier of the target server.
[0130] In the embodiment of the present invention, the identifier of the server may be the address of each server, such as an IP address. The interface testing platform may obtain the identifier of each interface to be tested, the target interface method, the IP address of the target server, etc. for each target server through jsfOpenApi, and display them in a list. At runtime, the interface to be tested is directly called by IP address.
[0131] S103: Send an access request to the target server according to the address information and parameter transfer relationship.
[0132] Among them, the access request includes the interface identifier and input parameters of the interface to be tested corresponding to the target server. After obtaining the address information of the target server corresponding to each interface to be tested, the interface testing platform can send an access request to each target server so that each target server can run according to the access request and obtain response data. The response data is the result obtained after the target server runs the interface to be tested according to the access request. Since each target server corresponds to an interface to be tested, the access request sent to the target server includes the interface identifier and input parameters of the interface to be tested corresponding to the target server.
[0133] It should be noted that in order to ensure the security of data transmission between the interface test platform and the target server, the target server usually sets a token (a verification identifier), and the target server provides the set token to the interface test platform. The interface test platform can carry the corresponding token when sending an access request to the target server. After receiving the access request, the target server can verify the token it carries, and process the access request after the verification is passed. In an embodiment of the present invention, the token can support explicit tokens and implicit tokens. The expression of implicit tokens can be {".authCode":"1",".accessToken":"abc"}, and the expression of explicit tokens can be {"authCode":"1","accessToken":"abc"}. The target server can provide an interface using the Hessian serialization method, or an interface using the MsgPack serialization method, so the serialization method of each interface to be tested can be configured in the interface test platform, and the serialization method can be switched according to user needs or instructions.
[0134] S104: receiving response data sent by the target server, and determining the test result according to the response data and the target result information.
[0135] After the target server runs, it will return the running result to the interface test platform, that is, return the response data. After receiving the response data, the interface test platform can determine the test result by comparing the response data with the target result information.
[0136] The target result information is used to compare with the response data of the interface to be tested, which can be the ideal result, comparison result, expected result or correct result of the corresponding interface to be tested, etc. Specifically, the target result information can include result information for comparison, that is, the result value directly compared with the response data of the interface to be tested, or it can be test information that can be used to compare with the response data of the interface to be tested, that is, the test information of the target interface. In this case, it is necessary to run the target result information to obtain the result value compared with the response data of the interface to be tested.
[0137] In this step, when the target result information is the result value directly compared with the response data of the interface to be tested, the target result information may include the data identifier to be compared and the expected result corresponding to the data identifier to be compared; so the step of determining the test result based on the response data and the expected test result can be executed as follows: filter the response result corresponding to the data identifier to be compared from the response data; compare the difference between the response result and the expected result based on the data identifier to be compared; and determine the difference between the response result and the expected result as the test result.
[0138] In an embodiment of the present invention, the result value to be compared included in the target result information can be in the form of a key-value pair, that is, the data identifier to be compared and the expected result corresponding to the data identifier to be compared constitute a key-value pair. Since the data included in the target result information is usually the data of the test result concerned in this test, after receiving the response data, the response result corresponding to the data identifier to be compared can be first screened out according to the data identifier to be compared, that is, the result obtained by the data identifier to be compared in this test, and then compared with the expected result of the test, so that the difference between the response result and the expected result can be compared, and then the test result can be determined.
[0139] In an embodiment of the present invention, the difference between the comparison response result and the expected result for one or more data to be compared can be obtained by fuzzy matching, and the fuzzy matching includes full fuzzy matching and partial fuzzy matching. Taking the parameter to be compared as createTime as an example, full fuzzy matching means that the response result of createTime in the response data is the same as the expected result by default no matter what it is, and the specific expression of full fuzzy matching can be ${*}, and the expected result can be expressed as {"createTime":"${*}"}, which means that the value of createTime in the response data can be judged without judgment and is the same by default. Taking the parameter to be compared as createTime as an example, partial fuzzy matching means that the response result of createTime in the response data only needs to include the partially matched parameters to be considered the same as the expected result, and the specific expression of partial fuzzy matching can be partial fuzzy matching: ${abc?}, abc is the partially matched parameter, such as 2019, and the specific expected result can be expressed as {"createTime":"${2019?}"}, which means that in the response result, createTime can be considered the same as the expected result as long as it contains 2019.
[0140] When the target result information is result information used for comparison, since sometimes the interface test does not need to compare the response data of all interfaces to be tested, in an embodiment of the present invention, the target result information may only include the result information that needs to be compared, and at this time, only the result information corresponding to the target result information in the response data may be compared.
[0141] In the embodiment of the present invention, the interface to be tested can test multiple interfaces to be tested at the same time in an overall test manner by testing the parameter transfer relationship between the test interfaces, and the test results of multiple interfaces to be tested can be obtained, thereby reducing the operation of testing multiple interfaces to be tested separately and improving the efficiency of interface testing. In addition, in the embodiment of the present invention, after obtaining the response data of the interface to be tested during the test, the test result can be directly determined by the response data and the target result information, without the need for manual comparison and other operations, thereby improving the efficiency of interface testing.
[0142] It should be noted that during interface testing, sometimes the interface testing platform may not have configured the interface to be tested. In this case, the interface to be tested can be temporarily configured according to the interface entry template. The specific interface entry interface can be as follows: Figure 3 shown.
[0143] In an embodiment of the present invention, each interface test can be saved as a test case, and each test case can be set to be executed repeatedly, so that the interface test can be executed again periodically or at a set time point. The specific periodic execution method can be implemented according to the user input instruction. For example, multiple time points can be set to trigger the execution of the test case. And in the implementation of the present invention, the address information for receiving the test results can be set, so that the test results of each execution can be sent to the address information, and the specific address information can be the address information of the email. The test results are usually stored in a log file. In order to facilitate users to view the periodic execution history log, the storage time of the log details can be set. The specific storage time can be set according to the needs, or the log details can be set to be viewed via email. Specifically, the interface for setting the test case periodic execution method can be as follows Figure 4 As shown. And for the test cases of the interfaces to be tested belonging to the same business line, a use case set for interface monitoring can be uniformly set to monitor the test cases that need to be monitored within the business line. In this way, the call report of each interface to be tested can be realized at a fixed time, so that problems in the interface test can be discovered in time. In an embodiment of the present invention, the user can collect the test information of the interface that often needs to be called and tested. For example, the interface testing platform can provide a favorite button. After the user clicks the favorite button, it indicates that the corresponding interface is collected. The interface testing platform can save the test information of the interface to the user's favorites, so that the user can quickly find the interface in subsequent tests. At the same time, after the user clicks the favorite button, the interface testing platform can prompt the user that the collection operation has been performed by lighting up (displaying a fixed color) the collection icon.
[0144] In an embodiment of the present invention, the use case details of the test case can also be imported. For example, if the information of the interface to be tested included in other test cases can be used in the current interface test, the information of the interface to be tested in the test case can be directly copied and imported into the current interface test, thereby reducing the steps of the current interface test execution. Among them, the information of the interface to be tested can include the interface identifier of the interface to be tested, the address information of the corresponding server, input parameters, etc.
[0145] exist Figure 1In the illustrated embodiment, the target result information may include result information for comparison, or may be test information that can derive a result value for comparison with the response data of the interface to be tested, i.e., test information of the target interface. When the target result information includes test information that can derive a result value for comparison with the response data of the interface to be tested, the interface test platform needs to derive a result value for comparison based on the target result information before determining the test result based on the response data and the target result information in step S104.
[0146] Specific, combined Figure 1 The embodiment shown in the figure, the embodiment of the present invention provides a method for determining a test result, and specifically describes the process of obtaining a result value for comparison based on the target result information and determining the test result in combination with the response data in step S103, wherein the target result information may include an interface identifier and input parameters of the target interface, and a parameter transfer relationship between the target interfaces, such as Figure 5 As shown, the following steps may be included.
[0147] S501: Acquire address information of a server corresponding to each target interface according to the interface identifier of the target interface.
[0148] The target result information may include the interface identifier and input parameters of the target interface, and the parameter transfer relationship between the target interfaces, that is, the test information of the target interface. In this way, the operation result of the target interface can be obtained by running the test information of the target interface, that is, the result value used to compare with the response data corresponding to the result to be tested.
[0149] In this step, the interface testing platform can obtain the address information of the server corresponding to each target interface according to the interface identifier of the target interface. The method and principle of obtaining the address information are the same as those of obtaining the target server in step S102, and will not be repeated here.
[0150] S502: Send a target access request to the server corresponding to the target interface according to the address information of the server corresponding to the target interface and the parameter transfer relationship of the target interface, and receive response data corresponding to the target interface sent by the server corresponding to the target interface.
[0151] The target access request includes an interface identifier and input parameters of the target interface.
[0152] After obtaining the address of the server corresponding to the target interface, the interface test platform can send an access request to the server corresponding to the target interface, so that the server corresponding to the target interface runs the target interface according to the access request and obtains the response data corresponding to the target interface. In the embodiment of the present invention, the implementation method and principle of sending the target access request to the server corresponding to the target interface are the same as the implementation method and principle of sending the access request to the target server in step S103, and will not be repeated here.
[0153] After obtaining the response data, the server corresponding to the target interface can send the response data corresponding to the target interface to the interface testing platform, that is, the interface testing platform can receive the response data corresponding to the target interface sent by the server corresponding to the target interface.
[0154] S503: Determine the test result according to the response data corresponding to the target interface and the response data sent by the target server.
[0155] After receiving the response data corresponding to the target interface and the response data sent by the target server, the interface testing platform can compare the response data corresponding to the target interface with the response data sent by the target server to obtain the test result.
[0156] When comparing the response data corresponding to the target interface with the response data sent by the target server, the response data corresponding to the target interface can be used as a basis to compare whether the values of the parameters to be compared in the response data corresponding to the target interface are the same as the corresponding values in the response data sent by the target server, and the different parts can be determined as test results.
[0157] It should be noted that this step is a specific execution method of the step of determining the test result according to the response data and the target result information in S104. Its execution principle is the same as that in step S104 and will not be repeated here.
[0158] In an embodiment of the present invention, the target result information is realized as test information through the above process, and the interface testing platform can realize real-time testing of the interface to be tested and the target interface and determine the test results, which not only simplifies the user's operation process in the interface test, saves time in determining the test results, but also improves the efficiency of the interface test.
[0159] It should be noted that, in the embodiment of the present invention, test cases can also be entered through step S101 and step S102. The specific process can be: create a test case set according to user instructions (the test case can be named using the project name or the test task name); then create a new test case in the test case set, and add the test case details to the created test case, such as the test information of the interface to be tested included in the test case; the newly created test cases can adjust the order of test execution, and batch modify the test information of the interface to be tested in each test case, etc. Figure 6 Shown is a schematic diagram of the test case entry interface of the HTTP interface.
[0160] In an embodiment of the present invention, each test case can be executed in sequence according to the test case detail list, that is, it can be executed according to the test information of the interface to be tested in the test case. If an interface to be tested corresponds to the address information of multiple target servers, the address information of all target servers will be traversed to perform the test before executing the next interface to be tested. The specific interface test execution method can be immediate execution, execution according to instructions, periodic or scheduled execution, etc. The executed test results can be viewed online, that is, through the interface testing platform, or by setting an email address to view the test results via email. Multiple test cases can form a test case set, and batch execution of test cases can be achieved through the test case set. For the test case set, some test cases can be selected for batch execution, or all test cases in the test case set can be batch executed. After execution is completed, the test results can also be sent to a designated mailbox via email, etc., so that users can view the execution results. Figure 7 The figure shows a schematic diagram of the interface for setting batch execution of test cases. In addition, the interface test platform can also share the entire use case set with other users through the shared use case set according to the user's instructions.
[0161] In the embodiment of the present invention, the interface testing platform does not require the user to write code. By inputting user instructions to determine the test information of the interface to be tested, the interface testing of each business scenario can be realized. For the interface calls that need to be frequently made, the interface to be tested and the input parameters that have been saved and collected can be directly selected. The relevant information of each interface to be tested can be queried through the identifier of the interface to be tested, without the need for the user to search by himself. In addition, the user monitors whether the server corresponding to each interface to be tested is in a normal state by periodically executing the test case. A variety of expressions can be used in the input parameter template of each interface to be tested, which can realize interface testing for a variety of complex scenarios.
[0162] In order to solve the problems existing in the prior art, an embodiment of the present invention provides an interface testing device 800, such as Figure 8 As shown, the device 800 includes:
[0163] The determination unit 801 is used to determine the test information of each interface to be tested according to the received target user instruction, wherein the test information includes the interface identifier and input parameters of the interface to be tested, the parameter transfer relationship between the interfaces to be tested, and the target result information;
[0164] The acquisition unit 802 is used to acquire the address information of the target server corresponding to each interface to be tested according to the interface identifier of the interface to be tested;
[0165] A sending unit 803 is used to send an access request to the target server according to the address information and the parameter transfer relationship, wherein the access request includes an interface identifier and input parameters of the interface to be tested corresponding to the target server;
[0166] The determining unit 801 is further configured to receive response data sent by the target server, and determine a test result according to the response data and the target result information.
[0167] It should be understood that the manner of implementing the embodiments of the present invention is different from the Figure 1 The method of the illustrated embodiment is the same and will not be repeated here.
[0168] In an implementation manner of the embodiment of the present invention, the determining unit 801 is specifically configured to:
[0169] Receive a target user instruction, wherein the target user instruction includes an interface identifier of the interface to be tested, a target interface method corresponding to the interface to be tested, a target input parameter of the interface to be tested, and a parameter transfer relationship between the interfaces to be tested;
[0170] According to the interface identifier and the target interface method, query the input parameter template of the interface to be tested;
[0171] Determine the input parameters of the interface to be tested according to the parameter transfer relationship between the input parameter template, the target input parameter and the interface to be tested.
[0172] In another implementation of the embodiment of the present invention, the determining unit 801 is specifically configured to:
[0173] According to the interface identifier, query the parsing data packet corresponding to the interface to be tested, and the parsing data packet is used to parse the input parameter template corresponding to the interface to be tested; parse the input parameter template corresponding to the interface to be tested through the parsing data packet.
[0174] In another implementation of the embodiment of the present invention, the parameter transfer relationship includes a corresponding relationship between the input parameters of the interface to be tested and the response data of other interfaces to be tested;
[0175] The determining unit 801 is specifically configured to:
[0176] According to the first preset identifier, the target input parameter replaces the parameter to be replaced in the input parameter template, and according to the second preset identifier and the corresponding relationship, the input parameter corresponding to the response data of other interfaces to be tested in the input parameter template is replaced with the response data of other interfaces to be tested, so as to obtain the input parameters of the interface to be tested.
[0177] In another implementation of the embodiment of the present invention, the acquiring unit 802 is specifically configured to:
[0178] Sending an address request to an interface center, wherein the address request includes an interface identifier of the interface to be tested;
[0179] Receive and display the group information returned by the interface center, the group information including the grouping information and identification of the server corresponding to the interface to be tested;
[0180] Receive a test server instruction, the test server instruction including target server information corresponding to the interface to be tested determined from the group information and the target server information including information of the group to which the target server belongs and / or an identifier of the target server;
[0181] Sending target server information to the interface center;
[0182] Receive the address information of each target server sent by the interface center.
[0183] In another implementation of the embodiment of the present invention, the target result information includes a to-be-compared data identifier and an expected result corresponding to the to-be-compared data identifier;
[0184] The determining unit 801 is specifically configured to:
[0185] Filtering the response result corresponding to the identifier of the data to be compared from the response data;
[0186] Comparing the difference between the response result and the expected result according to the identifier of the data to be compared;
[0187] The difference between the response result and the expected result is determined as the test result.
[0188] In another implementation of the embodiment of the present invention, the determining unit 801 is specifically configured to:
[0189] receiving a target user instruction, wherein the target user instruction includes an identifier of a target test case, and the target test case is pre-stored;
[0190] According to the identifier of the target test case, obtaining the test information of the target test case;
[0191] The test information of the target test case is determined as the test information of each interface to be tested.
[0192] In another implementation of the embodiment of the present invention, the determining unit 801 is specifically configured to:
[0193] Receive a target user instruction, the target user instruction including an identifier of a target test case and a target input parameter of the interface to be tested, the target test case being pre-stored;
[0194] According to the identifier of the target test case, obtaining the interface identifier, parameter transfer relationship and input parameters of the test interface in the target test case, and the target result information of the target test case;
[0195] Determine the input parameters of the interface to be tested according to the input parameters of the test interface in the target test case and the target input parameters of the interface to be tested;
[0196] The test information of the interface to be tested is determined according to the input parameters of the interface to be tested, the interface identifier and parameter transfer relationship of the test interface in the target test case, and the target result information of the target test case.
[0197] In another implementation of the embodiment of the present invention, the target result information includes an interface identifier and input parameters of the target interface, and a parameter transfer relationship between the target interfaces;
[0198] The acquisition unit 802 is further configured to acquire address information of a server corresponding to each target interface according to the interface identifier of the target interface;
[0199] The sending unit 803 is further used to send a target access request to the server corresponding to the target interface according to the server address information corresponding to the target interface and the parameter transmission relationship of the target interface, and receive response data corresponding to the target interface sent by the server corresponding to the target interface, wherein the target access request includes an interface identifier and input parameters of the target interface;
[0200] The determining unit 801 is specifically configured to determine a test result according to the response data corresponding to the target interface and the response data sent by the target server.
[0201] In another implementation of the embodiment of the present invention, the sending unit 803 is further configured to send the test result to a target address, and the target address is preset.
[0202] It should be understood that the manner of implementing the embodiments of the present invention is different from the Figure 1 or Figure 2 The method of the illustrated embodiment is the same and will not be described again here.
[0203] In the embodiment of the present invention, the parameter transmission relationship between the test interfaces can be used to test multiple interfaces to be tested at the same time through the overall test method, and the test results of multiple interfaces to be tested can be obtained, thereby reducing the operation of testing multiple interfaces to be tested separately and improving the efficiency of interface testing. In addition, in the embodiment of the present invention, the target result information can be determined in advance, so that after obtaining the response data of the interface to be tested during the test, the test result can be directly determined through the response data and the target result information, without the need for manual comparison and other operations, thereby improving the efficiency of interface testing.
[0204] According to an embodiment of the present invention, the present invention also provides an electronic device and a readable storage medium.
[0205] The electronic device of the present invention comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the one processor, and the instructions are executed by the at least one processor so that the at least one processor executes the interface testing method provided in an embodiment of the present invention.
[0206] Fig. 9 An exemplary system architecture 900 is shown to which the interface testing method or interface testing apparatus according to an embodiment of the present invention may be applied.
[0207] like Fig. 9 As shown, system architecture 900 may include terminal devices 901, 902, 903, network 904 and server 905. Network 904 is used to provide a medium for communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0208] The user can use the terminal devices 901, 902, 903 to interact with the server 905 through the network 904 to receive or send messages, etc. Various client applications can be installed on the terminal devices 901, 902, 903.
[0209] The terminal devices 901 , 902 , and 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0210] The server 905 may be a server that provides various services, and may analyze and process the received data such as the product information query request, and feed back the processing result (such as product information - just an example) to the terminal device.
[0211] It should be noted that the interface testing method provided in the embodiment of the present invention is generally executed by the server 905 , and accordingly, the interface testing device is generally set in the server 905 .
[0212] It should be understood that Fig. 9 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0213] Reference below Fig.10 , which shows a schematic diagram of the structure of a computer system 1000 suitable for implementing an embodiment of the present invention. Fig.10 The computer system shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0214] like Fig.10 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0215] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 1005 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0216] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present invention are executed.
[0217] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0218] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a unit, a program segment, or a part of a code, and the above-mentioned unit, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0219] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes a determination unit, an acquisition unit, and a sending unit. The names of these units do not constitute a limitation on the units themselves in some cases, for example, the determination unit may also be described as a "unit that determines the function of the unit".
[0220] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device executes the interface test method provided by the present invention.
[0221] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for interface testing, characterized in that: include: Determine test information of each interface to be tested according to the received target user instruction, wherein the test information includes interface identifiers and input parameters of the interface to be tested, parameter transfer relations between the interfaces to be tested, and target result information; According to the interface identifier of the interface to be tested, obtaining the address information of the target server corresponding to each interface to be tested; Sending an access request to the target server according to the address information and the parameter transfer relationship, wherein the access request includes an interface identifier and input parameters of the interface to be tested corresponding to the target server; Receiving response data sent by the target server, and determining a test result according to the response data and the target result information; The step of determining the test information of each interface to be tested according to the received target user instruction includes: Receive a target user instruction, wherein the target user instruction includes an interface identifier of the interface to be tested, a target interface method corresponding to the interface to be tested, a target input parameter of the interface to be tested, and a parameter transfer relationship between the interface to be tested; the parameter transfer relationship includes a corresponding relationship between the input parameters of the interface to be tested and response data of other interfaces to be tested; According to the interface identifier and the target interface method, query the input parameter template of the interface to be tested; According to the first preset identifier, the target input parameter replaces the parameter to be replaced in the input parameter template, and according to the second preset identifier and the corresponding relationship, the input parameter corresponding to the response data of other interfaces to be tested in the input parameter template is replaced with the response data of other interfaces to be tested, so as to obtain the input parameters of the interface to be tested.
2. The method according to claim 1, characterized in that Before determining the input parameters of the interface to be tested according to the parameter transfer relationship between the input parameter template, the target input parameter and the interface to be tested, the method further includes: According to the interface identifier, query the parsing data packet corresponding to the interface to be tested, where the parsing data packet is used to parse the input parameter template corresponding to the interface to be tested; The input parameter template corresponding to the interface to be tested is parsed by the parsing data packet.
3. The method according to claim 1, characterized in that The step of acquiring address information of a target server corresponding to each interface to be tested according to the interface identifier of the interface to be tested includes: Sending an address request to an interface center, wherein the address request includes an interface identifier of the interface to be tested; Receive and display the group information returned by the interface center, wherein the group information includes the grouping information and identification of the server corresponding to the interface to be tested; Receive a test server instruction, the test server instruction including target server information corresponding to the interface to be tested determined from the group information, the target server information including information of the group to which the target server belongs and / or an identifier of the target server; Sending the target server information to the interface center; Receive the address information of each target server sent by the interface center.
4. The method according to claim 1, characterized in that: The target result information includes a to-be-compared data identifier and an expected result corresponding to the to-be-compared data identifier; The determining of the test result according to the response data and the expected test result includes: Filtering the response result corresponding to the identifier of the data to be compared from the response data; Comparing the difference between the response result and the expected result according to the identifier of the data to be compared; The difference between the response result and the expected result is determined as the test result.
5. The method according to claim 1, characterized in that The step of determining the test information of each interface to be tested according to the received target user instruction includes: receiving a target user instruction, wherein the target user instruction includes an identifier of a target test case, and the target test case is pre-stored; According to the identifier of the target test case, obtaining the test information of the target test case; The test information of the target test case is determined as the test information of each interface to be tested.
6. The method according to claim 1, characterized in that The step of determining the test information of each interface to be tested according to the received target user instruction includes: Receive a target user instruction, the target user instruction including an identifier of a target test case and a target input parameter of the interface to be tested, the target test case being pre-stored; According to the identifier of the target test case, obtaining the interface identifier, parameter transfer relationship and input parameters of the test interface in the target test case, and the target result information of the target test case; Determine the input parameters of the interface to be tested according to the input parameters of the test interface in the target test case and the target input parameters of the interface to be tested; The test information of the interface to be tested is determined according to the input parameters of the interface to be tested, the interface identifier and parameter transfer relationship of the test interface in the target test case, and the target result information of the target test case.
7. The method according to claim 1, characterized in that The target result information includes the interface identifier and input parameters of the target interface, and the parameter transfer relationship between the target interfaces; Before determining the test result according to the response data and the target result information, the method further includes: According to the interface identifier of the target interface, acquiring the address information of the server corresponding to each of the target interfaces; According to the server address information corresponding to the target interface and the parameter transmission relationship of the target interface, a target access request is sent to the server corresponding to the target interface, and response data corresponding to the target interface sent by the server corresponding to the target interface is received, wherein the target access request includes an interface identifier and input parameters of the target interface; Determining the test result according to the response data and the target result information includes: A test result is determined according to the response data corresponding to the target interface and the response data sent by the target server.
8. The method according to claim 1, characterized in that After determining the test result according to the response data and the target result information, the method further includes: The test result is sent to a target address, which is preset.
9. An interface testing device, characterized in that: include: A determination unit, configured to determine test information of each interface to be tested according to a received target user instruction, wherein the test information includes an interface identifier and input parameters of the interface to be tested, a parameter transfer relationship between the interfaces to be tested, and target result information; An acquisition unit, configured to acquire address information of a target server corresponding to each of the interfaces to be tested according to the interface identifier of the interface to be tested; A sending unit, configured to send an access request to the target server according to the address information and the parameter transfer relationship, wherein the access request includes an interface identifier and input parameters of an interface to be tested corresponding to the target server; The determining unit is further configured to receive response data sent by the target server, and determine a test result based on the response data and the target result information; The determining unit is specifically configured to: Receive a target user instruction, wherein the target user instruction includes an interface identifier of the interface to be tested, a target interface method corresponding to the interface to be tested, a target input parameter of the interface to be tested, and a parameter transfer relationship between the interface to be tested; the parameter transfer relationship includes a corresponding relationship between the input parameters of the interface to be tested and response data of other interfaces to be tested; According to the interface identifier and the target interface method, query the input parameter template of the interface to be tested; According to the first preset identifier, the target input parameter replaces the parameter to be replaced in the input parameter template, and according to the second preset identifier and the corresponding relationship, the input parameter corresponding to the response data of other interfaces to be tested in the input parameter template is replaced with the response data of other interfaces to be tested, so as to obtain the input parameters of the interface to be tested.
10. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.
11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
