A method and device for generating a test packet

By generating test messages in the interface resources and directly modifying the interface parameters, the problem of large workload in modifying test cases is solved, achieving efficient parameter management and saving manpower and time costs.

CN111078573BActive Publication Date: 2026-06-26WEBANK (CHINA)

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
WEBANK (CHINA)
Filing Date
2019-12-24
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In existing technologies, modifying test cases involves a large workload and a long work cycle, especially when interface parameters change, requiring modifications to a large number of test cases.

Method used

By obtaining the interface identifier, test messages are generated using the parameter paths and values ​​in the interface resources. Parameters can be modified directly in the interface resources, reducing the dependence on test cases and enabling the addition, modification, or deletion of parameters.

Benefits of technology

It saves manpower and time costs, reduces the workload of modifying test cases, and improves work efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111078573B_ABST
    Figure CN111078573B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a test message generation method and device, the test message is used for testing an interface; the method comprises the following steps: obtaining an interface identifier recorded in a test case; obtaining an interface parameter item and a parameter path item from an interface resource corresponding to the interface identifier, the interface parameter item comprises a parameter path of more than one parameter, and the parameter path item comprises original parameter values corresponding to the parameter paths; extracting actual parameter values corresponding to the parameter paths from the test case according to the parameter paths in the interface parameter item; and filling parameter positions corresponding to the parameter paths in the interface parameter item according to the original parameter values and / or the actual parameter values corresponding to the parameter paths, to generate a test message. By using the method, compared with the prior art, the test case modification needs not to be called, a large number of test case parameter modifications can be completed by modifying once in the interface resource, and human cost and time cost are saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of automated testing technology in financial technology (Fintech), and in particular to a method and apparatus for generating test messages. Background Technology

[0002] With the development of computer technology, more and more technologies are being applied in the financial sector, and the traditional financial industry is gradually transforming into Fintech. However, due to the security and real-time requirements of the financial industry, higher demands are being placed on technology. In today's rapidly developing network environment, most financial transactions can now be processed directly by computers. This method greatly saves human resources and allows for fast and accurate processing of financial transactions, improving the precision and real-time performance of financial transactions.

[0003] In the process of computer processing financial business, there is usually interaction between multiple systems and interaction between subsystems within each system. This requires the use of interfaces to connect the systems to realize data exchange, transmission and control management processes, as well as the logical dependencies between the systems. Accordingly, when developing multi-system interaction and application systems, it is necessary to verify the correctness and stability of the interfaces to ensure normal interaction between the systems. Existing interface testing techniques can generate messages by setting multiple pieces of information, which are then carried in HTTP requests. If the message is successfully transmitted, there is no interface exception; if the system reports an error, an interface exception occurs. Generally, one scenario of a message corresponds to one test case. For example, the message {"idCardNo":"","name":"","city":"Shenzhen"} contains three parameters: idCardNo, name, and city. If one parameter is empty, there are three test cases; if two are empty, there are three test cases; and if all three are empty, there is one test case. There are also cases where the parameters are not empty but are incorrect. Therefore, when a message has multiple parameters, a large number of test cases are generated, and complex messages can generate tens of thousands of test cases. Consequently, adding, removing, or modifying parameters may require modifying all test cases separately, resulting in a huge workload and a long cycle.

[0004] Therefore, there is an urgent need for a method and apparatus for generating test messages, which can reduce the workload of modifying test cases and shorten the work cycle. Summary of the Invention

[0005] This invention provides an automated testing method and apparatus, which solves the problems of large workload and long work cycle in modifying test cases in the prior art.

[0006] In a first aspect, embodiments of the present invention provide a method for generating a test message, the test message being used to test an interface; the method includes: obtaining an interface identifier recorded in a test case; obtaining an interface parameter item and a parameter path item from the interface resource corresponding to the interface identifier, wherein the interface parameter item contains parameter paths for one or more parameters, and the parameter path item includes original parameter values ​​corresponding to each parameter path; extracting actual parameter values ​​corresponding to the parameter paths from the test case based on the parameter paths in the interface parameter item; and filling the parameter positions corresponding to each parameter path in the interface parameter item based on the original parameter values ​​and / or the actual parameter values ​​corresponding to each parameter path, thereby generating the test message.

[0007] Using the above method, an interface identifier is set in the test case, and then the corresponding interface resource is found through the interface identifier. The interface parameter items and parameter path items are then obtained from the interface resource. The original parameter values ​​corresponding to each parameter path are obtained based on the parameter path items. The actual parameter values ​​are obtained from the test case based on the parameter path in the interface parameter items. Finally, a test message is generated based on the original parameter values ​​and the actual parameter values. Compared to existing technologies where adding, modifying, or removing parameter information requires changes to a large number of test cases, this application allows direct modification of parameters in the interface resource if modifications, additions, or deletions are needed. This eliminates the need to call the test case for modification; a large number of test case parameters can be modified simply by modifying the interface resource once, saving manpower and time costs.

