Test case field positioning method, device, equipment, medium and program product

By generating a mapping relationship between full field paths and assertion rule sets, and using instrumented variables and tree structures to determine locations, the noise problem in test case field location was solved, achieving accurate field location and defect verification.

CN119902980BActive Publication Date: 2026-01-02BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411977300.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2026-01-02
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

Existing technologies are noisy when locating test case fields, which can easily lead to false alarms in the location information and cannot effectively help users verify potential field defects.

Method used

By obtaining the output parameter fields, values, and corresponding relationships of the target test cases, a mapping relationship between the full field path and the assertion rule set is generated. Instrumentation variables are used to mark the full field path, and the position of the field node is determined by combining the tree structure. The mapping relationship between the position and the full field path is established, thereby determining the accurate position of the full field path.

Benefits of technology

It reduces false alarms in location information, improves the accuracy of test case field location, ensures the correct correspondence of assertion rule sets, and can effectively assist users in verifying potential field defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119902980B_ABST
    Figure CN119902980B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the technical field of computers, in particular to a test case field positioning method, device, equipment, medium and program product, the method comprising: obtaining the out-parameter field, the out-parameter field value, the corresponding relationship between the out-parameter field and the out-parameter field value of the target test case, obtaining the first mapping relationship of the full field path and the assertion rule set; determining the instrumentation variable according to the full field path, obtaining the second mapping relationship of the full field path and the instrumentation variable; determining the position of the text string of each field node according to the tree structure, obtaining the third mapping relationship of the position and the instrumentation variable; obtaining the fourth mapping relationship of the position and the full field path according to the second mapping relationship and the third mapping relationship; determining the position of the full field path according to the fourth mapping relationship and the first mapping relationship. The present disclosure solves the problem of false positives in positioning test case fields in related technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, specifically to methods, apparatus, devices, media, and program products for locating test case fields. Background Technology

[0002] Interface automation testing is an important way to ensure business quality in the software quality system. Interface automation test cases mainly include several core parts: test execution logic, assertion methods, and result measurement.

[0003] Assertion methods can be categorized based on their generation method into manual script assertions, recorded playback difference value assertions, and logical rule assertions. Currently, when users perform defect detection on test case fields, they typically use recorded playback difference value assertions to locate the difference fields. Specifically, this involves recording and replaying the results in a specific test swimlane, comparing the difference value assertions of the replay results of two requests, finding the difference fields between the two replay results, and thus locating the test case field with the defect. However, this location method is affected by timestamps or inventory quantities, resulting in significant noise and a tendency for false positives in the location information.

[0004] Therefore, when locating test case fields, the relevant technologies suffer from significant noise and are prone to false alarms, making it impossible to assist users in verifying potential field defects. Summary of the Invention

[0005] In view of this, this disclosure provides a method, apparatus, device, medium, and program product for locating test case fields, in order to solve the problem that related technologies have large noise levels and are prone to false alarms when locating test case fields, which makes it impossible to assist users in verifying potential field defects.

[0006] Firstly, this disclosure provides a method for locating test case fields, the method comprising:

[0007] Obtain the output parameter fields, output parameter field values, and the correspondence between output parameter fields and output parameter field values ​​of the target test case. Obtain the full field path of the target test case and the first mapping relationship between the assertion rule set. 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 assertion rules. The assertion rules are obtained based on the correspondence between output parameter fields and output parameter field values.

[0008] The instrumentation variable is determined based on the full field path, and a second mapping relationship between the full field path and the instrumentation variable is obtained. The instrumentation variable is used to mark the full field path.

[0009] determine the location of each field node according to the tree structure, and obtain a third mapping relationship between the location and the inserted variable;

[0010] obtain a fourth mapping relationship between the location and the full field path according to the second mapping relationship and the third mapping relationship;

[0011] 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.

[0012] In the embodiment of the present disclosure, by obtaining the out-parameter field, the out-parameter field value, and the corresponding relationship between the out-parameter field and the out-parameter field value of the target test case, a first mapping relationship between the full field path and the assertion rule set is obtained, an inserted variable is determined according to the full field path, a second mapping relationship between the full field path and the inserted variable is obtained, the location of the text string of each field node is determined according to the tree structure, a third mapping relationship between the location and the inserted variable is obtained, 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, and 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. In this way, since the embodiment of the present disclosure implements full field path marking in the manner of writing an inserted variable at the full field path, a mapping relationship between the location and the text string of each field node in the tree structure is established according to the inserted variable, and then a mapping relationship between the location and the full field path is derived, and further a mapping relationship between the location and the assertion rule set is derived, the positioning information of the full field path of the target test case is obtained, and the problem of large noise in positioning the field in the test case and easy false positives of the positioning information in the related art is solved.

