Test case field positioning method and device, equipment, medium and program product
By obtaining and mapping the parameter fields and assertion rules of the test cases, using instrumentation variable marking and position mapping, the problems of high noise and false positives when positioning the test case fields are solved, and accurate field positioning and defect verification are achieved.
Patent Information
- Application Number
- CN202411977300.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2044-12-30
AI Technical Summary
The prior art is noisy when positioning test case fields, which is prone to false alarms of positioning information, resulting in the inability to assist users in checking potential field defects.
By obtaining the parameter output field, parameter output field value and correspondence of the target test case, a mapping relationship between the full field path and the assertion rule set is established, and the mapping relationship between the position and the instrumentation variable is used to determine the location of the full field path.
It effectively solves the problem of high noise when positioning test case fields, reduces false alarms of positioning information, and can accurately assist users in checking potential field defects.
Smart Images

Figure CN119902980A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, equipment, medium and program product for locating a test case field. Background Art
[0002] Interface automation testing is an important way to ensure business quality in the software quality system. Interface automation use cases mainly include test execution logic, assertion methods, and result measurement.
[0003] According to the generation method, assertion methods can be divided into manual script assertions, recording and playback difference value assertions, and logic rule assertions. When users currently detect defects in test case fields, they usually use the recording and playback difference value assertion method to locate the difference field. Specifically, by recording and replaying in a specific test lane, the difference value assertion of the playback results of the two requests is compared, and then the difference field of the two playback results is found, and then the location of the test case field with defects is located. However, this positioning method will be affected by timestamps or inventory quantities, and has a lot of noise, which is prone to false positives in positioning information.
[0004] Therefore, when the relevant technology locates the test case fields, there is a lot of noise, which is prone to false alarms of positioning information, resulting in the inability to assist users in checking potential field defects. Summary of the invention
[0005] In view of this, the present disclosure provides a method, device, equipment, medium and program product for locating test case fields to solve the problem that when locating test case fields in related technologies, there is large noise and false alarms of positioning information, resulting in the inability to assist users in checking potential field defects.
[0006] In a first aspect, the present disclosure provides a method for locating a test case field, the method comprising:
[0007] Obtain the output parameter fields, output parameter field values, and the correspondence between the output parameter fields and the output parameter field values of the target test case, and obtain a first mapping relationship between the full field path of the target test case and the assertion rule set, wherein the full field path is obtained according to the tree structure corresponding to the output parameter fields, the assertion rule set is obtained by aggregating the assertion rules, and the assertion rules are obtained according to the correspondence between the output parameter fields and the output parameter field values;
[0008] Determine an instrumentation variable according to the full field path, and obtain a second mapping relationship between the full field path and the instrumentation variable, wherein the instrumentation variable is used to mark the full field path;
[0009] Determine the position of the text string of each field node according to the tree structure, and obtain a third mapping relationship between the position and the plugged variable;
[0010] According to the second mapping relationship and the third mapping relationship, a fourth mapping relationship between the position and the full field path is obtained;
[0011] According to the fourth mapping relationship and the first mapping relationship, the location of the full field path is determined, wherein the full field path corresponds to the assertion rule set.
[0012] In the disclosed embodiment, by obtaining the output parameter field, the output parameter field value, the output parameter field and the corresponding relationship between the output parameter field value of the target test case, a first mapping relationship between the full field path and the assertion rule set is obtained, the plug-in variable is determined according to the full field path, a second mapping relationship between the full field path and the plug-in variable is obtained, the text string location of each field node is determined according to the tree structure, a third mapping relationship between the location and the plug-in variable is obtained, and a fourth mapping relationship between the location and the full field path is obtained according to the second mapping relationship and the third mapping relationship. According to the fourth mapping relationship and the first mapping relationship, the location of the full field path is determined, wherein the full field path corresponds to the assertion rule set. In this way, since the disclosed embodiment implements full field path marking by writing plug-in variables at the full field path, a mapping relationship is established with the location of the text string of each field node in the tree structure according to the plug-in variable, and then the mapping relationship between the location and the full field path is derived, and then the mapping relationship between the location and the assertion rule set is derived, and the positioning information of the full field path of the target test case is obtained, which solves the problem that the related technology has large noise when locating fields in the test case, and the positioning information is easily misreported.
[0013] In a second aspect, the present disclosure provides a device for locating a test case field, the device comprising:
[0014] An acquisition module is used to acquire the output parameter fields, output parameter field values, and the correspondence between the output parameter fields and the output parameter field values of the target test case, and obtain a first mapping relationship between the full field path of the target test case and the assertion rule set, wherein the full field path is obtained according to the tree structure corresponding to the output parameter fields, the assertion rule set is obtained by aggregating the assertion rules, and the assertion rules are obtained according to the correspondence between the output parameter fields and the output parameter field values;
[0015] A first obtaining module is used to determine an instrumentation variable according to the full field path, and obtain a second mapping relationship between the full field path and the instrumentation variable, wherein the instrumentation variable is used to mark the full field path;
[0016] The second obtaining module is used to determine the position of the text string of each field node according to the tree structure, and obtain a third mapping relationship between the position and the plugged variable;
[0017] A third obtaining module, used to obtain a fourth mapping relationship between a position and a full field path according to the second mapping relationship and the third mapping relationship;
[0018] The determination module is used to determine the location of the full field path according to the fourth mapping relationship and the first mapping relationship, wherein the full field path corresponds to the assertion rule set.
[0019] In a third aspect, the present disclosure provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the method for locating a test case field of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0020] In a fourth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for locating a test case field of the first aspect or any corresponding embodiment thereof.
[0021] In a fifth aspect, the present disclosure provides a computer program product, including computer instructions, which are used to enable a computer to execute the method for locating a test case field of the above-mentioned first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0023] Figure 1 is a flow chart of a method for locating a test case field according to an embodiment of the present disclosure;
[0024] Figure 2 is a flow chart of a method for optimizing test case field positioning according to an embodiment of the present disclosure;
[0025] Figure 3 It is a complete flow chart of the method for locating the test case field according to an embodiment of the present disclosure;
[0026] Figure 4 is a structural block diagram of a positioning device for a test case field according to an embodiment of the present disclosure;
[0027] Figure 5 It is a schematic diagram of the hardware structure of the computer device of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0029] Currently, when locating fields in some test cases, the difference value assertion is usually recorded and replayed to locate the difference field. However, this positioning method will be affected by timestamps or inventory quantities, resulting in large noise and false positives in positioning information.
[0030] In order to solve the above problems, according to an embodiment of the present disclosure, a method embodiment of locating a test case field is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0031] In this embodiment, a method for locating a test case field is provided. Figure 1 is a flowchart of a method for locating a test case field according to an embodiment of the present disclosure, such as Figure 1 As shown, the method is applied to the server side, and the method flow includes the following steps:
[0032] Step S101, obtain the output parameter fields, output parameter field values, and the correspondence between the output parameter fields and the output parameter field values of the target test case, and obtain a first mapping relationship between the full field path of the target test case and the assertion rule set, wherein the full field path is obtained based on the tree structure corresponding to the output parameter fields, the assertion rule set is obtained by aggregating the assertion rules, and the assertion rules are obtained based on the correspondence between the output parameter fields and the output parameter field values.
[0033] Optionally, the test case is a result obtained after replaying the scene traffic. In the disclosed embodiment, the server will obtain the test case to be located as the target test case. Usually the target test case is a line of string, such as {"k1":{"k21":1,"k22":3,"k23":4}}. From {"k1":{"k21":1,"k22":3,"k23":4}}, it can be seen that the target test case is composed of some nested key-value pairs. Currently, it is necessary to locate the field key in the target test case, namely k1.k21, k1.k22, and k1.k23.
[0034] First, the target test case is processed to obtain the output parameter fields of the json structure (such as k1, k21, k22, k23 in the above string), the output parameter field values (such as 1, 3, 4 in the above string), and the correspondence between the output parameter fields and the output parameter field values (such as k21:1, k2:3, k23:4 in the above string).
[0035] Parse the output parameter fields into a tree structure, and determine the full field path from the tree structure, such as k1.k21 and k1.k22. According to the correspondence between the output parameter fields and their values, the assertion rule for the full field path of the target test case can be selected from the assertion rule list. The full field path of a test case can correspond to multiple assertion rules, such as k1.k21, and its corresponding assertion rule can be k1.k21 in{1,2}; k1.k21 is not empty.
[0036] Some examples of assertion rules are shown in Table 1:
[0037] Table 1
[0038]
[0039] By aggregating all assertion rules contained in each full-field path, an assertion rule set can be obtained, and then a first mapping relationship between the full-field path and the assertion rule set can be established.
[0040] Step S102, determining an instrumentation variable according to the full field path, and obtaining a second mapping relationship between the full field path and the instrumentation variable, wherein the instrumentation variable is used to mark the full field path.
[0041] Optionally, since the position of the output parameter field is difficult to locate, the full field path can be marked by means of instrumentation. The specific method is: determine the number of instrumentation variables according to the number of full field paths, for example, there are as many instrumentation variables as there are full field paths, and then write the instrumentation variables in front of or after the full field path, and then establish a second mapping relationship between the full field path and the instrumentation variables.
[0042] Step S103, determining the position of the text string of each field node according to the tree structure, and obtaining a third mapping relationship between the position and the plugged variable.
[0043] Optionally, the text strings of the field nodes contained in the tree structure are determined according to the tree structure parsed above, and then the positions of the text strings in the display box, such as line numbers, are obtained.
[0044] It can be seen from the above embodiments that a tree structure is obtained by parsing the output parameter field, and the tree structure is the source of the full field path in the output parameter field, so there must be an association between the text string of each field node in the tree structure and the full field path, so there will be a mapping relationship between the position of the text string and the plug-in variable of the full field path, so a third mapping relationship can be established based on the position (such as line number) and the plug-in variable inserted in the full field path.
[0045] Step S104: Obtain a fourth mapping relationship between a position and a full field path according to the second mapping relationship and the third mapping relationship.
[0046] Optionally, since the second mapping relationship records the mapping relationship between the full field path and the instrumented variable, and the third mapping relationship records the mapping relationship between the position and the instrumented variable, the fourth mapping relationship between the position and the full field path can be obtained from the second mapping relationship and the third mapping relationship.
[0047] Step S105: Determine the location of the full field path according to the fourth mapping relationship and the first mapping relationship, wherein the full field path corresponds to the assertion rule set.
[0048] Optionally, since the first mapping relationship records the mapping relationship between the full field path and the assertion rule set, and the fourth mapping relationship records the mapping relationship between the position and the full field path, the mapping relationship between the position and the assertion rule set can be obtained from the second mapping relationship and the third mapping relationship. Since each assertion rule set corresponds to all assertion rules of a full field path, after obtaining the mapping relationship between the position and the assertion rule set, the position of the assertion rule set can be determined, and then the positioning information of the full field path can be obtained according to the position of the assertion rule set, such as the 3rd row, the 4th row, etc.
[0049] In the disclosed embodiment, by obtaining the output parameter field, the output parameter field value, the output parameter field and the corresponding relationship between the output parameter field value of the target test case, a first mapping relationship between the full field path and the assertion rule set is obtained, the plug-in variable is determined according to the full field path, a second mapping relationship between the full field path and the plug-in variable is obtained, the text string location of each field node is determined according to the tree structure, a third mapping relationship between the location and the plug-in variable is obtained, and a fourth mapping relationship between the location and the full field path is obtained according to the second mapping relationship and the third mapping relationship. According to the fourth mapping relationship and the first mapping relationship, the location of the full field path is determined, wherein the full field path corresponds to the assertion rule set. In this way, since the disclosed embodiment implements full field path marking by writing plug-in variables at the full field path, a mapping relationship is established with the location of the text string of each field node in the tree structure according to the plug-in variable, and then the mapping relationship between the location and the full field path is derived, and then the mapping relationship between the location and the assertion rule set is derived, and the positioning information of the full field path of the target test case is obtained, which solves the problem that the related technology has large noise when locating fields in the test case, and the positioning information is easily misreported.
[0050] In some optional implementations, the above step S101 includes:
[0051] Step S1011, performing a first preprocessing on the target test case to obtain the output parameter fields, the output parameter field values, and the corresponding relationship between the output parameter fields and the output parameter field values.
[0052] Optionally, after the server obtains the target test case, the correspondence between the input parameter fields, input parameter field values, output parameter fields and output parameter field values can be obtained by performing a first preprocessing on the target test case, such as jsonization / flattening. Since the output parameter fields and output parameter field values are usually used when determining the assertion rules of the test case, the embodiment of the present disclosure only retains the input parameter fields and input parameter field values, and also needs to obtain the correspondence between the output parameter fields and the output parameter field values. The corresponding relationship here is usually a key-value relationship.
[0053] Step S1012, generating a tree structure based on the output parameter fields.
[0054] Optionally, define a data structure for representing tree nodes, parse the parameter fields according to the data format, such as JSON format, and use a recursive function to convert the parameter fields into a tree structure.
[0055] Step S1013, obtaining the full field path and assertion rules according to the tree structure.
[0056] Optionally, since the embodiment of the present disclosure generates a tree structure by parsing the output parameter fields, all the output parameter fields should be included in the tree structure. Since the target test case writes the fields at each level into one line, after the tree structure is generated, the output parameter fields will be graded according to the actual hierarchical relationship, and then the full field path will be determined according to the graded situation.
[0057] In addition, the assertion rules are related to the output parameter fields and the values of the output parameter fields, so after grading based on the tree structure, the assertion rules can be determined according to the graded field nodes.
[0058] Step S1014, aggregating assertion rules according to the full field path to obtain an aggregated assertion rule set.
[0059] Optionally, a full field path corresponds to multiple assertion rules. Currently, multiple assertion rules belonging to the same full field path are aggregated to obtain an aggregated assertion rule set. For example, the full field path is k1.k21, and its corresponding assertion rules are k1.k21 in{1,2}; k1.k21 is not empty, then the assertion rule set is ["k1.k21in{1,2}","k1.k21 is not empty"].
[0060] Step S1015: obtain a first mapping relationship from the full field path and the assertion rule set.
[0061] Optionally, a correspondence between the full field path and the assertion rule set is established to obtain a first mapping relationship map1, such as map1:{"k1.k21":["k1.k21 in{1,2}","k1.k21 is not empty"],"k1.k22":["k1.k22is 3"]}.
[0062] In the disclosed embodiment, by aggregating assertion rules based on the full-field path, an assertion rule set is obtained, and a first mapping relationship between the full-field path and the assertion rule set is established, so as to facilitate the derivation of the location information of the full-field path corresponding to the assertion rule set according to the first mapping relationship.
[0063] In some optional implementations, the above step S1013 includes:
[0064] Step a1, obtaining the parent field node and child field node of the parameter field in the tree structure;
[0065] Step a2, obtaining the full field path according to the parent field node and the child field node;
[0066] Step a3: Generate assertion rules based on the subfield node and the output parameter field value corresponding to the subfield node.
[0067] Optionally, after the tree structure is generated, the output parameter fields are graded according to the actual hierarchical relationship, so that parent field nodes and child field nodes are obtained.
[0068] Here, after "k1":{"k21":1,"k22":3,"k23":4}} is graded, k1 is the parent field node, and k21, k22, and k23 are child field nodes.
[0069] The full field path, i.e. k1.k21, k1.k22, and k1.k23, can be obtained based on the parent field node and the child field node.
[0070] Currently, based on the sub-field nodes k21, k22, k23 and the output parameter field values 1, 3, and 4 corresponding to the sub-field nodes, assertion rules are obtained, such as k1.k21 in{1,2}, k1.k21 is not empty, and k1.k22 is 3.
[0071] In some optional implementations, the above step S102 includes:
[0072] Step S1021, inserting a sub-field node under the full field path in the tree structure to obtain an inserted variable.
[0073] Optionally, traverse the assertion rules to extract the node where the single field is located in the tree structure, where the single node is a sub-field node under the full field path, for example, if the full field nodes are k1.k21 and k1.k22, then the sub-field nodes are k21 and k22.
[0074] According to the number of full-field paths, for example, the full-field paths are k1.k21 and k1.k22, and then the stub variables are var1 and var2. Write var1 and var2 after the output parameter field key of the single-field node to get k21var1 and k22var2.
[0075] Step S1022, obtaining a second mapping relationship from the instrumented variable and the full field path.
[0076] Optionally, after the instrumented variable is obtained and written into the field node of a single field, a second mapping relationship map2 consisting of the instrumented variable and the full field path is established, that is, map2:{"var1":"k1.k21","var2":"k1.k22"}.
[0077] In the disclosed embodiment, the mapping relationship between the full field path and the instrumented variable is determined by the instrumentation technology, so as to facilitate the derivation of the location information of the assertion rule set.
[0078] In some optional implementations, the above step S103 includes:
[0079] Step S1031 , performing second preprocessing on the tree structure to obtain a text string, wherein the text string includes a text string of a child field node and a text string of a parent field node.
[0080] Optionally, the tree structure is subjected to a second preprocessing, such as serialization processing, to obtain a json string text string. Since the tree structure contains child field nodes and parent field nodes, the text string obtained after serializing the tree structure should contain the text string of the child field node and the text string of the parent field node.
[0081] Step S1032: perform a first preprocessing on the text string to obtain the location of the text string.
[0082] Optionally, perform reverse JSON formatting on the text string to obtain the location of the text string. For example, perform reverse JSON formatting on the text string by line to obtain the line number where the text string is located. For example, if the text string is {"k1":{"k21 var1":1,"k22var2":3,"k23":4}}, after performing reverse JSON formatting on the text string by line, the following is obtained:
[0083] {
[0084] "k1":{
[0085] "k21 var1":1,
[0086] "k22var2":3,
[0087] "k23":4
[0088] }
[0089] }
[0090] Step S1033, traverse the text string, and after reading the text string containing the plugged variable, obtain the position.
[0091] Optionally, all text strings are traversed to determine whether the text string contains a text string of an instrumented variable, and then the position of the text string is obtained. It can be understood that in the above embodiment, the instrumented variable is written after the key of the subfield node of the tree structure, so the text string containing the instrumented variable should also be a text string of a subfield node, and then its corresponding position, such as line number information, can be obtained.
[0092] Step S1034, obtaining a third mapping relationship from the position and the plug-in variable.
[0093] Optionally, since the embodiment of the present disclosure can obtain the positions of all text strings, the position information of the text string containing the instrumented variables can also be obtained, and then a correspondence between the position of the text string containing the instrumented variables and the instrumented variables is established to obtain a third mapping relationship map3. For example, the position of the text string containing the instrumented variable var1 is the third row, and the position of the text string containing the instrumented variable var2 is the fourth row. In this case, map3:{"var1":3,"var2":4}.
[0094] Based on the above embodiment, a fourth mapping relationship map4 between the position and the full field path can be obtained from map2 and map3, where map4:{"3":"k1.k21","4":"k1.k22"}.
[0095] Through map4 and map1, a fifth mapping relationship map5 between the position and the assertion rule set can be obtained, where map5:{"3":["k1.k21 in{1,2}","k1.k21 is not empty"],"4":["k1.k22 is 3]}. Based on the assertion rule set in map5, the location information of the full field path is determined: 3 and 4.
[0096] In the disclosed embodiment, by establishing a third mapping relationship between the position of the text string and the instrumented variable, it is convenient to derive the location information of the full field path corresponding to the assertion rule set according to the third mapping relationship.
[0097] In some optional implementations, after obtaining the parent field node and the child field node of the parameter field in the tree structure, the method further includes:
[0098] The sub-field nodes are written into the pointer array according to a preset order, wherein the sub-field nodes in the pointer array are stored in order.
[0099] Optionally, since the value of the output parameter field key corresponding to the sub-field node is changed by the instrumentation, the position of the changed key in the full field path will change when it is deserialized into a text string. In order to ensure that the sub-field nodes are not out of order after being deserialized into a text string, after the tree structure is generated at the beginning of the process, the sub-field nodes are written into the pointer array childlist array in a preset order, so that the sub-field nodes are stored in the pointer array in order.
[0100] In the disclosed embodiment, bidirectional writing of sub-field nodes is achieved by adding a pointer array, so that the position of the text string of the sub-field node does not change, thereby ensuring the orderliness of multiple parsing of the sub-field node.
[0101] In some optional implementations, after performing the first preprocessing on the text string, the method further includes:
[0102] In response to the indication information, determining whether the node type of the field node that has changed on the tree structure is the target type, wherein the indication information is used to indicate that the node content of any field node on the tree structure has changed;
[0103] When the node type is the target type, traverse the pointer array to obtain the preset position of the subfield node;
[0104] Get the position of the text string according to the preset position of the subfield node.
[0105] Alternatively, if Figure 2 As shown, after the instrumented variable is written to the subfield node key position, the jsonstring text string needs to be deserialized into a json structure;
[0106] Determine whether the field node of the currently traversed tree structure is empty; if it is empty, output an empty string; if it is not empty, determine whether the content of the field node of the currently traversed tree structure has changed according to the indication information fed back by the tracking function (such as a Boolean function);
[0107] If there is a change, determine whether the node type of the field node is not an array or a target type; if so, output a node string of another type; if not, determine whether the node type of the field node is an array type;
[0108] If it is an array type, loop through the sub-field nodes of the tree structure and process the sub-field nodes according to array logic; if it is not an array type, determine whether the node type of the field node is the target type (such as map type);
[0109] If it is the target type, traverse the pointer array to obtain the preset position of the subfield node (the preset position here is actually the initial, fixed position), and process the subfield node according to the map logic.
[0110] In the embodiment of the present disclosure, by judging the node type of the field node that has changed in the tree structure, it is determined which array needs to be entered to obtain the sub-field node and the position of the sub-field node, thereby avoiding the problem of difficulty in accurate positioning caused by the position of the text string of the sub-field node changing when the text string is deserialized into a JSON structure due to the disorder of the map.
[0111] In some optional embodiments, such as Figure 3 As shown, Figure 3 : is a complete flow chart of the method for locating the test case field according to an embodiment of the present disclosure, and the specific steps are:
[0112] start;
[0113] Query test case field details;
[0114] JSONize the test case output parameter fields and parse them into a tree structure;
[0115] Query the assertion rule list and get multiple assertion rules;
[0116] Parse the assertion rule field path to get the full field path, and aggregate the assertion rule according to the full field path to get map1;
[0117] Traverse the full field path;
[0118] Extract the corresponding subfield node in the tree structure where the single field in the full field path is located;
[0119] Insert the subfield node key;
[0120] Save the mapping relationship between the instrumented variables and the full field path map2;
[0121] Determine whether all full-field paths have been traversed;
[0122] If the traversal is complete, the tree structure is serialized to obtain a text string;
[0123] Format text string by line json;
[0124] Iterate over the formatted text string lines;
[0125] Determine whether the formatted text string contains the instrumented variable;
[0126] If there is an instrumented variable, save the mapping relationship between the instrumented variable and the text string line number map3;
[0127] Determine whether the text string traversal is complete;
[0128] If the traversal is complete, the row number in map2 and the full field path in map3 are associated through the instrumented variable to obtain the mapping relationship map4;
[0129] By associating the map1 assertion rule set and the row number in map4 through the full field path, we get the mapping relationship map5.
[0130] Output line numbers.
[0131] In this embodiment, a device for locating a test case field is also provided, and the device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0132] This embodiment provides a device for locating a test case field, such as Figure 4 As shown, including:
[0133] The acquisition module 401 is used to acquire the output parameter fields, output parameter field values, and the correspondence between the output parameter fields and the output parameter field values of the target test case, and obtain the first mapping relationship between the full field path of the target test case and the assertion rule set, wherein the full field path is obtained according to the tree structure corresponding to the output parameter fields, the assertion rule set is obtained by aggregating the assertion rules, and the assertion rules are obtained according to the correspondence between the output parameter fields and the output parameter field values;
[0134] A first obtaining module 402 is used to determine an instrumentation variable according to the full field path, and obtain a second mapping relationship between the full field path and the instrumentation variable, wherein the instrumentation variable is used to mark the full field path;
[0135] The second obtaining module 403 is used to determine the position of the text string of each field node according to the tree structure, and obtain a third mapping relationship between the position and the plugged variable;
[0136] A third obtaining module 404, configured to obtain a fourth mapping relationship between a position and a full field path according to the second mapping relationship and the third mapping relationship;
[0137] The determination module 405 is used to determine the location of the full field path according to the fourth mapping relationship and the first mapping relationship, wherein the full field path corresponds to the assertion rule set.
[0138] In some optional implementations, the acquisition module 401 includes:
[0139] A first obtaining submodule is used to perform a first preprocessing on the original data in the network to obtain an output parameter field, an output parameter field value, and a corresponding relationship between an output parameter field and an output parameter field value;
[0140] The generation submodule is used to generate a tree structure based on the output parameter fields;
[0141] Second, obtain the submodule, which is used to obtain the full field path and assertion rules according to the tree structure;
[0142] Third, a submodule is obtained, which is used to aggregate assertion rules according to the full field path to obtain an aggregated assertion rule set;
[0143] The fourth obtaining submodule is used to obtain the first mapping relationship from the full field path and the assertion rule set.
[0144] In some optional implementations, the second obtaining submodule includes:
[0145] An acquisition unit is used to acquire the parent field node and the child field node of the parameter field in the tree structure;
[0146] A get unit is used to get the full field path according to the parent field node and the child field node;
[0147] The generating unit is used to generate assertion rules according to the sub-field node and the output parameter field value corresponding to the sub-field node.
[0148] In some optional implementations, the first obtaining module 402 includes:
[0149] Fifth, a submodule is obtained, which is used to insert a subfield node under the full field path in the tree structure to obtain an insert variable;
[0150] Sixth, a submodule is obtained, which is used to obtain a second mapping relationship from the plug-in variable and the full field path.
[0151] In some optional implementations, the second obtaining module 403 includes:
[0152] Seventh, obtaining a submodule, which is used to perform a second preprocessing on the tree structure to obtain a text string, wherein the text string includes a text string of a child field node and a text string of a parent field node;
[0153] An eighth obtaining submodule is used to perform a first preprocessing on the text string to obtain the position of the text string;
[0154] The acquisition submodule is used to traverse the text string and obtain the position after reading the text string containing the instrumented variable;
[0155] Ninth, a submodule is obtained, which is used to obtain a third mapping relationship based on the position and the plug-in variable.
[0156] In some optional embodiments, the device further comprises:
[0157] The writing module is used to write the sub-field node into the pointer array in a preset order after obtaining the parent field node and the sub-field node of the parameter field in the tree structure, wherein the sub-field nodes in the pointer array are stored in order.
[0158] In some optional embodiments, the device further comprises:
[0159] a response module, configured to, after performing a first preprocessing on the text string, determine whether the node type of the field node that has changed on the tree structure is a target type in response to the indication information, wherein the indication information is used to indicate that the node content of any field node on the tree structure has changed;
[0160] A traversal module, used to traverse the pointer array to obtain the preset position of the subfield node when the node type is the target type;
[0161] The fourth obtaining module is used to obtain the position of the text string according to the preset position of the subfield node.
[0162] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0163] The positioning device of the test case field in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0164] The present disclosure also provides a computer device having the above Figure 4 The test case fields are shown as positioning devices.
[0165] See also Figure 5 , Figure 5 is a schematic diagram of a computer device provided by an optional embodiment of the present disclosure, such as Figure 5 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.
[0166] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0167] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0168] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0169] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0170] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0171] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0172] A part of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0173] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for locating a test case field, characterized in that: The method comprises: Obtain the output parameter fields, output parameter field values, and the correspondence between the output parameter fields and the output parameter field values of the target test case, and obtain a first mapping relationship between the full field path of the target test case and the assertion rule set, wherein the full field path is obtained according to the tree structure corresponding to the output parameter fields, the assertion rule set is obtained by aggregating assertion rules, and the assertion rules are obtained according to the correspondence between the output parameter fields and the output parameter field values; Determine an instrumentation variable according to the full field path, and obtain a second mapping relationship between the full field path and the instrumentation variable, wherein the instrumentation variable is used to mark the full field path; Determine the position of the text string of each field node according to the tree structure, and obtain a third mapping relationship between the position and the plugged variable; Obtaining a fourth mapping relationship between the position and the full field path according to the second mapping relationship and the third mapping relationship; The location of the full field path is determined according to the fourth mapping relationship and the first mapping relationship, wherein the full field path corresponds to the assertion rule set.
2. The method according to claim 1, characterized in that The obtaining of the output parameter fields, the output parameter field values, and the correspondence between the output parameter fields and the output parameter field values of the target test case, and obtaining a first mapping relationship between the full field path of the target test case and the assertion rule set, includes: Performing a first preprocessing on the target test case to obtain the output parameter field, the output parameter field value, and the corresponding relationship between the output parameter field and the output parameter field value; Generate a tree structure based on the output parameter field; Obtaining the full field path and the assertion rule according to the tree structure; Aggregate the assertion rules according to the full field path to obtain the aggregated assertion rule set; The first mapping relationship is obtained from the full field path and the assertion rule set.
3. The method according to claim 2, characterized in that The obtaining the full field path and the assertion rule according to the tree structure includes: Obtain the parent field node and the child field node of the parameter field in the tree structure; Obtain the full field path according to the parent field node and the child field node; The assertion rule is generated according to the subfield node and the output parameter field value corresponding to the subfield node.
4. The method according to claim 3, characterized in that: The determining the instrumented variable according to the full field path to obtain a second mapping relationship between the full field path and the instrumented variable includes: Inserting the sub-field node under the full-field path in the tree structure to obtain the inserted variable; A second mapping relationship is obtained from the instrumented variable and the full field path.
5. The method according to claim 3, characterized in that: The determining the position of the text string of each field node according to the tree structure and obtaining a third mapping relationship between the position and the plugged variable includes: Performing a second preprocessing on the tree structure to obtain a text string, wherein the text string includes a text string of the child field node and a text string of the parent field node; Performing the first preprocessing on the text string to obtain the position of the text string; Traversing the text string, and obtaining the position after reading the text string containing the plugged variable; The third mapping relationship is obtained from the position and the plug-in variable.
6. The method according to claim 5, characterized in that After obtaining the parent field node and the child field node of the parameter field in the tree structure, the method further includes: The sub-field nodes are written into a pointer array according to a preset order, wherein the sub-field nodes in the pointer array are stored in order.
7. The method according to claim 6, characterized in that After performing the first preprocessing on the text string, the method further includes: In response to the indication information, determining whether the node type of the field node that has changed on the tree structure is a target type, wherein the indication information is used to indicate that the node content of any field node on the tree structure has changed; In the case where the node type is the target type, traversing the pointer array to obtain the preset position of the subfield node; The position of the text string is obtained according to the preset position of the subfield node.
8. A test case field positioning device, characterized in that: The device comprises: An acquisition module, used to acquire the output parameter fields, output parameter field values, and the correspondence between the output parameter fields and the output parameter field values of the target test case, and obtain a first mapping relationship between the full field path of the target test case and the assertion rule set, wherein the full field path is obtained according to the tree structure corresponding to the output parameter fields, the assertion rule set is obtained by aggregation of assertion rules, and the assertion rules are obtained according to the correspondence between the output parameter fields and the output parameter field values; A first obtaining module, configured to determine an instrumentation variable according to the full field path, and obtain a second mapping relationship between the full field path and the instrumentation variable, wherein the instrumentation variable is used to mark the full field path; A second obtaining module is used to determine the position of the text string of each field node according to the tree structure, and obtain a third mapping relationship between the position and the plugged variable; A third obtaining module, configured to obtain a fourth mapping relationship between the position and the full field path according to the second mapping relationship and the third mapping relationship; A determination module is used to determine the location of the full field path according to the fourth mapping relationship and the first mapping relationship, wherein the full field path corresponds to the assertion rule set.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for locating a test case field according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for locating a test case field according to any one of claims 1 to 7.
11. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to enable a computer to execute the method for locating a test case field according to any one of claims 1 to 7.
Citation Information
Patent Citations
Path alignment-based verification function positioning method
CN107193732A
Metainformation generation method and device for resource dependency analysis and storage medium
CN116028442A
Web page system for setting interface test case
CN116501607A
Program analyzing apparatus and testing apparatus, and analyzing method and program therefor
US20060143596A1
Efficiently developing software using test cases to check the conformity of the software to the requirements
US20120117545A1