[0008] In one possible design, the parameter positions corresponding to each parameter path in the interface parameter item are filled according to the original parameter value and / or the actual parameter value corresponding to each parameter path. This includes: for each parameter path in the interface parameter item, if the test case contains an actual parameter value corresponding to the parameter path, then the actual parameter value corresponding to the parameter path is filled into the parameter position corresponding to the parameter path in the interface parameter item; if the test case does not contain an actual parameter value corresponding to the parameter path, then the original parameter value corresponding to the parameter path is filled into the parameter position corresponding to the parameter path in the interface parameter item.

[0009] Using the above method, the interface parameter items include parameter paths. The actual parameter values ​​in the test case can be obtained through the parameter paths, and the corresponding actual parameter values ​​are filled into the corresponding positions of the parameter defined in the interface parameter items in the message. If the actual parameter value cannot be obtained, the original parameter value corresponding to the parameter is filled into the corresponding positions in the message corresponding to the parameter. Thus, the interface parameter items provide the position and space of the parameter in the message, and the parameter path items and test cases provide the original parameter values ​​and actual parameter values, thereby enabling the test cases to generate test messages. In this way, the message content can be modified by adding, removing, or modifying the interface parameter items and / or parameter path items.

[0010] In one possible design, the interface resource is generated in the following manner: obtaining a definition message corresponding to the interface identifier, the definition message including each definition parameter item, each definition parameter item including a parameter and an original parameter value; for each definition parameter item, determining the parameter path corresponding to the parameter in the definition parameter item; constructing the parameter path and the original parameter value into a parameter path item in the interface resource; and constructing the parameter and the parameter path into an interface parameter item in the interface resource.

[0011] Using the above method, the defined message includes defined parameter items, which contain parameters and their original values. By obtaining the parameters and their original values ​​from the defined parameter items, the parameter paths and their original values ​​from the parameter path items are retrieved, thus obtaining the parameters and their paths from the interface parameter items. This yields the interface resources, allowing test cases to call the resources from the interface parameter items and parameter path items to generate test messages. In this way, the resources of the interface parameter items and parameter path items can be modified to generate modified test messages, while retaining the original content of the defined message.

[0012] In one possible design, determining the parameter path corresponding to the parameter in the defined parameter item includes: determining the defined parameter item in the defined message according to the ordered Hashmap function, and converting the parameter in the defined parameter item into a parameter path.

[0013] By using the above method, the parameters in each defined parameter item in the definition message are converted into parameter paths through the ordered Hashmap function. This can convert each defined parameter item in the definition message into an ordered parameter path, effectively preventing test cases from calling unordered parameter paths and causing test message errors.

[0014] In one possible design, the test cases are obtained by: determining the parameter path corresponding to the parameter in the interface parameter item for the parameter that needs to be parameterized in the test cases; and constructing the actual parameter value corresponding to the parameter path in the test cases.

[0015] Using the above method, we obtain the interface parameter items from the interface resources and construct the parameter paths and actual parameter values ​​in the test cases. This allows the actual parameter values ​​to be filled into the corresponding positions and spaces in the message defined by the interface parameter items, thus obtaining the test message. In this way, the interface parameter items provide placeholder space for the corresponding parameter values ​​in the test cases.

[0016] In one possible design, the method further includes:

[0017] Receive an interface resource update instruction; and modify the interface parameter items and / or parameter path items in the interface resource indicated by the interface resource update instruction according to the interface resource update instruction.

[0018] Using the above method, the interface parameters and / or parameter path items of the interface resource are changed by receiving the interface resource update instruction, thereby enabling the test case to call the changed interface resource and obtain the updated test message.

[0019] In one possible design, modifying the interface parameter item and / or parameter path item in the interface resource indicated by the interface resource update instruction includes: adding a parameter with a fixed value to the interface parameter item, and adding a parameter with the fixed value to the parameter path item; or deleting the parameter in the parameter path item; or modifying the original parameter value of the parameter with the fixed value in the parameter path item.

[0020] Using the above method, by adding parameters with fixed values ​​to the interface parameter items and parameters with fixed values ​​to the parameter path items, fixed values ​​are added to the original test message; by deleting parameters from the interface parameter items and parameters from the parameter path items, corresponding parameter information is reduced in the original test message; by modifying the parameter values ​​of the parameters with fixed values ​​in the parameter path items, corresponding parameter information is modified in the original test message.

[0021] Secondly, embodiments of the present invention provide a test message generation apparatus, the apparatus comprising:

[0022] The acquisition module is used to acquire the interface identifier recorded in the test case; it is also used to acquire interface parameter items and parameter path items from the interface resources corresponding to the interface identifier, wherein the interface parameter item contains parameter paths for one or more parameters, and the parameter path item includes the original parameter values ​​corresponding to each parameter path;

[0023] The extraction module is used to extract the actual parameter value corresponding to the parameter path from the test case based on the parameter path in the interface parameter item;