[0013] In a second aspect, the present disclosure provides a test case field positioning device, which comprises:

[0014] The obtaining module is configured to obtain the out-parameter field, the out-parameter field value, and the corresponding relationship between the out-parameter field and the out-parameter field value of the target test case, and obtain a first mapping relationship between the full field path and the assertion rule set of the target test case, wherein the full field path is obtained according to the tree structure corresponding to the out-parameter field, the assertion rule set is obtained by aggregating the assertion rules, and the assertion rules are obtained according to the corresponding relationship between the out-parameter field and the out-parameter field value;

[0015] The first obtaining module is configured to determine the inserted variable according to the full field path, and obtain a second mapping relationship between the full field path and the inserted variable, wherein the inserted variable is used for marking the full field path.

[0016] The second obtaining module is configured to determine the location of the text string of each field node according to the tree structure, and obtain a third mapping relationship between the location and the inserted variable.

[0017] 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;

[0018] a determining module configured to determine the position where the full-field path is located according to the fourth mapping relationship and the first mapping relationship, wherein the full-field path corresponds to the set of assertion rules.

[0019] In a third aspect, the present disclosure provides a computer device, comprising a memory and a processor, which are connected with each other in communication, the memory stores computer instructions, and the processor executes the computer instructions to perform the test case field positioning method of the first aspect or any of the corresponding embodiments.

[0020] In a fourth aspect, the present disclosure provides a computer readable storage medium, which stores computer instructions, and the computer instructions are used to make a computer execute the test case field positioning method of the first aspect or any of the corresponding embodiments.

[0021] In a fifth aspect, the present disclosure provides a computer program product, which comprises computer instructions, and the computer instructions are used to make a computer execute the test case field positioning method of the first aspect or any of the corresponding embodiments. BRIEF DESCRIPTION OF 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 needed in the specific embodiments or prior art description will be briefly introduced as follows. Obviously, the drawings in the following description are some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor.

[0023] Figure 1 is a flowchart of the test case field positioning method according to the embodiments of the present disclosure;

[0024] Figure 2 is a flowchart of the optimized test case field positioning method according to the embodiments of the present disclosure;

[0025] Figure 3 is a complete flowchart of the test case field positioning method according to the embodiments of the present disclosure;

[0026] Figure 4 is a structural block diagram of the test case field positioning device according to the embodiments of the present disclosure;

[0027] Figure 5 is a hardware structure diagram of the computer device according to the embodiments of the present disclosure. DETAILED DESCRIPTION

[0028] To make the objectives, technical solutions and advantages of the embodiments of the present disclosure clearer, the following will be combined with the drawings in the embodiments of the present disclosure to make a clear and complete description of the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are some but not all of the embodiments of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present disclosure.

[0029] When locating the fields in some test cases at present, the way of recording playback difference value assertion is usually used to locate the difference fields, but this locating way is affected by time stamps or inventory quantities, resulting in large noise and false positives of the locating information.

[0030] To solve the above problems, according to the embodiments of the present disclosure, a test case field locating method embodiment 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 here.

[0031] In the present embodiment, a test case field locating method is provided, Figure 1 is a flowchart of the test case field locating method according to the embodiments of the present disclosure, as Figure 1 shown, the method is applied to the server side, and the method flow includes the following steps:

[0032] Step S101, obtaining the out-parameter field of the target test case, the out-parameter field value, the correspondence between the out-parameter field and the out-parameter field value, obtaining the first mapping relationship of 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 out-parameter field, the assertion rule set is obtained by aggregating the assertion rules, and the assertion rule is obtained according to the correspondence between the out-parameter field and the out-parameter field value.

