Test range determination method and device, electronic equipment and storage medium
By generating and parsing the call relationship file, determining the impact of the change code on the transaction and call branch paths, the problem of omissions in the test scope determination in the existing technology is solved, and a more comprehensive test scope coverage is achieved.
Patent Information
- Application Number
- CN202411743582.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-30
- Publication Date
- 2025-02-21
AI Technical Summary
It is difficult for the prior art to directly determine the impact of changing codes on transactions and calling branch paths, resulting in the risk of omission in determining the scope of the test.
By analyzing the program call relationship of the new package and the relevant data of the target incremental code, a call relationship file is generated, and the file is parsed to obtain the top-level call interface and call path information, a test function list is generated, and the test scope is determined based on this information.
It directly determines the impact of changing code on transactions and calling branch paths, helping testers quickly define the test scope, avoid omissions, and improve test adequacy.
Smart Images

Figure CN119493735A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a test range determination method, device, electronic equipment and storage medium. Background Art
[0002] After developers deliver project or non-project requirements to testers, testers usually need to ask developers about the impact of this transformation and the content of regression testing. However, manual judgment based on development experience is prone to the risk of missing the test scope.
[0003] Currently, the test scope can be determined by analyzing the modified code. The specific process is: a list to be tested is obtained by analyzing the method name of the modified code, and the obtained list to be tested is the method name of all the modified codes. However, the inventors have found that the existing solution of determining the test scope by analyzing the modified code still does not know how to call these modified codes; because in daily testing work, testers usually define the test scope by the transaction dimension, rather than the method dimension. Therefore, there is an urgent need for a method that can directly determine the transactions and call branch paths affected by the changed code to assist testers in quickly defining the test scope. Summary of the invention
[0004] In this regard, the present application provides a test scope determination method, device, electronic device and storage medium, which can directly determine the transactions affected by the changed code and the method of calling branch paths, so as to assist testers in quickly defining the test scope.
[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0006] The first aspect of the present application discloses a test range determination method, comprising:
[0007] Generate a call relationship file according to the program call relationship of the new program package and relevant data of the target incremental code, wherein the target incremental code is the incremental code corresponding to the target incremental code report, the target incremental report includes the version difference between the new program package and the old program package, and the call relationship file is a set composed of a plurality of elements, each element corresponds to a method, and its data format includes a package name, a class name and a method name;
[0008] Parsing the call relationship file to obtain the top-level call interface and call path information of the target incremental code, wherein the call path information includes a call path generated according to an upward call relationship and a downward call relationship in the call relationship file;
[0009] Generate a test function list according to the top-level calling interface of the target incremental code;
[0010] A test scope result is determined according to the call path information and the test function list.
[0011] Optionally, in the above test scope determination method, the process of generating the program call relationship of the new program package includes:
[0012] Obtaining a storage path of the new program package;
[0013] Reading according to the storage path of the new program package to obtain the new program package;
[0014] Performing static code analysis on the new program package to obtain a program call relationship of the new program package;
[0015] The target incremental code generation process includes:
[0016] Determining a version of the new program package and a version of the old program package;
[0017] The version of the new program package is compared with the version of the old program package to obtain the target incremental code report.
[0018] Optionally, in the above test scope determination method, generating a call relationship file according to the program call relationship of the new program package and relevant data of the target incremental code includes:
[0019] Determine the csv file corresponding to the target incremental code;
[0020] Arrange the csv file in a preset manner to obtain an initial call relationship file;
[0021] When it is determined that the method in the initial calling relationship file exists in the program calling relationship of the new program package, the method existing in the program calling relationship of the new program package is replaced with the corresponding method in the initial calling relationship file to obtain the calling relationship file.
[0022] Optionally, in the above test range determination method, after the csv file is sorted in a preset manner to obtain an initial call relationship file, the method further includes:
[0023] Determine respectively whether the class to which the method corresponding to the initial call relationship file belongs exists in the program call relationship of the new program package;
[0024] If it is determined that the class to which the method corresponding to the initial call relationship file belongs does not exist in the program call relationship of the new program package, file version check information is generated.
[0025] Optionally, in the above test scope determination method, parsing the call relationship file to obtain the top-level call interface of the target incremental code includes:
[0026] Determine the top-level entry method in the call relationship file according to the upward call chain;
[0027] Determine the element corresponding to the top-level entry method in the call relationship file;
[0028] The top-level calling interface of the target incremental code is determined according to the element corresponding to the top-level entry method in the calling relationship file.
[0029] Optionally, in the above test scope determination method, generating a test function list according to the top-level calling interface of the target incremental code includes:
[0030] Searching the comment content of each top-level call interface in the source code of the new program package in turn to obtain relevant parameters of each top-level call interface, wherein the relevant parameters of the top-level call interface include a top-level call interface function and a top-level call interface transaction code;
[0031] The test function list is obtained by printing the program package name, csv file name, date and time and the comment content of each top-level calling interface in the calling relationship file.
[0032] Optionally, in the above test range determination method, determining the test range result according to the call path information and the test function list includes:
[0033] Determine a first page table and a second page table respectively, wherein the first page table includes the test function list, and the second page table includes the call path information;
[0034] The test range result is generated according to the first page table and the second page table.
[0035] A second aspect of the present application discloses a test range determination device, comprising:
[0036] A first generating unit is used to generate a calling relationship file according to the program calling relationship of the new program package and relevant data of the target incremental code, wherein the target incremental code is an incremental code corresponding to a target incremental code report, wherein the target incremental report includes a version difference between the new program package and the old program package, and the calling relationship file is a set consisting of a plurality of elements, each element corresponds to a method, and the data format of the method includes a package name, a class name, and a method name;
[0037] A parsing unit, used to parse the call relationship file to obtain the top-level call interface and call path information of the target incremental code, wherein the call path information includes a call path generated according to the upward call relationship and the downward call relationship in the call relationship file;
[0038] A second generating unit is used to generate a test function list according to the top-level calling interface of the target incremental code;
[0039] A determination unit is used to determine the test range result according to the call path information and the test function list.
[0040] The third aspect of the present application discloses an electronic device, including: a memory and a processor;
[0041] Wherein, the memory is used to store computer programs;
[0042] The processor is used to execute the computer program, specifically to implement the test range determination method as described in any one of the first aspects disclosed.
[0043] A fourth aspect of the present application discloses a computer storage medium for storing a computer program. When the computer program is executed, it is specifically used to implement the test range determination method as described in any one of the items disclosed in the first aspect.
[0044] The present invention provides a test scope determination method, comprising: generating a call relationship file according to program call relationships of a new program package and relevant data of a target incremental code, wherein the target incremental code is the incremental code corresponding to a target incremental code report, the target incremental report includes the version difference between the new program package and the old program package, the call relationship file is a set composed of a plurality of elements, each element corresponds to a method, and its data format includes a package name, a class name and a method name; parsing the call relationship file to obtain a top-level call interface and call path information of the target incremental code, wherein the call path information includes a call path generated according to an upward call relationship and a downward call relationship in the call relationship file; generating a test function list according to the top-level call interface of the target incremental code; determining a test scope result according to the call path information and the test function list, and being able to automatically analyze the impact scope according to the software package of the program and the incremental code coverage report, on the one hand being able to give the top-level entry method affected by the incremental code, thereby obtaining the affected transaction scope, and on the other hand being able to give all branch paths involved in the method in the incremental code, so as to assist development and test analysis of the test scenario designed for the incremental code, that is, being able to directly determine the method of transactions and call branch paths affected by the changed code, so as to assist testers in quickly defining the test scope. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0046] Figure 1 A flow chart of a test range determination method provided for this application;
[0047] Figure 2 A flow chart for generating a program call relationship of a new program package provided in an embodiment of the present application;
[0048] Figure 3 A flow chart for generating a target incremental code provided in an embodiment of the present application;
[0049] Figure 4 A flow chart for generating a call relationship file provided in an embodiment of the present application;
[0050] Figure 5 A schematic diagram of the structure of an upward call chain provided in an embodiment of the present application;
[0051] Figure 6 A schematic diagram of the structure of a downward call chain provided in an embodiment of the present application;
[0052] Figure 7 A flow chart for determining a top-level calling interface provided in an embodiment of the present application;
[0053] Figure 8 A flow chart for generating a test function list provided in an embodiment of the present application;
[0054] Fig. 9 A flow chart for determining a test range result provided in an embodiment of the present application;
[0055] Fig.10 A specific application flow chart of a test range determination method provided in an embodiment of the present application;
[0056] Fig.11 A schematic diagram of the structure of a test range determination device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] First of all, Java currently uses code static analysis technology to batch generate complete call chains of specified Java methods downward. For the Java method of interest, it can generate the method information of its downward calls, and the methods called by the called method, until the method called at the bottom. It can also generate a complete call chain of calling a specified Java class method upward. For the Java class method of interest, it can generate the method information of calling the corresponding method, and the information of calling the above method.
[0059] Based on the above, the present application provides a test scope determination method, device, electronic device and storage medium, which can directly determine the transactions affected by the changed code and the method of calling branch paths, so as to assist testers in quickly defining the test scope.
[0060] Combination Fig.10 , see Figure 1 , the test range determination method mainly includes the following steps:
[0061] S101. Generate a calling relationship file according to the program calling relationship of the new program package and relevant data of the target incremental code.
[0062] The target incremental code is the incremental code corresponding to the target incremental code report. The target incremental report includes the version difference between the new package and the old package. The call relationship file is a set composed of several elements. Each element corresponds to a method. Its data format includes package name, class name and method name.
[0063] In actual applications, the process of generating the program call relationship of a new package can be as follows: Figure 2 As shown, it mainly includes steps S201 to S203:
[0064] S201: Obtain the storage path of the new program package.
[0065] In actual applications, after the project filled in by the user is modified, the storage path of the new program package can be obtained according to the modified content of the filled in project; of course, it is not limited to this, and can also be determined according to the application environment and user needs, all within the protection scope of this application.
[0066] S202: Read according to the storage path of the new program package to obtain the new program package.
[0067] In actual applications, after the storage path of the new program package is obtained, the new program package can be read through the storage path to obtain the new program package.
[0068] S203: Perform static code analysis on the new program package to obtain a program call relationship of the new program package.
[0069] In practical applications, static code analysis technology can be used to generate program call relationships of new program packages. The program call relationships of new program packages include program call relationship data. In order to facilitate the subsequent use of the program call relationships of the new program packages, the program call relationships of the program packages can be stored in a database.
[0070] It should be noted that the database can store the complete call chain contained in the new package, including package name, class name, method name, method parameters, caller source code line number, etc. Exemplarily, the database structure of the program call relationship of the new package can be shown in Table 1-1:
[0071] Table 1-1 Database structure table of program call relations of new program package
[0072] Database field name meaning caller_jar_num Caller jar package serial number caller_method_hash Caller method hash caller_full_method The complete method name of the caller (class name + method name + parameters) caller_method_name Caller method name caller_full_class_name Caller class name caller_line_num Caller source code line number callee_method_hash Callee method hash callee_full_method The full method name of the called party (class name + method name + parameters) callee_method_name Callee method name callee_full_class_name Callee class name callee_line_num The callee source code line number
[0073] In practical applications, the target incremental code report generation process can be as follows: Figure 3 As shown, it mainly includes steps S301 and S302:
[0074] S301: Determine the version of the new program package and the version of the old program package.
[0075] The program version of the project to be tested is divided into the old program version before the change (ie, the old program package version) and the new program version after the change (ie, the new program package version). The new program package version and the old program package version can be determined by obtaining the program version of the project to be tested.
[0076] S302: Compare the version of the new program package with the version of the old program package to obtain a target incremental code report.
[0077] In practice, you can run the [git log](){"sa":"re_dqa_zy","icon":1} command to view the commit history of the program version to obtain the commit number, branch name or tag name of the two versions you want to compare. Among them, you can use the gitdiff command to compare the old and new versions. You can enter the commit number, branch name or tag name for comparison.
[0078] For example, if you want to compare the difference between the second-to-last commit number and the latest commit number of the current branch, you can use the command "git diffHEAD~2HEAD". After executing the command, the difference between the two versions will be displayed in the form of lines, and an incremental code report will be obtained (that is, the target incremental code report mentioned above).
[0079] In practical applications, the relevant data of the target incremental code may include the class and method list of the incremental code. Specifically, after obtaining the incremental code report, text processing can be performed to record the package name, class name, and method name information of the changed code, and output it to a csv table file. The format of the csv table file is shown in Table 1-2:
[0080] Table 1-2 CSV table file format
[0081] Package Name 1 Class Name 1 Method name 1 | Method name 2 | Method name 3 Package Name 1 Class Name 2 Method name 4 | Method name 7 Package name 2 Class name 3 Method name 9 | Method name 10
[0082] In some embodiments, the specific process of step S101, generating a call relationship file according to the program call relationship of the new program package and the relevant data of the target incremental code, can be as follows: Figure 4 As shown, it mainly includes steps S401 to S403:
[0083] S401, determine the csv file corresponding to the target incremental code.
[0084] Among them, the csv file corresponding to the target incremental code is generally the above-mentioned csv table file.
[0085] In practical applications, the csv file corresponding to the target incremental code can be determined by user selection; of course, it is not limited to this, and can also be determined according to the application environment and user needs. This application does not make specific limitations and is within the scope of protection of this application.
[0086] S402: Arrange the csv file in a preset manner to obtain an initial call relationship file.
[0087] In actual applications, after determining the csv file corresponding to the target incremental code, the various methods in the csv file corresponding to the target incremental code can be sorted according to the format of "package name.class name:method name" to obtain the initial call relationship file.
[0088] It should be noted that after sorting the various methods in the csv file corresponding to the target incremental code in the format of "package name.class name:method name", they can be stored in the collection X.
[0089] S403: When it is determined that the method in the initial call relationship file exists in the program call relationship of the new program package, the method existing in the program call relationship of the new program package is replaced with the corresponding method in the initial call relationship file to obtain a call relationship file.
[0090] In actual applications, the calling relationship of the new package can be queried to determine whether each method in the initial calling relationship file exists in the program calling relationship of the new package. Specifically, first query whether each method in the calling relationship of the new package has a calling relationship, identify the overloaded methods, add the identified methods to the initial calling relationship file, and then query whether the class of the method in the initial calling relationship file exists in the program calling relationship of the new package to prevent the failure of generating the calling file due to the non-existence of the class.
[0091] In specific applications, each method in the initial call relationship file can be queried one by one in the program call relationship of the new program package using a fuzzy query method to query the upward and downward call relationships; if the query result is empty, the initial call relationship is not modified and the method is skipped directly; if the query result is not empty, that is, the data is queried, the queried method with parameters is replaced with the original method in the initial call relationship file, thereby obtaining a call relationship file.
[0092] In some embodiments, after executing step S402 and arranging the csv file in a preset manner to obtain the initial call relationship file, steps S501 and S502 may also be included:
[0093] S501, respectively determine whether the class to which the method corresponding to the initial call relationship file belongs exists in the program call relationship of the new program package.
[0094] If it is determined that the class to which the method corresponding to the initial call relationship file belongs does not exist in the program call relationship of the new program package, step S502 may be executed.
[0095] S502: Generate file version check information.
[0096] The file version detection information prompts the user to recheck the version of the program package.
[0097] In actual applications, the elements in the initial call relationship can be queried one by one by class name in the program call relationship of the new package. If a certain category i cannot be found, it means that the new package (such as war\jar package) does not include the class name i in the csv file of the incremental code class and method list, that is, the version of the war\jar package does not match the incremental code list, and the user needs to recheck the version of the uploaded file.
[0098] It should be noted that the call relationship can be divided into an upward call chain and a downward call chain, which can be output to the call relationship file according to the following rules. Figure 5 As shown in the figure, the complete call chain of the DestClass.destfunc() method upwards is as follows:
[0099] [0]#DestClass.destfunc()
[0100] [1]#ClassA3.funcA3()(ClassA3:10)
[0101] [2]#ClassA2.funcA2()(ClassA2:19)
[0102] [1]#ClassB1.funcB1()(ClassB1:57)! entry!
[0103] [1]#ClassC2.funcC2()(ClassC2:31)
[0104] [2]#ClassC1.funcC1()(ClassC1:9)! entry!
[0105] The output format of the complete call chain of calling the specified class method is similar to a tree. Each line represents a caller Java method. It has nothing to do with the actual code execution order. The larger the number in front, the higher the call level. 0 represents the method in the specified class being called. The brackets at the end of each line follow the "(class name: line number)" format. For methods that are not called by other methods, they are considered entry methods and are marked with "!entry!" at the end of the corresponding line.
[0106] The structure of the downward call chain can be as follows Figure 6 As shown in the figure, the complete downward call chain of the SrcClass.srcfunc method is as follows:
[0107] [0]#SrcClass.srcfunc()
[0108] [1]#[SrcClass:15]ClassA1.funcA1()
[0109] [2]#[ClassA1:27]ClassA2a.funcA2a()
[0110] [2]#[ClassA1:59]ClassA2b.funcA2b()
[0111] [3]#[ClassA2b:39]ClassA3.funcA3()
[0112] [1]#[SrcClass:17]ClassB1.funcB1()
[0113] Similar to the upward call chain, the output result of the complete downward call chain is also similar to a tree. Each line represents a callee Java method, which is consistent with the actual code execution order. The larger the number in front, the lower the call level, and 0 represents the specified method.
[0114] By outputting the upward call chain and the downward call chain into a txt file, you can get a call relationship file.
[0115] S102: Parse the call relationship file to obtain the top-level call interface and call path information of the target incremental code.
[0116] The calling path information includes a calling path generated by the calling relationship file according to an upward calling relationship and a downward calling relationship.
[0117] Exemplarily, a page table may be used to represent call path information, where each row represents a path, the left column represents the upper layer, and the right column represents the lower layer, and from left to right represents a downward call from top to bottom.
[0118] It can be understood that the number of rows in the page table represents the number of branch paths involved in the modified code.
[0119] In practical applications, the specific process of step S102, parsing the call relationship file to obtain the top-level call interface of the target incremental code, can be as follows: Figure 7 As shown, it mainly includes steps S601 to S603:
[0120] S601. Determine the top-level entry method in the call relationship file according to the upward call chain.
[0121] In actual applications, each element in the initial call relationship file can be used to search in the call relationship file one by one, and the top-level entry method can be found according to the upward call chain.
[0122] Exemplarily, according to the structure of the upward call chain described above, the top-level entry method is marked as "!entry!".
[0123] S602: Determine the element corresponding to the top-level entry method in the call relationship file.
[0124] In actual applications, after the top-level entry method is determined, the element corresponding to the top-level entry method can be determined in the call relationship file by searching.
[0125] S603. Determine the top-level calling interface of the target incremental code according to the corresponding element of the top-level entry method in the calling relationship file.
[0126] In actual applications, the element corresponding to the top-level entry in the call relationship file can be inserted into the incremental code top-level call interface set to obtain the top-level call interface of the target incremental code. The output format of each element in the incremental code top-level call interface set is "class name: method name (parameters)".
[0127] S103. Generate a test function list according to the top-level calling interface of the target incremental code.
[0128] In some embodiments, the specific process of step S103, generating a test function list according to the top-level calling interface of the target incremental code, is as follows: Figure 8 As shown, it mainly includes steps S701 and S702:
[0129] S701. Search the comment content of each top-level calling interface in the source code of the new program package in turn to obtain relevant parameters of each top-level calling interface.
[0130] Among them, the relevant parameters of the top-level calling interface include the top-level calling interface function and the top-level calling interface transaction code.
[0131] In actual applications, you can search for the comments of each top-level call interface in the source code of the newly modified program of the project (that is, the source code of the new program package) in turn, obtain the function or transaction code of each top-level call interface, and add it to the function set. Among them, according to the general coding rules, the function or transaction code of the interface will be annotated on the previous line of the top-level interface by default.
[0132] S702: Print according to the program package name, csv file name, date and time, and the comment content of each top-level calling interface in the calling relationship file to obtain a test function list.
[0133] The package name in the call relationship file may be a war\jar package name, the csv file name may be a csv file name of the incremental code class and method list, and the date and time may be the date and time of the call relationship file.
[0134] It should be noted that the package name, csv file name, date and time in the call relationship file and the comment content of each top-level call interface can be printed into a table to obtain a test function list.
[0135] S104: Determine the test scope result according to the call path information and the test function list.
[0136] In some embodiments, the specific process of step S104, determining the test range result according to the call path information and the test function list, is as follows: Fig. 9 As shown, it mainly includes steps S801 and S802:
[0137] S801 , respectively determine a first page table and a second page table.
[0138] The first page table includes a test function list, and the second page table includes call path information.
[0139] In practical applications, the table containing the test function list can be used as the first page table; similarly to the test function list, the call path information can be printed in the table as the second page table.
[0140] S802: Generate a test range result according to the first page table and the second page table.
[0141] In practical applications, the first page table and the second page table may be integrated to obtain a test range result containing two page tables.
[0142] Based on the above principles, the test scope determination method provided in this embodiment includes: generating a call relationship file according to the program call relationship of the new program package and relevant data of the target incremental code, the target incremental code is the incremental code corresponding to the target incremental code report, the target incremental report includes the version difference between the new program package and the old program package, the call relationship file is a set composed of a number of elements, each element corresponds to a method, and its data format includes a package name, a class name and a method name; parsing the call relationship file to obtain the top-level call interface and call path information of the target incremental code, the call path information includes the call relationship file according to the upward call relationship and the downward call relationship Generate a call path; generate a test function list based on the top-level call interface of the target incremental code; determine the test scope results based on the call path information and the test function list. The application can automatically analyze the impact scope based on the program's software package and incremental code coverage report. On the one hand, it can give the top-level entry method affected by the incremental code, thereby obtaining the affected transaction scope. On the other hand, it can give all branch paths involved in the method in the incremental code, and assist in the development and test analysis of the test scenarios designed for the incremental code, that is, it can directly determine the methods of transactions and calling branch paths affected by the changed code, so as to assist testers in quickly defining the test scope.
[0143] It is worth noting that the test scope determination method provided in this application can conveniently and quickly identify the transaction scope affected by the changed code and all call branch paths of the changed code, thereby achieving the following purposes:
[0144] ① Improve test adequacy. If the test scope is determined solely based on the experience of developers, there is a risk of missing the test scope. By using the present invention, the test scope of the transaction dimension is automatically generated, which avoids the risk of missing test transactions and test scenarios and improves test adequacy.
[0145] ② Design test scenarios in a more targeted way. Introducing this solution in functional testing can guide testers to design effective test cases in a more targeted way based on the automatically generated transaction list and branch paths of the changed code, and focus the test cases on the test scenarios caused by the changed code, rather than being exhausted by writing and executing a large number of invalid test cases. It guides the core that testers need to focus on in the right direction, and can help improve the testers' ability to analyze the system and design effective cases.
[0146] ③ Low investment cost. This testing method only requires the war\jar package of the project and the version numbers of the new and old codes. Testers do not need to change the existing test form and process, and do not need to increase additional technical learning and conversion costs.
[0147] Correspondingly, another embodiment of the present application further provides a test range determination device, such as Fig.11 As shown, it mainly includes:
[0148] The first generating unit 101 is used to generate a calling relationship file according to the program calling relationship of the new program package and the relevant data of the target incremental code, the target incremental code is the incremental code corresponding to the target incremental code report, the target incremental report includes the version difference between the new program package and the old program package, the calling relationship file is a set composed of a plurality of elements, each element corresponds to a method, and its data format includes a package name, a class name and a method name;
[0149] A parsing unit 102 is used to parse the call relationship file to obtain the top-level call interface and call path information of the target incremental code, where the call path information includes a call path generated according to the upward call relationship and the downward call relationship in the call relationship file;
[0150] The second generating unit 103 is used to generate a test function list according to the top-level calling interface of the target incremental code;
[0151] The determination unit 104 is used to determine the test range result according to the call path information and the test function list.
[0152] In some embodiments, the process of generating the program call relationship of the new program package includes:
[0153] Get the storage path of the new package;
[0154] Read the new program package according to its storage path to obtain the new program package;
[0155] Perform static code analysis on the new program package to obtain the program call relationship of the new program package;
[0156] The process of generating relevant data of the target incremental code includes:
[0157] Determine the new package version and the old package version;
[0158] Compare the new package version with the old package version to get the target delta code report.
[0159] In some embodiments, the first generating unit 101 is specifically used for:
[0160] Determine the csv file corresponding to the target incremental code;
[0161] Arrange the csv file in a preset way to obtain the initial call relationship file;
[0162] When it is determined that the method in the initial call relationship file exists in the program call relationship of the new program package, the method existing in the program call relationship of the new program package is replaced with the corresponding method in the initial call relationship file to obtain the call relationship file.
[0163] In some embodiments, the first generating unit 101 is further configured to:
[0164] Determine whether the class of the method corresponding to the initial call relationship file exists in the program call relationship of the new program package;
[0165] If it is determined that the class to which the method corresponding to the initial call relationship file belongs does not exist in the program call relationship of the new program package, file version check information is generated.
[0166] In some embodiments, the parsing unit 102 is specifically used to:
[0167] Determine the top-level entry method in the call relationship file based on the upward call chain;
[0168] Determine the element corresponding to the top-level entry method in the call relationship file;
[0169] The top-level calling interface of the target incremental code is determined according to the corresponding element of the top-level entry method in the calling relationship file.
[0170] In some embodiments, the second generating unit 103 is specifically configured to:
[0171] Search the comment content of each top-level call interface in the source code of the new program package in turn to obtain the relevant parameters of each top-level call interface, wherein the relevant parameters of the top-level call interface include the top-level call interface function and the top-level call interface transaction code;
[0172] Print the package name, csv file name, date and time, and comments of each top-level calling interface in the calling relationship file to get the test function list.
[0173] In some embodiments, the determining unit 104 is specifically configured to:
[0174] Determine a first page table and a second page table respectively, the first page table includes a test function list, and the second page table includes call path information;
[0175] A test range result is generated according to the first page table and the second page table.
[0176] The test scope determination device provided in this embodiment includes: a first generating unit 101, which is used to generate a calling relationship file according to the program calling relationship of the new program package and the relevant data of the target incremental code, the target incremental code is the incremental code corresponding to the target incremental code report, the target incremental report includes the version difference between the new program package and the old program package, and the calling relationship file is a set composed of a plurality of elements, each element corresponds to a method, and its data format includes a package name, a class name and a method name; a parsing unit 102 is used to parse the calling relationship file to obtain the top-level calling interface and calling path information of the target incremental code, the calling path information includes the calling relationship file generated according to the upward calling relationship and the downward calling relationship The calling path of the target incremental code is generated by the second generating unit 103 according to the top-level calling interface of the target incremental code. The determining unit 104 is used to determine the test scope result according to the calling path information and the test function list, and can automatically analyze the impact scope according to the software package of the program and the incremental code coverage report. On the one hand, the top-level entry method affected by the incremental code can be given to obtain the affected transaction scope. On the other hand, all branch paths involved in the method in the incremental code can be given to assist in the development and test analysis of the test scenarios designed for the incremental code, that is, the method of directly determining the transactions affected by the changed code and the calling branch path can be directly determined to assist the tester in quickly defining the test scope.
[0177] It should be noted that, for the relevant description of each unit in the test range determination device, reference can also be made to the above method embodiment, and this application will not go into details one by one.
[0178] Optionally, another embodiment of the present application further provides a computer storage medium for storing a computer program, which, when executed, is specifically used to implement the test range determination method provided in any embodiment of the present application.
[0179] It should be noted that, for the relevant description of the test range determination method, please refer to the above embodiment, which will not be repeated here.
[0180] Optionally, another embodiment of the present application further provides an electronic device, which includes a memory and a processor.
[0181] Wherein, the memory is used to store computer programs;
[0182] The processor is used to execute a computer program, specifically to implement the test range determination method provided in any embodiment of the present application.
[0183] It should be noted that, for the relevant description of the test range determination method, reference can also be made to the above embodiment, which will not be repeated here.
[0184] The features recorded in the various embodiments in this specification can be replaced or combined with each other, and the same and similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The system and system embodiments described above are only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work. Professionals can also further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented in electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0185] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0186] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for determining a test range, characterized in that: include: Generate a call relationship file according to the program call relationship of the new program package and relevant data of the target incremental code, wherein the target incremental code is the incremental code corresponding to the target incremental code report, the target incremental report includes the version difference between the new program package and the old program package, and the call relationship file is a set composed of a plurality of elements, each element corresponds to a method, and its data format includes a package name, a class name and a method name; Parsing the call relationship file to obtain the top-level call interface and call path information of the target incremental code, wherein the call path information includes a call path generated by the call relationship file according to an upward call relationship and a downward call relationship; Generate a test function list according to the top-level calling interface of the target incremental code; The test scope result is determined according to the calling path information and the test function list.
2. The test range determination method according to claim 1, characterized in that: The process of generating the program call relationship of the new program package includes: Obtaining a storage path of the new program package; Reading according to the storage path of the new program package to obtain the new program package; Performing static code analysis on the new program package to obtain a program call relationship of the new program package; The target incremental code generation process includes: Determining a version of the new program package and a version of the old program package; The version of the new program package is compared with the version of the old program package to obtain the target incremental code report.
3. The test range determination method according to claim 1, characterized in that: According to the program call relationship of the new package and the relevant data of the target incremental code, the call relationship file is generated including: Determine the csv file corresponding to the target incremental code; Arrange the csv file in a preset manner to obtain an initial call relationship file; When it is determined that the method in the initial calling relationship file exists in the program calling relationship of the new program package, the method existing in the program calling relationship of the new program package is replaced with the corresponding method in the initial calling relationship file to obtain the calling relationship file.
4. The test range determination method according to claim 3, characterized in that: After the csv file is sorted in a preset manner to obtain an initial call relationship file, the method further includes: Determine respectively whether the class to which the method corresponding to the initial call relationship file belongs exists in the program call relationship of the new program package; If it is determined that the class to which the method corresponding to the initial call relationship file belongs does not exist in the program call relationship of the new program package, file version check information is generated.
5. The test range determination method according to claim 1, characterized in that: Parsing the calling relationship file to obtain the top-level calling interface of the target incremental code includes: Determine the top-level entry method in the call relationship file according to the upward call chain; Determine the element corresponding to the top-level entry method in the call relationship file; The top-level calling interface of the target incremental code is determined according to the element corresponding to the top-level entry method in the calling relationship file.
6. The test range determination method according to claim 1, characterized in that: According to the top-level calling interface of the target incremental code, a test function list is generated including: Searching the comment content of each top-level call interface in the source code of the new program package in turn to obtain relevant parameters of each top-level call interface, wherein the relevant parameters of the top-level call interface include a top-level call interface function and a top-level call interface transaction code; The test function list is obtained by printing the program package name, csv file name, date and time and the comment content of each top-level calling interface in the calling relationship file.
7. The test range determination method according to claim 1, characterized in that: Determining the test scope result according to the call path information and the test function list includes: Determine a first page table and a second page table respectively, wherein the first page table includes the test function list, and the second page table includes the call path information; The test range result is generated according to the first page table and the second page table.
8. A test range determination device, characterized in that: include: A first generating unit is used to generate a calling relationship file according to the program calling relationship of the new program package and relevant data of the target incremental code, wherein the target incremental code is an incremental code corresponding to a target incremental code report, wherein the target incremental report includes a version difference between the new program package and the old program package, and the calling relationship file is a set consisting of a plurality of elements, each element corresponds to a method, and the data format of the method includes a package name, a class name, and a method name; A parsing unit, used to parse the call relationship file to obtain the top-level call interface and call path information of the target incremental code, wherein the call path information includes a call path generated according to the upward call relationship and the downward call relationship in the call relationship file; A second generating unit is used to generate a test function list according to the top-level calling interface of the target incremental code; A determination unit is used to determine the test range result according to the call path information and the test function list.
9. An electronic device, characterized in that: include: Memory and processor; Wherein, the memory is used to store computer programs; The processor is used to execute the computer program, specifically to implement the test range determination method as described in any one of claims 1-7.
10. A computer storage medium, characterized in that: Used to store a computer program, which, when executed, is specifically used to implement the test range determination method as described in any one of claims 1-7.