[0024] The processing module is used to fill in the parameter positions corresponding to each parameter path in the interface parameter item according to the original parameter value and / or the actual parameter value corresponding to each parameter path, and generate the test message.

[0025] In one possible design, the processing module is specifically used to: for each parameter path in the interface parameter item, if the test case contains an actual parameter value corresponding to the parameter path, then fill the actual parameter value corresponding to the parameter path into the parameter position corresponding to the parameter path in the interface parameter item; if the test case does not contain an actual parameter value corresponding to the parameter path, then fill the original parameter value corresponding to the parameter path into the parameter position corresponding to the parameter path in the interface parameter item.

[0026] In one possible design, the processing module is further configured to: obtain a definition message corresponding to the interface identifier, the definition message including each definition parameter item, each definition parameter item including a parameter and an original parameter value; for each definition parameter item, determine the parameter path corresponding to the parameter in the definition parameter item; construct the parameter path and the original parameter value into a parameter path item in the interface resource; and construct the parameter and the parameter path into an interface parameter item in the interface resource.

[0027] In one possible design, the processing module is further configured to:

[0028] The defined parameter items in the defined message are determined using an ordered Hashmap function, and the parameters in the defined parameter items are converted into parameter paths.

[0029] In one possible design, the processing module is further configured to: determine the parameter path corresponding to the parameter in the interface parameter item for the parameter that needs to be parameterized in the test case; and construct the actual parameter value corresponding to the parameter path in the test case.

[0030] In one possible design, the processing module is further configured to: receive an interface resource update instruction; and, according to the interface resource update instruction, modify the interface parameter items and / or parameter path items in the interface resource indicated by the interface resource update instruction.

[0031] In one possible design, the processing module is further configured to: add a parameter with a fixed value to the interface parameter item, and add a parameter with the fixed value to the parameter path item; or delete a parameter in the interface parameter item, and delete the parameter in the parameter path item; or modify the original parameter value of the parameter with the fixed value in the parameter path item.

[0032] Thirdly, embodiments of this application also provide a computing device, including: a memory for storing program instructions; and a processor for calling the program instructions stored in the memory and executing the method described in various possible designs of the first aspect according to the obtained program.

[0033] Fourthly, embodiments of this application also provide a computer-readable non-volatile storage medium including computer-readable instructions that, when read and executed by a computer, cause the computer to perform the method described in various possible designs of the first aspect.

[0034] These or other implementations of this application will become clearer and easier to understand in the following description of the embodiments. Attached Figure Description

[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0036] Figure 1 A schematic diagram of the architecture of a test message generation system provided in an embodiment of the present invention;

[0037] Figure 2 A flowchart illustrating a method for generating a test message according to an embodiment of the present invention;

[0038] Figure 3 A flowchart illustrating a method for updating interface resources according to an embodiment of the present invention;

[0039] Figure 4 A flowchart illustrating a method for generating interface resources according to an embodiment of the present invention;

[0040] Figure 5 This is a schematic diagram of a HashMap data structure provided in an embodiment of the present invention;

[0041] Figure 6 A flowchart illustrating a method for generating a test message according to an embodiment of the present invention;

[0042] Figure 7 This is a schematic diagram of an apparatus for generating test messages according to an embodiment of the present invention. Detailed Implementation

[0043] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0044] First, obtain multiple messages from existing technologies, such as JSON messages like {"idCardNo":"","name":"","city":"Shenzhen"}, {"sex":"","name":"","city":"Shenzhen"}, {"sex":"","name":"","city":"Shanghai"}, etc.; then... Figure 1 This invention provides a system architecture for generating test messages. In the parsing module 101, the acquired definition message is converted into a parameter path; then, a parameter path item including the parameter path and the original parameter value, and an interface parameter item including the parameter and the parameter path are obtained. An interface resource including an interface identifier is generated. Each definition message corresponds to an interface identifier, which is stored in the interface resource and stored in the resource library 102. The testing module 103 runs test cases. The test cases generate parameters that need to be parameterized. The interface resource corresponding to the interface identifier is retrieved from the interface resource in the resource library 102 through the interface identifier in the test case. A test message is generated according to the parameters that need to be parameterized in the test case, the corresponding parameter path item in the interface resource, and the interface parameter item. This allows the sent request to carry the test message, thereby realizing the testing of the interface.

[0045] Based on this, embodiments of this application provide a flowchart of a method for generating test messages, such as... Figure 2 As shown, it includes:

[0046] Step 201: Obtain the interface identifier recorded in the test case;

[0047] Here, test cases are testing tools used to test the interfaces between system components, and interface identifiers are reference conditions used in test cases to obtain test messages.

[0048] Step 202: Obtain interface parameter items and parameter path items from the interface resources corresponding to the interface identifier. The interface parameter items contain parameter paths for one or more parameters, and the parameter path items include the original parameter values ​​corresponding to each parameter path.