[0033] Optionally, the test case is a result obtained after the scene traffic passes through the playback, in the present embodiment, the server obtains the test case to be located as the target test case. Usually, the target test case is a string, such as {"k1":{"k21":1,"k22":3,"k23":4}}. It can be known from {"k1":{"k21":1,"k22":3,"k23":4}} that the target test case is composed of some nested key-value pairs, and the current field key in the target test case, i.e. k1.k21, k1.k22, k1.k23, needs to be located.

[0034] Firstly, the target test case is processed to obtain the out-parameter field in the json structure (such as k1, k21, k22, and k23 in the above string), the out-parameter field value (such as 1, 3, and 4 in the above string), and the correspondence between the out-parameter field and the out-parameter field value (such as k21:1, k2:3, and k23:4 in the above string).

[0035] The out-parameter field is parsed into a tree structure, and the full field path is determined from the tree structure, such as k1.k21 and k1.k22. According to the correspondence between the out-parameter field and the out-parameter field value, the assertion rule of the full field path of the target test case can be selected from the assertion rule list. The full field path of one test case can correspond to multiple assertion rules, such as k1.k21, which can correspond to the assertion rules k1.k21 in{1,2} and k1.k21 is not empty.

[0036] Some examples of assertion rules are shown in Table 1.

[0037] Table 1

[0038]

[0039] All the assertion rules included in each full field path are aggregated to obtain the assertion rule set, and then the first mapping relationship between the full field path and the assertion rule set can be established.

[0040] In step S102, the full field path is determined to determine the inserted variable, and the second mapping relationship between the full field path and the inserted variable is obtained, wherein the inserted variable is used to mark the full field path.

[0041] Optionally, since the position of the out-parameter field is difficult to locate, the full field path can be marked by inserting, and the specific method is as follows: the number of inserted variables is determined according to the number of full field paths, such as several full field paths, several inserted variables, and then the inserted variables are written in front of or behind the full field path, and then the second mapping relationship between the full field path and the inserted variable is established.

[0042] In step S103, the position of the text string of each field node is determined according to the tree structure to obtain the third mapping relationship between the position and the inserted variable.

[0043] Optionally, the text string of each field node contained in the tree structure is determined according to the above parsed tree structure, and then the position of these text strings in the display box is obtained, such as the line number.

[0044] As can be seen from the above embodiment, the tree structure is obtained by parsing the out-parameter field, and the tree structure is the source of the full field path in the out-parameter field, so the text string of each field node in the tree structure and the full field path must have a correlation relationship, so the position of the text string and the inserted variable of the full field path also have a mapping relationship, so the third mapping relationship can be established based on the position (such as line number) and the inserted variable of the full field path.

[0045] In step S104, the fourth mapping relationship between the position and the full field path is obtained 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 inserted variable, and the third mapping relationship records the mapping relationship between the position and the inserted 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] In step S105, the position of the full field path corresponding to the set of assertion rules is determined according to the fourth mapping relationship and the first mapping relationship.

[0048] Optionally, since the first mapping relationship records the mapping relationship between the full field path and the set of assertion rules, 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 set of assertion rules can be obtained from the second mapping relationship and the third mapping relationship. Since each set of assertion rules corresponds to all the assertion rules of a full field path, after obtaining the mapping relationship between the position and the set of assertion rules, the position of the set of assertion rules can be determined, and then the positioning information of the full field path, such as the 3rd line, the 4th line, etc., can be obtained according to the position of the set of assertion rules.

[0049] In the embodiments of the present disclosure, the first mapping relationship between the full field path and the assertion rule set is obtained by acquiring the out-parameter field, the out-parameter field value, and the correspondence between the out-parameter field and the out-parameter field value of the target test case, the insertion variable is determined according to the full field path, the second mapping relationship between the full field path and the insertion variable is obtained, the position of the text string of each field node in the tree structure is determined, the third mapping relationship between the position and the insertion variable is obtained, the fourth mapping relationship between the position and the full field path is obtained according to the second mapping relationship and the third mapping relationship, and the position 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. In this way, since the embodiments of the present disclosure implement full field path marking in the manner of writing an insertion variable at the full field path, the mapping relationship between the position and the text string of each field node in the tree structure is established according to the insertion variable, and then the mapping relationship between the position and the full field path is derived, and further the mapping relationship between the position and the assertion rule set is derived, so that the positioning information of the full field path of the target test case is obtained, and the problem of large noise and easy false positives in positioning the fields in the test case in the related art is solved.