[0049] Here, the interface resource corresponding to the interface identifier is obtained from the definition message. That is, firstly, the definition message corresponding to the interface identifier is obtained. The definition message includes each definition parameter item, and each definition parameter item includes a parameter and an original parameter value. For each definition parameter item, the parameter path corresponding to the parameter in the definition parameter item is determined. The parameter path and the original parameter value are used to construct the parameter path item in the interface resource. The parameter and the parameter path are used to construct the interface parameter item in the interface resource.

[0050] The definition message is a message that defines parameters and original parameter values. It can also be said to be a message in the existing test cases. Each parameter definition item in the definition message includes the parameter and the original parameter value. For example, the parameter item idCardNo is defined as {"idCardNo":""}, which corresponds to {parameter item: original parameter value item}. The defined parameter items in the defined message can be determined using an ordered Hashmap function, and the parameters in the defined parameter items can be converted into parameter paths. Therefore, according to the order of the defined parameter items in the defined message, the corresponding parameter path can be determined based on the parameters in each defined parameter item. That is, in the defined message {“idCardNo”:””,“name”:””,”city”:”Shenzhen”}, the parameter item “idCardNo” can be obtained as the parameter path / idCardNo, the parameter item “name” as the parameter path / name, and the parameter item “city” as the parameter path / city. The original parameter values ​​corresponding to the parameters in the defined parameter items are obtained, i.e., “” is &, “” is &, and “” is Shenzhen. This leads to the parameter path items, which include the parameter path and the corresponding original parameter values, i.e., / idCardNo=&, / name=&, / city=Shenzhen. The parameters and parameter paths are then used to construct interface parameter items, i.e., “idCardNo”:”$ / idCardNo$, “name”:”$ / name$, and “city”:”$ / city$.

[0051] This yields interface resources including interface identifier, parameter path items, and interface parameter items, such as:

[0052] Table 1

[0053]

[0054]

[0055] Thus, the interface resource corresponding to interface identifier 1 is obtained, and can be added to the test case.<resourceid=”1”> This allows the test case to locate the interface resource and obtain the interface parameter items.

[0056] Step 203: Extract the actual parameter value corresponding to the parameter path from the test case according to the parameter path in the interface parameter item;

[0057] Here, the actual parameter values ​​are extracted from the test case based on the parameter path in the interface parameter item. In other words, the test case needs to generate actual parameter values.

[0058] Therefore, for the parameters that need to be parameterized in the test case, the parameter path corresponding to the parameter in the interface parameter item is determined; the actual parameter value corresponding to the parameter path is constructed in the test case; that is, for the parameters that need to be parameterized in the test case, the actual parameter value corresponding to the parameter path is constructed according to the parameter path in the interface parameter item.

[0059] like,<api idCardNo=”23022719980101****”>

[0060] <output> v_idCardNo< / output>

[0061] .

[0062] Step 204: Fill in the parameter positions corresponding to each parameter path in the interface parameter item according to the original parameter value and / or the actual parameter value corresponding to each parameter path, and generate the test message.

[0063] Here, for each parameter path in the interface parameter item, if the test case contains an actual parameter value corresponding to the parameter path, then the actual parameter value corresponding to the parameter path is filled into the parameter position corresponding to the parameter path in the interface parameter item.

[0064] If the test case does not contain the actual parameter value corresponding to the parameter path, then the original parameter value corresponding to the parameter path will be filled into the parameter position corresponding to the parameter path in the interface parameter item.

[0065] That is, if the test case contains actual parameter values ​​corresponding to parameter paths, for the parameter that needs to be parameterized in the test case: idCardNo, the test case contains actual parameter values ​​23022719980101**** corresponding to parameter path / idCardNo, such as:

[0066] <api idCardNo=”23022719980101****”>

[0067] <output> v_idCardNo< / output>

[0068] .

[0069] <parameter>

[0070] <parameterpath>

[0071] / idCardNo

[0072] < / parameterpath>

[0073] <parametervalue>

[0074] v_idCardNo

[0075] < / parametervalue>

[0076] < / parameter>

[0077] Determine the parameter path of idCardNo in the interface parameter items, that is, the parameter path of idCardNo in Table 1 corresponds to $ / idCardNo$. Then, extract / idCardNo=& ​​from the parameter path items in Table 1, separate / idCardNo and null values ​​by =, parse the parameter node information, and determine... <parameterpath>The configuration includes ` / idCardNo`. The value of the parameter that needs to be parameterized, `v_idCardNo` (23022719980101****), is used to replace `$ / idCardNo$`. This gives the parameter path `$ / idCardNo$` in the interface parameter field, and the corresponding actual parameter value `23022719980101****`. This is used to construct the parameter path and actual parameter value in the test case.

[0078] Finally, as shown in Table 1, the actual parameter values ​​are filled into the positions corresponding to the positions of the parameter items {"idCardNo":"$ / idCardNo$","name":"$ / name$","city":"$ / city$"} in the interface parameter items. If the actual parameter value of name is Mingyang, and the actual parameter value of city is Shenzhen, then the final test message is: 23022719980101****, Mingyang, Shenzhen.

[0079] If the test case does not contain the actual parameter value corresponding to the parameter path, or if the test case does not generate the actual parameter value corresponding to the parameterized idCardNo during execution; that is, if there is no...<api idCardNo=”23022719980101****”>

[0080] <output> v_idCardNo< / output>

[0081] .

[0082] For the parameter that needs to be parameterized in the test case: idCardNo, for example:

[0083] <parameter>

[0084] <parameterpath>

[0085] idCardNo

[0086] < / parameterpath>

[0087] <parametervalue>

[0088] v_idCardNo

[0089] < / parametervalue>

[0090] < / parameter>

[0091] Determine the parameter path of idCardNo in the interface parameter items, that is, the parameter path of idCardNo in Table 1 corresponds to $ / idCardNo$. Then, extract / idCardNo=& ​​from the parameter path items in Table 1, separate / idCardNo and null values ​​by =, parse the parameter node information, and determine... <parameterpath>The value of the variable v_idCardNo of the parameter to be parameterized, idCardNo, does not exist, the null value obtained by splitting / idCardNo=& in the parameter path item is filled in $ / idCardNo$, the parameter idCardNo in the parameter path $ / idCardNo$ in the interface parameter item is obtained, and the corresponding original parameter value null is obtained, so as to construct the parameter and the original parameter value in the test case.

[0092] Finally, actual parameter values are filled in positions corresponding to the positions of the parameter items {"idCardNo”:”$ / idCardNo$”,"name”:”$ / name$”,”city”:”$ / city$”} in the interface parameter item in Table 1, if the actual parameter value of name is Ming Yang, and if the actual parameter value of city is Shenzhen, the final test message is Ming Yang, Shenzhen.

[0093] By using the above method, the interface identifier is set in the test case, the corresponding interface resource is found through the interface identifier, the interface parameter item and the parameter path item are obtained from the interface resource, the original parameter values corresponding to the parameter paths are obtained according to the parameter path item, the actual parameter values are obtained from the test case according to the parameter path in the interface parameter item, and finally the test message is generated according to the original parameter value and the actual parameter value. Compared with the prior art in which a large number of test cases need to be changed when parameter information is added, modified or reduced, if the parameters in the test case need to be modified, added or deleted, the parameters in the interface resource can be directly modified, so that the test case does not need to be called for modification, a large number of test case parameters can be modified by modifying the interface resource once, and the labor cost and time cost are saved.

[0094] The embodiment of the application further provides a method for updating an interface resource, as shown in Figure 3 The method comprises the following steps.

[0095] In step 301, an interface resource update instruction is received.

[0096] Here, the interface resource update instruction is an instruction for changing parameter information in the interface resource, for example, adding a gender parameter, reducing an ID card parameter, or modifying a city parameter.

[0097] In step 302, according to the interface resource update instruction, a change operation is performed on the interface parameter item and / or the parameter path item in the interface resource indicated by the interface resource update instruction.

[0098] This includes adding a parameter with a fixed value to the interface parameter item and adding a parameter with the fixed value to the parameter path item; wherein, the fixed value parameter is a value that can be fixed in the test message, such as: in the account opening scenario, if all users are Shenzhen residents, then the fixed value 'Shenzhen' can be set in the test message.

[0099] Based on the interface resources in Table 1, if an interface resource update instruction is received that adds a gender parameter to the interface resources, the updated interface resources are as follows:

[0100] Table 2

[0101]

[0102] Alternatively, the parameter can be deleted from the interface parameter item, and the parameter can be deleted from the parameter path item; that is, if the parameter name is to be deleted, the name interface parameter item in the interface parameter item and the name parameter path item in the parameter path item can be deleted.

[0103] Based on the interface resources in Table 1, upon receiving an interface resource update instruction to delete the name parameter from the interface resources, the updated interface resources are as follows:

[0104] Table 3

[0105]

[0106] Alternatively, the parameter value of the parameter with the fixed value can be modified in the parameter path item.

[0107] In other words, if you want to change the original parameter value of the city parameter with a fixed value from 'Shenzhen' to 'Shanghai', then change / city=Shenzhen to / city=Shanghai in the parameter path field.

[0108] Based on the interface resources in Table 1, upon receiving an interface resource update instruction to modify the city parameter, the updated interface resources are as follows:

[0109] Table 4

[0110]

[0111] It should be noted that the above-mentioned method for updating interface resources is not the only method. For example, deleting parameters can also be achieved by deleting only the parameter path value in the interface parameter item. There are no restrictions on the specific method for updating interface resources here.

[0112] Based on the above-described method for generating test messages and updating interface resources, this application embodiment provides a flowchart of an interface resource generation method, such as... Figure 4 As shown, it includes:

[0113] Step 401: Obtain the defined message;