[0050] In some optional embodiments, the step S101 includes:

[0051] In step S1011, the target test case is first preprocessed to obtain the correspondence between the out-parameter field, the out-parameter field value, the out-parameter field, and the out-parameter field value.

[0052] Optionally, after the server acquires the target test case, the target test case can be first preprocessed, such as jsonization / flatization processing, to obtain the correspondence between the in-parameter field, the in-parameter field value, the out-parameter field, and the out-parameter field value. Since the out-parameter field and the out-parameter field value are usually used when determining the assertion rule of the test case, the embodiments of the present disclosure only retain the in-parameter field and the in-parameter field value, and further need to acquire the correspondence between the out-parameter field and the out-parameter field value. The correspondence here is usually a key-value relationship.

[0053] In step S1012, a tree structure is generated based on the out-parameter field.

[0054] Optionally, a data structure for representing a tree node is defined, and the out-parameter field is parsed according to the data format, such as the json format, and the recursive function is used to convert the out-parameter field into a tree structure.

[0055] In step S1013, the full field path and the assertion rule are obtained according to the tree structure.

[0056] Optionally, since the embodiments of the present disclosure generate a tree structure by parsing the out-parameter field, all out-parameter fields should be included in the tree structure. Since the target test case writes the fields at each level to a line, after generating the tree structure, the out-parameter fields are classified according to the actual hierarchical relationship, and then the full-field path is determined according to the classification.

[0057] In addition, the assertion rule is related to the out-parameter field and the out-parameter field value, so after classification based on the tree structure, the assertion rule can be determined according to the classified field node.

[0058] Step S1014, aggregating the assertion rules according to the full-field path to obtain an aggregated assertion rule set.

[0059] Optionally, one full-field path corresponds to multiple assertion rules, and 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 the corresponding assertion rules are k1.k21 in{1, 2}; k1.k21 is not empty, and the assertion rule set is ["k1.k21 in{1, 2}", "k1.k21 is not empty"].

[0060] Step S1015, obtaining a first mapping relationship from the full-field path and the assertion rule set.

[0061] Optionally, the corresponding relationship 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.k22 is 3"]}.

[0062] In the embodiments of the present disclosure, the assertion rule set is obtained by aggregating the assertion rules based on the full-field path, and the first mapping relationship between the full-field path and the assertion rule set is established, so as to facilitate deriving the positioning information of the full-field path corresponding to the assertion rule set according to the first mapping relationship.

[0063] In some optional embodiments, the above step S1013 comprises:

[0064] Step a1, obtaining the parent field node and the child field node of the out-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, generating the assertion rule according to the child field node and the out-parameter field value corresponding to the child field node.

[0067] Optionally, after the tree structure is generated, the out-parameter field is classified according to the actual hierarchical relationship, so that the parent field node and the child field node are obtained.

[0068] Here, after the classification, k1 is the parent field node, and k21, k22 and k23 are the child field nodes.

[0069] According to the parent field node and the child field node, the full field path is obtained, that is, k1.k21, k1.k22 and k1.k23.

[0070] According to the child field nodes k21, k22 and k23 and the out-parameter field values 1, 3 and 4 corresponding to the child field nodes, the 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 embodiments, the step S102 includes:

[0072] In step S1021, the child field node under the full field path in the tree structure is instrumented to obtain an instrumented variable.

[0073] Optionally, the single field node in the tree structure is extracted by traversing the assertion rule, where the single node is the child field node under the full field path, for example, the full field nodes are k1.k21 and k1.k22, and the child 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 instrumented variables are var1 and var2, and var1 and var2 are written behind the out-parameter field key of the single field node to obtain k21var1 and k22var2.

[0075] In step S1022, the second mapping relationship is obtained from the instrumented variable and the full field path.

[0076] Optionally, after the instrumented variable is obtained and written in the field node of the single field, the second mapping relationship map2 composed of the instrumented variable and the full field path is established, that is, map2: {“var1”:“k1.k21”,“var2”:“k1.k22”}.

[0077] In the embodiments of the present disclosure, the mapping relationship between the full field path and the instrumented variable is determined through the instrumented technology, so as to facilitate the derivation of the position information of the assertion rule set.

[0078] In some optional embodiments, the step S103 comprises:

[0079] The step S1031 comprises: performing a second preprocessing on the tree structure to obtain a text string, wherein the text string comprises a text string of a child field node and a text string of a parent field node.

[0080] Optionally, the second preprocessing on the tree structure is a serialization processing to obtain a json string text string. Since the tree structure comprises the child field node and the parent field node, the text string obtained after the serialization of the tree structure should comprise the text string of the child field node and the text string of the parent field node.

[0081] The step S1032 comprises: performing a first preprocessing on the text string to obtain a position of the text string.

[0082] Optionally, the first preprocessing on the text string is a reverse sequence json formatting to obtain the position of the text string. For example, the reverse sequence json formatting is performed on the text string by line to obtain a line number of the text string. For example, the text string is {"k1":{"k21 var1":1,"k22var2":3,"k23":4}}, and the reverse sequence json formatting is performed on the text string by line to obtain:

[0083] {

[0084] "k1":{

[0085] "k21 var1":1,

[0086] "k22var2":3,

[0087] "k23":4

[0088] }

[0089] }

[0090] The step S1033 comprises: traversing the text string, and obtaining the position after reading a text string comprising the inserted variable.

[0091] Optionally, all the text strings are traversed to determine whether the text string comprises the text string comprising the inserted variable, and then the position of the text string is obtained. It can be understood that, in the above embodiment, the inserted variable is written after the key of the child field node of the tree structure, and therefore the text string comprising the inserted variable should be the text string of a certain child field node, and then the corresponding position, such as the line number information, can be obtained.

[0092] The step S1034 comprises: obtaining a third mapping relationship from the position and the inserted variable.

[0093] Optionally, since the position of all text strings can be obtained by the embodiments of the present disclosure, the position information of the text string containing the inserted variable can also be obtained, and then the correspondence between the position of the text string containing the inserted variable and the inserted variable is established to obtain a third mapping relationship map3, such as the position of the text string containing the inserted variable var1 is the 3rd line, and the position of the text string containing the inserted variable var2 is the 4th line, and at this time, map3: {"var1": 3, "var2": 4}.

[0094] Based on the above embodiments, the fourth mapping relationship map4 between the position and the full field path can be obtained from map2 and map3, wherein map4: {"3":"k1.k21","4":"k1.k22"}.

[0095] The fifth mapping relationship map5 between the position and the assertion rule set can be obtained from map4 and map1, wherein 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 positioning information of the full field path is determined: 3 and 4.

[0096] In the embodiments of the present disclosure, the third mapping relationship is established based on the position of the text string and the inserted variable, which facilitates deriving the positioning information of the full field path corresponding to the assertion rule set according to the third mapping relationship.

[0097] In some optional embodiments, after obtaining the parent field node and the child field node of the out-parameter field in the tree structure, the method further comprises:

[0098] The child field node is written into a pointer array in a preset order, wherein the child field nodes in the pointer array are sequentially stored.

[0099] Optionally, since the value of the out-parameter field key corresponding to the child field node is changed after the insertion, the position of the changed key in the full field path will change when the text string is deserialized. In order to ensure that the child field node will not appear out of order after being deserialized into a text string, the tree structure is generated at the beginning of the process, and the child field node is written into the pointer array childlist array in a preset order, so that the child field node is sequentially stored in the pointer array.

[0100] In the embodiments of the present disclosure, the bidirectional writing of the child field node is realized by adding the pointer array, so that the position of the text string of the child field node will not change, and the orderliness of the multiple parsing of the child field node is ensured.

[0101] In some optional embodiments, after the first preprocessing of the text string, the method further comprises:

[0102] In response to the indication information, it is judged 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] In the case where the node type is the target type, the pointer array is traversed to obtain the preset position of the child field node;

[0104] According to the preset position of the child field node, the position of the text string is obtained.

[0105] Optionally, as shown in Figure 2 After the stub variable is written to the key position of the child field node, the jsonstring text string needs to be serialized into a json structure;

[0106] It is judged whether the field node of the tree structure currently traversed is empty; if empty, an empty string is output, and if not empty, it is determined according to the indication information fed back by the tracking function (such as a Boolean function) whether the field node of the tree structure currently traversed has changed in content;

[0107] If changed, it is judged whether the node type of the field node is not an array and the target type; if yes, a node string of other types is output; if no, it is judged whether the node type of the field node is an array type;