[0114] Here, the defined message is retrieved, as shown in Table 1: {"idCardNo":"",name":"",city":"Shenzhen"}

[0115] Step 402: Convert the definition message into an ordered HashMap object;

[0116] Here, the defined parameter items in the definition message are determined according to the ordered HashMap function: "idCardNo":", "name":", "city":"Shenzhen", and the definition message is converted into ordered HashMap data, such as... Figure 5 As shown, the HashMap data consists of 5 parts: 501 is the header of the HashMap data; 502 is the node after the idCardNo parameter is transformed, which can be written as (Key->idCardNo, Value->""); 503 is the node after the name parameter is transformed, which can be written as (Key->name, Value->""); 504 is the node after the city parameter is transformed, which can be written as (Key->city, Value->"Shenzhen"); and 505 is an empty node, indicating the end of the HashMap data.

[0117] Step 403: Convert the parameters into parameter paths using a recursive function;

[0118] Here, the parameters in the defined parameter items are converted into parameter paths. At this point, 501 in the HashMap data is the header of the HashMap data, 502 can be written as (Key-> / idCardNo, Value->""), 503 can be written as (Key-> / name, Value->""), 504 can be written as (Key-> / city, Value->"Shenzhen"), and 505 is the end of the HashMap data.

[0119] Step 404: Determine if the message is in HashMap format;

[0120] Here, if it is not in the form of a HashMap data, then step 4041 is executed to continue to determine whether the data is array data; if it is not array data, it is data in other forms, and step 410 is executed to directly record the parameter path as the actual parameter value, that is: / idCardNo=& / name=& / city=Shenzhen, and the parameter is equal to the parameter path, that is: {"idCardNo":"$ / idCardNo$","name":"$ / name$","city":"$ / city$"}.

[0121] If it is an array, then step 4091 is executed to determine whether there is a next element in the array. If there is, then step 4092 is executed to convert the array element number into a parameter path, and so on in a loop until step 4093 when the array element traversal ends. For example: If the parameter idCardNo item contains three sets of data, that is, idCardNo: 0, 1, 2, then in the first loop, steps 402, 403, 404, 4041, 4091, 4092, the parameter path of the 0th array of the parameter idCardNo is / array / 0 / idCardNo; in the second loop, steps 402, 403, 404, 4041, 4091, 4092, the parameter path of the 1st array of the parameter idCardNo is / array / 1 / idCardNo; in the third loop, steps 402, 403, 404, 4041, 4091, 4092, the parameter path of the 2nd array of the parameter idCardNo is / array / 2 / idCardNo; in the fourth loop, steps 402, 403, 404, 4041, 4091, there is no next element, and step 4093 is performed to end the traversal.

[0122] If it is in the form of a HashMap data, then step 405 is executed.

[0123] In step 405, the iteration pointer points to the head of the ordered HashMap data, that is, the HashMap data Header501.

[0124] In step 406, is there a node?

[0125] Here, it is judged whether there is a node after the HashMap data Header501. If not, then step 411 is executed and the process ends; if there is a node, then step 407 is executed.

[0126] In step 407, record the parameter path.

[0127] Here, record the parameter path / idCardNo.

[0128] Step 408: Is the original parameter value in the form of a HashMap data?

[0129] Here, if the original parameter value is in the form of a HashMap data, then execute Step 4081 to record the original parameter value ""; loop and execute Steps 403 - 408 and 4081 in this way to obtain the parameter paths / idCardNo, / name, / city, and the original parameter values "", "", Shenzhen. The last polling is to poll until the last empty node 505 of the HashMap data, and the polling ends.

[0130] Step 410: Record that the parameter path is equal to the original parameter value, that is: / idCardNo=& / name=& / city=Shenzhen, and set the parameter equal to the actual parameter value, that is: {"idCardNo": "$ / idCardNo$", "name": "$ / name$", "city": "$ / city$"}.

[0131] Step 411: The generation of interface resources ends.

[0132] Based on the above test message generation method and interface resource generation method, an embodiment of the present application provides a flow of a test message generation method, as Figure 6 shown, including:

[0133] Step 601: Generate test cases;

[0134] Here, determine the number of test cases for the defined parameter items of the defined message. For example, for the defined message in Table 1: {"idCardNo": "", "name": "", "city": "Shenzhen"}, one test case can be:

[0135] <?xml version='1.0' encoding='UTF-8'?>

[0136] <case id="1">

[0137] <api idCardNo="2302271998********">

[0138] <output> v_idCardNo< / output>

[0139]

[0140] <api name="Ming Yang">

[0141] <output> v_name< / output>

[0142]

[0143] <api name="Send HTTP Request">

[0144] <resource id="1">

[0145] <parameter>

[0146] <parameterpath>

[0147] idCardNo

[0148] < / parameterpath>

[0149] <parametervalue>

[0150] v_idCardNo

[0151] < / parametervalue>

[0152] < / parameter>

[0153] <parameter>

[0154] <parameterpath>

[0155] / name

[0156] < / parameterpath>

[0157] <parametervalue>

[0158] v_name

[0159] < / parametervalue>

[0160] < / parameter>

[0161]

[0162]

[0163]

[0164] It includes a module for generating ID card information and name information.

[0165] Step 602: Generate interface resources;

[0166] Here, from Figure 4 the process in it, the interface resources including interface parameter items, parameter path items, and interface identifiers are as shown in Table 1.

[0167] Step 603: Generate actual parameter values when running test cases;

[0168] Here, according to the <api idCardNo="2302271998********"> in the test case

[0169] <output> v_idCardNo< / output>

[0170]

[0171] <api name="Ming Yang">

[0172] <output> v_name< / output>

[0173]

[0174] The interface can randomly generate ID card information and name. For example: ID card number 2302271998********, name: Ming Yang.

[0175] Step 604: Obtain interface resources according to the interface identifier;

[0176] Here, from <resource id="1"> in the test case, it can be seen that the interface identifier of the interface resource is 1, and the interface resource to be called is found to be "1".

[0177] Step 605: Obtain the interface parameter items in the interface resources;

[0178] Here, the interface parameter item {"idCardNo":"$ / idCardNo$","name":"$ / name$","city":"$ / city$"} is obtained from interface resource "1".

[0179] Step 606: Obtain the parameter path item from the interface resource;

[0180] The parameter path item / idCardNo=& / name=& / city=Shenzhen is obtained from interface resource "1".

[0181] Step 607: Generate and send a test message;

[0182] Here, the parameterized information in the XML result description of the test case is parsed, namely the parameter node. In the first parameter node, parameterPath is configured with / idCardNo, so the value of variable v_idCardNo, 2302271998********, is taken to replace the $ / idCardNo$ part. In the second parameter node, parameterPath is configured with / name, so the value of variable v_name, Mingyang, is taken to replace the $ / name$ part. The parameter node information does not contain / city, so "Shenzhen" from the parameter path item is used to fill and replace the $ / city$ part.

[0183] The final test message obtained is {"idCardNo":"2302271998********","name":"Mingyang","city":"Shenzhen"}, and the HTTP request is sent with this test message.

[0184] It should be noted that the above execution order is not the only one. For example, the execution order of steps 601 and 602 can be that step 602 is executed first, and then step 601 is executed. There is no specific limitation.

[0185] Based on the same concept, embodiments of the present invention provide an apparatus for generating test messages. Figure 7 This is a schematic diagram of a test message generation device provided in an embodiment of this application, as shown below. Figure 7 The following are examples:

[0186] The acquisition module 701 is used to acquire the interface identifier recorded in the test case; it is also used to acquire interface parameter items and parameter path items from the interface resources corresponding to the interface identifier, wherein the interface parameter item contains parameter paths for one or more parameters, and the parameter path item includes the original parameter values ​​corresponding to each parameter path.

[0187] Extraction module 702 is used to extract the actual parameter value corresponding to the parameter path from the test case according to the parameter path in the interface parameter item;

[0188] The processing module 703 is used to fill in the parameter positions corresponding to each parameter path in the interface parameter item according to the original parameter value and / or the actual parameter value corresponding to each parameter path, and generate the test message.

[0189] In one possible design, the processing module 703 is specifically used to: for each parameter path in the interface parameter item, if the test case contains an actual parameter value corresponding to the parameter path, then fill the actual parameter value corresponding to the parameter path into the parameter position corresponding to the parameter path in the interface parameter item; if the test case does not contain an actual parameter value corresponding to the parameter path, then fill the original parameter value corresponding to the parameter path into the parameter position corresponding to the parameter path in the interface parameter item.

[0190] In one possible design, the processing module 703 is further configured to: obtain a definition message corresponding to the interface identifier, the definition message including each definition parameter item, each definition parameter item including a parameter and an original parameter value; for each definition parameter item, determine the parameter path corresponding to the parameter in the definition parameter item; construct the parameter path and the original parameter value into a parameter path item in the interface resource; and construct the parameter and the parameter path into an interface parameter item in the interface resource.

[0191] In one possible design, the processing module 703 is further configured to:

[0192] The defined parameter items in the defined message are determined using an ordered Hashmap function, and the parameters in the defined parameter items are converted into parameter paths.

[0193] In one possible design, the processing module 703 is further configured to: determine the parameter path corresponding to the parameter in the interface parameter item for the parameter that needs to be parameterized in the test case; and construct the actual parameter value corresponding to the parameter path in the test case.

[0194] In one possible design, the processing module 703 is further configured to: receive an interface resource update instruction; and, according to the interface resource update instruction, modify the interface parameter items and / or parameter path items in the interface resource indicated by the interface resource update instruction.

[0195] In one possible design, the processing module 703 is further configured to: add a parameter with a fixed value to the interface parameter item, and add a parameter with the fixed value to the parameter path item; or delete a parameter in the interface parameter item, and delete the parameter in the parameter path item; or modify the original parameter value of the parameter with the fixed value in the parameter path item.