[0108] If an array type, the child field nodes of the tree structure are looped and traversed, and the child field nodes are processed according to the array logic; if not an array type, it is judged whether the node type of the field node is the target type (such as a map type);

[0109] If the target type, the pointer array is traversed to obtain the preset position (which is actually the initial and fixed position) of the child field node, and the child field nodes are processed according to the map logic.

[0110] In the embodiments of the present disclosure, by judging the node type of the field node that has changed on the tree structure, it is determined which array to enter to obtain the child field node and the position of the child field node, thereby avoiding the problem that the text string position of the child field node changes when the text string is serialized into a json structure due to the unordered nature of the map.

[0111] In some optional embodiments, as shown in Figure 3 Figure 3 is a complete flowchart of the positioning method of the test case field according to the embodiments of the present disclosure, and the specific steps are as follows: ​

[0112] Start;

[0113] Query test case field details;

[0114] json the test case output parameter field, and parse the output parameter field into a tree structure;

[0115] Query the assertion rule list to obtain multiple assertion rules;

[0116] Parse the assertion rule field path to obtain a full field path, and perform aggregated assertion rules according to the full field path to obtain map1;

[0117] Traverse the full field path;

[0118] Extract the corresponding sub-field node in the tree structure of the single field in the full field path;

[0119] Plug in the sub-field node key;

[0120] Save the mapping relationship map2 between the plug-in variable and the full field path;

[0121] Determine whether all full field paths have been traversed;

[0122] If the traversal is complete, serialize the tree structure to obtain a text string;

[0123] Format the text string in line json format;

[0124] Traverse the formatted text string line;

[0125] Determine whether the formatted text string contains a plug-in variable;

[0126] If the plug-in variable exists, save the mapping relationship map3 between the plug-in variable and the line number of the text string;

[0127] Determine whether the text string has been traversed;

[0128] If the traversal is complete, associate the line number in map2 and the full field path in map3 through the plug-in variable to obtain the mapping relationship map4;

[0129] Associate the line number in map4 and the assertion rule set in map1 through the full field path to obtain the mapping relationship map5;

[0130] Output the line number.

[0131] A test case field positioning apparatus is also provided in the embodiments, which is used to implement the above-described embodiments and preferred embodiments, and will not be described again. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.

[0132] The embodiments provide a test case field positioning apparatus, as shown in Figure 4 The apparatus comprises:

[0133] The obtaining module 401 is configured to obtain an out-parameter field of a target test case, an out-parameter field value, a correspondence between the out-parameter field and the out-parameter field value, obtain a first mapping relationship between a full field path of the target test case and an assertion rule set, wherein the full field path is obtained according to a tree structure corresponding to the out-parameter field, the assertion rule set is obtained by aggregating assertion rules, and the assertion rules are obtained according to the correspondence between the out-parameter field and the out-parameter field value;

[0134] The first obtaining module 402 is configured to determine a plug-in variable according to the full field path, and obtain a second mapping relationship between the full field path and the plug-in variable, wherein the plug-in variable is used to mark the full field path;

[0135] The second obtaining module 403 is configured to determine a position of a text string of each field node according to the tree structure, and obtain a third mapping relationship between the position and the plug-in variable;

[0136] The third obtaining module 404 is 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;

[0137] The determining module 405 is configured to determine the position 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 embodiments, the obtaining module 401 comprises:

[0139] The first obtaining sub-module is configured to perform first preprocessing on the original in the network to obtain the correspondence between the out-parameter field, the out-parameter field value, the out-parameter field and the out-parameter field value;

[0140] The generating sub-module is configured to generate the tree structure based on the out-parameter field;

[0141] The second obtaining sub-module is configured to obtain the full field path and the assertion rule according to the tree structure;

[0142] The third obtaining sub-module is configured to obtain an aggregated assertion rule set according to the full-field path aggregation assertion rule;

[0143] The fourth obtaining sub-module is configured to obtain a first mapping relationship from the full-field path and the assertion rule set.

[0144] In some optional embodiments, the second obtaining sub-module includes:

[0145] The acquisition unit is configured to acquire a parent field node and a child field node of the out-parameter field in the tree structure;

[0146] The obtaining unit is configured to obtain a full-field path according to the parent field node and the child field node;

[0147] The generating unit is configured to generate an assertion rule according to the child field node and a value of the out-parameter field corresponding to the child field node.

[0148] In some optional embodiments, the first obtaining module 402 includes:

[0149] The fifth obtaining sub-module is configured to perform instrumentation on the child field node under the full-field path in the tree structure to obtain an instrumented variable;

[0150] The sixth obtaining sub-module is configured to obtain a second mapping relationship from the instrumented variable and the full-field path.

[0151] In some optional embodiments, the second obtaining module 403 includes:

[0152] The seventh obtaining sub-module is configured to perform 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;

[0153] The eighth obtaining sub-module is configured to perform a first preprocessing on the text string to obtain a position of the text string;

[0154] The acquisition sub-module is configured to traverse the text string and acquire the position after reading a text string containing the instrumented variable;

[0155] The ninth obtaining sub-module is configured to obtain a third mapping relationship from the position and the instrumented variable.

[0156] In some optional embodiments, the apparatus further includes:

[0157] The writing module is configured to write the child field node into a pointer array in a preset order after acquiring the parent field node and the child field node of the out-parameter field in the tree structure, wherein the child field nodes in the pointer array are stored in order.

[0158] In some optional embodiments, the apparatus further includes:

[0159] The response module is used to determine, in response to the indication information, whether the node type of the field node that has changed in the tree structure is the target type after the first preprocessing of the text string. The indication information is used to indicate that the node content of any field node in the tree structure has changed.

[0160] The traversal module is used to traverse the pointer array to obtain the preset positions of the child field nodes when the node type is the target type;

[0161] The fourth module is used to obtain the position of the text string based on the preset position of the sub-field node.

[0162] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0163] In this embodiment, the test case field location device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0164] This disclosure also provides a computer device having the above-described features. Figure 4 The device for locating the test case field shown.

[0165] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of this disclosure, such as... Figure 5 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 5 Take a processor 10 as an example.

[0166] The processor 10 can be a central processing unit, a network processing unit, or a combination thereof. The processor 10 can further include hardware chips. The hardware chips can be application specific integrated circuits, programmable logic devices, or a combination thereof. The programmable logic devices can be complex programmable logic devices, field programmable logic gate arrays, general array logic, or any combination thereof.

[0167] The memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform the methods illustrated by the above embodiments.

[0168] The memory 20 can include a program storage area and a data storage area. The program storage area can store an operating system, application programs required by at least one function, and the like. The data storage area can store data created according to the use of the computer device, and the like. In addition, the memory 20 can include a high-speed random access memory, and can further include a non-transitory memory such as at least one disk storage device, a flash memory device, or other non-transitory solid state storage device. In some alternative embodiments, the memory 20 can optionally include a memory disposed remotely from the processor 10, which can be connected to the computer device through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0169] The memory 20 can include a volatile memory such as a random access memory, and can also include a non-volatile memory such as a flash memory, a hard disk, or a solid state disk. The memory 20 can further include a combination of the above-mentioned types of memories.

[0170] The computer device further includes a communication interface 30 for communication of the computer device with other devices or communication networks.

[0171] The embodiments of the present disclosure further provide a computer readable storage medium. The above-mentioned methods according to the embodiments of the present disclosure can be implemented in hardware, firmware, or recorded in a storage medium, or stored in a remote storage medium or a non-transitory machine readable storage medium originally downloaded through a network and stored in a local storage medium, so that the methods described herein can be processed by such software on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, or a solid state disk, etc. Further, the storage medium can further include a combination of the above-mentioned types of memories. It can be understood that the computer, the processor, the microprocessor controller, or the programmable hardware includes a storage component that can store or receive software or computer code, which, when accessed and executed by the computer, the processor, or the hardware, implements the methods illustrated by the above embodiments.

[0172] Part of the present disclosure can be applied as a computer program product, for example, computer program instructions, when executed by a computer, through the operation of the computer, the method and / or technical solutions according to the present disclosure can be invoked or provided. Those skilled in the art should understand that the form of computer program instructions in computer readable medium includes but is not limited to source file, executable file, installation package file and the like, and accordingly, the way of computer program instructions executed by computer includes but is not limited to: the computer directly executes the instructions, or the computer compiles the instructions and then executes the corresponding compiled program, or the computer reads and executes the instructions, or the computer reads and installs the instructions 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 are described in conjunction with the drawings, various modifications and changes can be made by those skilled in the art without departing from the spirit and scope of the present disclosure, and such modifications and changes fall within the scope defined by the appended claims.