[0196] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0197] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0198] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0199] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0200] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.< / parameterpath> < / parameterpath>

Claims

1. A method for generating a test message, characterized in that, The test message is used to test the interface; the method includes: Retrieve the interface identifier recorded in the test cases; From the interface resources corresponding to the interface identifier, obtain the interface parameter items and parameter path items. The interface parameter items contain parameter paths for one or more parameters, and the parameter path items include the original parameter values ​​corresponding to each parameter path. Run the test case; extract the actual parameter value corresponding to the parameter path from the run test case according to the parameter path in the interface parameter item; If the actual parameter value corresponding to the parameter path is not found in the test case after the test is run, the original parameter value is obtained from the parameter path item; Based on the original parameter values ​​and / or actual parameter values ​​corresponding to each parameter path, the parameter positions corresponding to each parameter path in the interface parameter item are filled in to generate the test message; The test cases are obtained as follows: for the parameters that need to be parameterized in the test cases, the parameter path corresponding to the parameter in the interface parameter item is determined; the actual parameter value corresponding to the parameter path is constructed in the test cases. The interface resources are generated in the following way: Obtain the definition message corresponding to the interface identifier. The definition message includes each definition parameter item, and each definition parameter item includes a parameter and its original value. For each defined parameter item, determine the parameter path corresponding to the parameter in the defined parameter item; construct the parameter path item in the interface resource using the parameter path and the original parameter value; construct the interface parameter item in the interface resource using the parameter and the parameter path.

2. The method as described in claim 1, characterized in that, Based on the original parameter value and / or the actual parameter value corresponding to each parameter path, the parameter positions corresponding to each parameter path in the interface parameter item are filled in, including: For each parameter path in the interface parameter item, if the test case contains an actual parameter value corresponding to the parameter path, then the actual parameter value corresponding to the parameter path is filled into the parameter position corresponding to the parameter path in the interface parameter item. If the test case does not contain the actual parameter value corresponding to the parameter path, then the original parameter value corresponding to the parameter path will be filled into the parameter position corresponding to the parameter path in the interface parameter item.

3. The method as described in claim 1, characterized in that, Determining the parameter path corresponding to the parameter in the defined parameter item includes: The defined parameter items in the defined message are determined using an ordered Hashmap function, and the parameters in the defined parameter items are converted into parameter paths.

4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: Receive interface resource update instructions; According to the interface resource update instruction, the interface parameter items and / or parameter path items in the interface resource indicated by the interface resource update instruction are modified.

5. The method as described in claim 4, characterized in that, Modifying interface parameter items and / or parameter path items in the interface resource indicated by the interface resource update instruction includes: Add a parameter with a fixed value to the interface parameter field, and add a parameter with the fixed value to the parameter path field; or Delete the parameter in the interface parameter field, and delete the parameter in the parameter path field; or Modify the original parameter value of the parameter with the fixed value in the parameter path item.

6. A test message generation apparatus, characterized in that, The test message is used to test the interface; the device includes: The acquisition module is used to acquire the interface identifier recorded in the test case; it is also used to acquire interface parameter items and parameter path items from the interface resources corresponding to the interface identifier, wherein the interface parameter item contains parameter paths for one or more parameters, and the parameter path item includes the original parameter values ​​corresponding to each parameter path; An extraction module is used to run the test cases; extract the actual parameter values ​​corresponding to the parameter paths from the run test cases according to the parameter paths in the interface parameter items; if there are no actual parameter values ​​corresponding to the parameter paths in the run test cases, then obtain the original parameter values ​​from the parameter path items. The processing module is used to fill in the parameter positions corresponding to each parameter path in the interface parameter item according to the original parameter value and / or the actual parameter value corresponding to each parameter path, and generate the test message; The test cases are obtained as follows: for the parameters that need to be parameterized in the test cases, the parameter path corresponding to the parameter in the interface parameter item is determined; the actual parameter value corresponding to the parameter path is constructed in the test cases. The interface resources are generated in the following way: Obtain the definition message corresponding to the interface identifier. The definition message includes each definition parameter item, and each definition parameter item includes a parameter and its original value. For each defined parameter item, determine the parameter path corresponding to the parameter in the defined parameter item; construct the parameter path item in the interface resource using the parameter path and the original parameter value; construct the interface parameter item in the interface resource using the parameter and the parameter path.

7. A computing device, characterized in that, include: Memory, used to store program instructions; A processor is configured to invoke program instructions stored in the memory and execute the method according to any one of claims 1 to 5.

8. A computer-readable non-volatile storage medium, characterized in that, Includes computer-readable instructions that, when read and executed by a computer, cause the computer to perform the method as described in any one of claims 1 to 5.

9. A computer program product, characterized in that, When it is run on a computer, it causes the computer to perform the method as described in any one of claims 1 to 5.