Claims

1. A method for locating test case fields, characterized in that, The method includes: Obtain the output parameter fields, output parameter field values, and the correspondence between the output parameter fields and their values ​​for the target test case. This yields the first mapping relationship between the full field path of the target test case and the assertion rule set. 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 assertion rules, and the assertion rules are obtained based on the correspondence between the output parameter fields and their values. Based on the full-field path, an instrumentation variable is determined to 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; Based on the tree structure, the position of the text string of each field node is determined, and a third mapping relationship between the position and the instrumentation variable is obtained; Based on the second mapping relationship and the third mapping relationship, a fourth mapping relationship between the position and the full field path is obtained; Based on 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 set of assertion rules.

2. The method according to claim 1, characterized in that, The process of obtaining the output parameter fields, values, and correspondences between the output parameter fields and their values ​​for the target test case, and obtaining the first mapping relationship between the full field path of the target test case and the assertion rule set, includes: The target test case is preprocessed to obtain the output parameter field, the value of the output parameter field, and the correspondence between the output parameter field and the value of the output parameter field; Generate a tree structure based on the output parameter fields; The full-field path and the assertion rule are obtained based on the tree structure; The assertion rules are aggregated based on the full field path to obtain the aggregated set of assertion rules; The first mapping relationship is obtained from the full field path and the set of assertion rules.

3. The method according to claim 2, characterized in that, The step of obtaining the full field path and the assertion rule based on the tree structure includes: Obtain the parent and child nodes of the output parameter fields in the tree structure; The full field path is obtained based on the parent field node and the child field node; The assertion rule is generated based on the sub-field node and the value of the corresponding output parameter field of the sub-field node.

4. The method according to claim 3, characterized in that, The step of determining the instrumentation variable based on the full-field path and obtaining the second mapping relationship between the full-field path and the instrumentation variable includes: Instrument the sub-field nodes under the full-field path in the tree structure to obtain the instrumented variables; The 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 step of determining the position of the text string of each field node based on the tree structure, and obtaining the third mapping relationship between the position and the instrumentation variable, includes: The tree structure is subjected to a second preprocessing to obtain a text string, wherein the text string contains the text strings of the child field nodes and the text strings of the parent field nodes; Perform the first preprocessing on the text string to obtain the position of the text string; Iterate through the text string, and after reading a text string containing the instrumentation variable, obtain the position; The third mapping relationship is obtained from the position and the instrumentation variable.

6. The method according to claim 5, characterized in that, After obtaining the parent and child field nodes of the output parameter fields in the tree structure, the method further includes: The subfield nodes are written into a pointer array in a preset order, wherein the subfield nodes in the pointer array are stored in an orderly manner.

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, it is determined whether the node type of the field node that has changed in the tree structure is the target type, wherein the indication information is used to indicate that the node content of any field node in the tree structure has changed; If the node type is the target type, traverse the pointer array to obtain the preset position of the sub-field node; The position of the text string is obtained based on the preset position of the sub-field node.

8. A device for locating test case fields, characterized in that, The device includes: The acquisition module is used to acquire the output parameter fields, output parameter field values, and the correspondence between the output parameter fields and their values ​​of the target test case, and to obtain the first mapping relationship between the full field path of the target test case and the assertion rule set. The full field path is obtained based on the tree structure corresponding to the output parameter fields, and the assertion rule set is obtained by aggregating assertion rules. The assertion rules are obtained based on the correspondence between the output parameter fields and their values. The first obtaining module is used to determine the instrumentation variable based on 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; The second module is used to determine the position of the text string of each field node according to the tree structure, and obtain the third mapping relationship between the position and the instrumentation variable; The third obtaining module is used to obtain a fourth mapping relationship between the position and the full field path based on the second mapping relationship and the third mapping relationship; The determination module is used to determine the location of the full-field path based on 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 are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the method for locating test case fields according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the method for locating test case fields according to any one of claims 1 to 7.

11. A computer program product, characterized in that, It includes computer instructions for causing a computer to perform the method for locating test case fields 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