Application test method and apparatus
Patent Information
- Application Number
- CN202310096526.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-19
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2043-01-19
AI Technical Summary
[0005]本发明的一个目的在于提供一种应用测试方法,以解决现有技术中存在的应用测试进度监控的准确性较低,从而不利于提高应用测试的效率的问题
[0048]本发明提供的应用测试方法和装置,通过根据目标应用的变更类中变更代码块对应的代码当量,得到所述变更代码块的当量权重,能够以表征变更代码块在被修改时的对应工作量的代码当量为依据,准确地得到能够表征变更代码块的相对测试价值的当量权重(代码修改时的工作量与其测试价值密切相关);通过根据所述变更类,得到所述变更类对应的重要性权重,能够以变更类的实际信息和情况,准确地确定与变更类实际重要性相符的且能够充分表征变更类相对测试价值的重要性权重;从而,上述步骤提高了整体测试进度监控的准确性;
Smart Images

Figure CN116049007B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of application testing technology, particularly to the field of big data, and especially to an application testing method and apparatus. Background Technology
[0002] During application testing, it is often necessary to monitor the test progress (application testing mainly involves testing the changed code of the application) in order to adjust the test plan and test priority based on the monitored test progress, and to carry out corresponding test planning so that the overall test can be carried out effectively.
[0003] In existing technologies, test progress monitoring primarily involves using SQL for scenario monitoring, statistical analysis of test case execution, and statistical analysis of test environment code coverage. However, scenario monitoring using SQL cannot fully connect to the application code level, leading to the potential for missed test scenarios. Statistical analysis of test case execution does not adequately consider the varying granularity of test cases, resulting in inaccurate test progress data. Furthermore, conventional methods for calculating test environment code coverage fail to account for the different workloads and varying importance of different code segments, relying solely on the number of lines of code to determine coverage, which can still lead to discrepancies between monitored and actual test progress. Therefore, the shortcomings of existing test progress monitoring methods result in low accuracy, hindering overall test adjustments and optimizations, and ultimately reducing application testing efficiency.
[0004] In summary, existing technologies suffer from low accuracy in monitoring application testing progress, which hinders the improvement of application testing efficiency. Summary of the Invention
[0005] One object of this invention is to provide an application testing method to address the problem of low accuracy in application testing progress monitoring in existing technologies, which hinders the improvement of application testing efficiency. Another object of this invention is to provide an application testing apparatus. A further object of this invention is to provide a computer device. A still other object of this invention is to provide a readable medium.
[0006] To achieve the above objectives, one aspect of the present invention discloses an application testing method, the method comprising:
[0007] Based on the code equivalent of the changed code block in the change class of the target application, the equivalent weight of the changed code block is obtained; based on the change class, the importance weight of the change class is obtained.
[0008] The initial coverage rate corresponding to the change class is obtained based on the amount of changed code, the amount of covered code, and the equivalent weight of the changed code block;
[0009] Based on the initial coverage and importance weight, the corrected coverage corresponding to the change class is obtained; based on the corrected coverage, the corresponding change class of the target application is tested.
[0010] Optionally, it may further include:
[0011] Before obtaining the equivalent weight of the modified code block based on the code equivalent corresponding to the modified code block in the target application's modified class,
[0012] The current code and the code before the change of the target application are determined, and the current code and the code before the change are parsed to determine the change class of the target application and the change code block in the change class, and further determine the editing type and node type corresponding to the change code block;
[0013] The corresponding editing type weight is determined based on the editing type, and the corresponding node type weight is determined based on the node type;
[0014] Based on the corresponding node type weight and edit type weight, the code equivalent of the modified code block is obtained.
[0015] Optionally, obtaining the equivalent weight of the change code block based on the code equivalent of the change code block in the change class of the target application includes:
[0016] The total code equivalent of the change class is obtained by summing the code equivalents of all the change code blocks in the change class.
[0017] The equivalent weight of the code block corresponding to the change in the change class is obtained by dividing the equivalent code weight by the total equivalent code weight.
[0018] Optionally, it may further include:
[0019] Before determining the importance weight of the changed class based on its class code size, call hierarchy, and number of methods,
[0020] Based on the preset code analysis tool and the modified class, the corresponding class code size, call hierarchy, and number of methods are obtained.
[0021] Optionally, obtaining the importance weight corresponding to the change class based on the change class includes:
[0022] The importance weight of the modified class is obtained based on the class code size, call hierarchy, and number of methods of the modified class.
[0023] Optionally, obtaining the importance weight corresponding to the changed class based on the class code size, call hierarchy, and number of methods of the changed class includes:
[0024] Based on the class code size and the preset code size mapping information, the code size weight corresponding to the class code size is obtained;
[0025] Based on the call level and the preset call level mapping information, the call level weight corresponding to the call level is obtained;
[0026] Based on the number of methods and the preset method number mapping information, the method number weight corresponding to the number of methods is obtained;
[0027] The importance weight is obtained based on the code volume weight, call level weight, and method number weight.
[0028] Optionally, the determination of the importance weight based on the code volume weight, call hierarchy weight, and method number weight includes:
[0029] The importance parameter corresponding to the change class is obtained by superimposing the code volume weight, call level weight, and method number weight corresponding to the change class;
[0030] The total importance parameter is obtained by summing the importance parameters corresponding to all the change classes of the target application.
[0031] The importance weight corresponding to the change class is obtained by dividing the importance parameter corresponding to the total importance parameter.
[0032] Optionally, obtaining the initial coverage rate corresponding to the change class based on the change code volume, the covered code volume, and the equivalent weight of the change code block includes:
[0033] Based on the amount of covered code and the equivalent weight, the coverage parameter corresponding to the changed code block is obtained;
[0034] Based on the amount of changed code and the equivalent weight, the degree of change parameter corresponding to the changed code block is obtained;
[0035] The coverage parameters corresponding to all the change code blocks of the change class are summed to obtain the total coverage parameter;
[0036] The total change degree parameter is obtained by summing up the change degree parameters corresponding to all the change code blocks of the change class.
[0037] Divide the total coverage parameter by the total change parameter to obtain the initial coverage rate corresponding to the change class.
[0038] Optionally, obtaining the corrected coverage corresponding to the change class based on the corresponding initial coverage and importance weight includes:
[0039] Multiply the initial coverage by the importance weight to obtain the corrected coverage corresponding to the change class.
[0040] Optionally, testing the corresponding change classes of the target application based on the corrected coverage includes:
[0041] Determine whether the correction coverage rate is less than a preset correction coverage rate threshold. If so, test the change class corresponding to the correction coverage rate.
[0042] To achieve the above objectives, another aspect of the present invention discloses an application testing apparatus, the apparatus comprising:
[0043] The weight parsing module is used to obtain the equivalent weight of the changed code block based on the code equivalent of the changed code block in the change class of the target application; and to obtain the importance weight corresponding to the change class based on the change class.
[0044] The initial coverage determination module is used to obtain the initial coverage corresponding to the change class based on the amount of changed code, the amount of covered code, and the equivalent weight of the changed code block.
[0045] The application testing module is used to obtain the corrected coverage corresponding to the change class based on the initial coverage and importance weight; and to test the corresponding change class of the target application based on the corrected coverage.
[0046] The present invention also discloses a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described above.
[0047] The present invention also discloses a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method described above.
[0048] The application testing method and apparatus provided by this invention obtain the equivalent weight of the changed code block based on the code equivalent corresponding to the changed code block in the change class of the target application. This allows for the accurate determination of the equivalent weight that represents the relative testing value of the changed code block, based on the code equivalent representing the workload of the changed code block when it is modified (the workload of code modification is closely related to its testing value). Furthermore, by obtaining the importance weight corresponding to the change class, this allows for the accurate determination of the importance weight that matches the actual importance of the change class and fully represents its relative testing value, based on the actual information and situation of the change class. Therefore, the above steps improve the accuracy of overall test progress monitoring.
[0049] By obtaining the initial coverage rate corresponding to the change class based on the amount of changed code, the amount of covered code, and the equivalent weight of the changed code block, it is possible to more accurately determine the initial coverage rate that represents both the amount of covered code and the degree of test value corresponding to the covered code, based on a full consideration of the relevant code volume and by focusing on the equivalent weight that fully represents the relative test value of the changed code block. This improves the accuracy of overall test progress monitoring.
[0050] By obtaining the corrected coverage corresponding to the change class based on the initial coverage and importance weights, and then testing the corresponding change class of the target application based on the corrected coverage, the accurate initial coverage can be further combined with the importance weights that fully characterize the relative test value and importance of the change class. This fully considers the close relationship between the actual testing situation of the change class and its own nature and the nature of the changed code blocks it includes, accurately obtaining the corrected coverage that fully characterizes the test value and test volume of the code change class. This allows the corrected coverage to more accurately characterize and conform to the test time, actual test volume, and test importance of the corresponding change class—attributes closely related to test progress—improving the accuracy of test progress monitoring. This, in turn, facilitates accurate adjustment and optimization of the overall test, improving the efficiency of the overall application testing.
[0051] The application testing method and apparatus provided by this invention can fully relate to the application code level of specific change classes' change code blocks, thus minimizing the omission of test scenarios. By incorporating relevant importance and workload attributes, it accurately considers the granularity of test cases and the code under test, and further fully considers the correlation between the workload, test importance, and test value of different code segments and the test progress. Therefore, it can significantly improve the accuracy of test progress monitoring, thereby improving the overall efficiency of application testing.
[0052] In summary, the application testing method and apparatus provided by this invention can improve the accuracy of application testing progress monitoring, thereby improving the efficiency of application testing. Attached Figure Description
[0053] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0054] Figure 1 A flowchart illustrating an application testing method according to an embodiment of the present invention is shown;
[0055] Figure 2 A schematic diagram illustrating an optional step in determining the equivalent weight of a modified code block according to an embodiment of the present invention is shown.
[0056] Figure 3 A schematic diagram illustrating an optional step in determining the importance weight of a change class according to an embodiment of the present invention is shown.
[0057] Figure 4 A schematic diagram illustrating an optional step in determining the initial coverage of a change class according to an embodiment of the present invention is shown.
[0058] Figure 5 A schematic diagram illustrating an optional step in determining the correction coverage of a change class according to an embodiment of the present invention is shown.
[0059] Figure 6 A schematic diagram of an application testing device according to an embodiment of the present invention is shown;
[0060] Figure 7 A schematic diagram of a computer device suitable for implementing embodiments of the present invention is shown. Detailed Implementation
[0061] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0062] The terms "first," "second," etc., used in this document are not intended to specifically refer to order or sequence, nor are they intended to limit the invention. They are merely used to distinguish elements or operations described using the same technical terms.
[0063] The terms “include,” “including,” “have,” “contain,” etc., used in this article are all open-ended terms, meaning that they include but are not limited to.
[0064] The term "and / or" as used herein includes any or all of the things mentioned.
[0065] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of this invention all comply with the relevant provisions of national laws and regulations.
[0066] It should be noted that the application testing method and apparatus disclosed in this application can be used in the field of big data, or in any field other than big data. The application field of the application testing method and apparatus disclosed in this application is not limited.
[0067] This invention discloses an application testing method, such as... Figure 1 As shown, the method specifically includes the following steps:
[0068] S101: Obtain the equivalent weight of the changed code block based on the equivalent code of the changed code block in the change class of the target application; obtain the importance weight of the change class based on the change class.
[0069] S102: Based on the amount of changed code, the amount of covered code, and the equivalent weight of the changed code block, obtain the initial coverage rate corresponding to the change class.
[0070] S103: Based on the initial coverage and importance weight, obtain the corrected coverage corresponding to the change class; based on the corrected coverage, test the corresponding change class of the target application.
[0071] For example, a target application may correspond to multiple change classes, a change class may correspond to multiple change code blocks, a change code block may correspond to a code equivalent and an equivalent weight, and a change class may correspond to an importance weight, initial coverage, and revised coverage. It should be noted that the relevant correspondences can be determined by those skilled in the art based on the actual situation; the above description is merely an example and does not constitute a limitation.
[0072] For example, in this embodiment of the invention, "coverage" refers to test coverage. For instance, coverage rate refers to the coverage of the corresponding code during testing, and the amount of covered code refers to the amount of corresponding code covered by the test.
[0073] For example, the amount of code in an embodiment of the present invention can be, but is not limited to, the number of lines of code.
[0074] For example, the tests in this embodiment of the invention can be applied in scenarios that are, but not limited to, testing the relative changes in code content between the updated and unupdated versions of the target application after a version update. It should be noted that the specific application scenario for the tests can be determined by those skilled in the art based on actual circumstances; the above description is merely an example and does not constitute a limitation.
[0075] The application testing method and apparatus provided by this invention obtain the equivalent weight of the changed code block based on the code equivalent corresponding to the changed code block in the change class of the target application. This allows for the accurate determination of the equivalent weight that represents the relative testing value of the changed code block, based on the code equivalent representing the workload of the changed code block when it is modified (the workload of code modification is closely related to its testing value). Furthermore, by obtaining the importance weight corresponding to the change class, this allows for the accurate determination of the importance weight that matches the actual importance of the change class and fully represents its relative testing value, based on the actual information and situation of the change class. Therefore, the above steps improve the accuracy of overall test progress monitoring.
[0076] By obtaining the initial coverage rate corresponding to the change class based on the amount of changed code, the amount of covered code, and the equivalent weight of the changed code block, it is possible to more accurately determine the initial coverage rate that represents both the amount of covered code and the degree of test value corresponding to the covered code, based on a full consideration of the relevant code volume and by focusing on the equivalent weight that fully represents the relative test value of the changed code block. This improves the accuracy of overall test progress monitoring.
[0077] By obtaining the corrected coverage corresponding to the change class based on the initial coverage and importance weights, and then testing the corresponding change class of the target application based on the corrected coverage, the accurate initial coverage can be further combined with the importance weights that fully characterize the relative test value and importance of the change class. This fully considers the close relationship between the actual testing situation of the change class and its own nature and the nature of the changed code blocks it includes, accurately obtaining the corrected coverage that fully characterizes the test value and test volume of the code change class. This allows the corrected coverage to more accurately characterize and conform to the test time, actual test volume, and test importance of the corresponding change class—attributes closely related to test progress—improving the accuracy of test progress monitoring. This, in turn, facilitates accurate adjustment and optimization of the overall test, improving the efficiency of the overall application testing.
[0078] The application testing method and apparatus provided by this invention can fully relate to the application code level of specific change classes' change code blocks, thus minimizing the omission of test scenarios. By incorporating relevant importance and workload attributes, it accurately considers the granularity of test cases and the code under test, and further fully considers the correlation between the workload, test importance, and test value of different code segments and the test progress. Therefore, it can significantly improve the accuracy of test progress monitoring, thereby improving the overall efficiency of application testing.
[0079] In summary, the application testing method and apparatus provided by this invention can improve the accuracy of application testing progress monitoring, thereby improving the efficiency of application testing.
[0080] In one optional implementation, it further includes:
[0081] Before obtaining the equivalent weight of the modified code block based on the code equivalent corresponding to the modified code block in the target application's modified class,
[0082] The current code and the code before the change of the target application are determined, and the current code and the code before the change are parsed to determine the change class of the target application and the change code block in the change class, and further determine the editing type and node type corresponding to the change code block;
[0083] The corresponding editing type weight is determined based on the editing type, and the corresponding node type weight is determined based on the node type;
[0084] Based on the corresponding node type weight and edit type weight, the code equivalent of the modified code block is obtained.
[0085] For example, determining the current code and the code before the change of the target application can be, but is not limited to, determining the entire code of the current version of the target application as the current code, and determining the entire code of the previous version of the target application as the code before the change. It should be noted that the specific implementation method for determining the current code and the code before the change of the target application can be determined by those skilled in the art based on the actual situation; the above description is merely an example and does not constitute a limitation.
[0086] For example, the changed class can be, but is not limited to, a class in the current code that has changed relative to the code before the change. For instance, if there is a class A in the code before the change, and the code of class A in the current code has been modified or changed relative to the code of class A in the code before the change, then class A is a changed class. Correspondingly, the changed code block can be, but is not limited to, a specific code block in the class that has changed relative to the code before the change, and can also be called, but is not limited to, a code change block. For instance, if the code of a certain code block A of class A in the current code has been modified or changed relative to the code block A of class A in the code before the change, then code block A is a changed code block. It should be noted that the nature of the changed class and changed code block can be determined by those skilled in the art based on the actual situation. The above description is only an example and does not constitute a limitation.
[0087] For example, the step of parsing the current code and the code before the change to determine the change class of the target application and the changed code blocks within the change class, and further determining the edit type and node type corresponding to the changed code blocks, can be, but is not limited to, processing based on the Equivalent Line of Code (ELOC) algorithm, performing syntax tree comparison parsing on the current code and the code before the change (e.g., performing AST syntax tree parsing), directly determining the change class of the target application and the changed code blocks within the change class, and directly determining the edit type and node type corresponding to the changed code blocks (one changed code block corresponds to one syntax tree node). During the comparison parsing process, tree diff algorithms may also be involved, for example, referring to existing code equivalent calculation processes. It should be noted that the specific implementation method for parsing the current code and the code before the change to determine the change class of the target application and the changed code blocks within the change class, and further determining the edit type and node type corresponding to the changed code blocks, can be determined by those skilled in the art based on the actual situation. The above description is merely an example and does not constitute a limitation.
[0088] For example, the edit type can be, but is not limited to, adding, deleting, moving, or modifying code blocks. The node type can be, but is not limited to, methods, branches, assignments, or annotations. The AST tool can define various elements in the code, such as lines of code like methods, branches, assignments, or annotations, as corresponding node objects, thereby obtaining the corresponding node types. It should be noted that the range of values for edit types and node types can be determined by those skilled in the art based on the actual situation; the above description is merely illustrative and does not constitute a limitation.
[0089] For example, determining the corresponding edit type weight based on the edit type and the corresponding node type weight based on the node type can be, but is not limited to, processing steps based on existing Equivalent Line of Code (ELOC) algorithms, mapping the node type to obtain the corresponding node type weight based on preset type weight mapping information, and mapping the edit type to obtain the corresponding edit type weight. It should be noted that the specific implementation of determining the corresponding edit type weight based on the edit type and the corresponding node type weight based on the node type can be determined by those skilled in the art according to the actual situation. The above description is merely an example and does not constitute a limitation.
[0090] For example, obtaining the code equivalent corresponding to the modified code block based on the corresponding node type weight and edit type weight can be, but is not limited to, multiplying the node type weight of the modified code block by the edit type weight to obtain the corresponding code equivalent. Here, one modified code block corresponds to one node type weight (node type), one edit type weight (edit type), and one code equivalent. It should be noted that the specific implementation of obtaining the code equivalent corresponding to the modified code block based on the corresponding node type weight and edit type weight can be determined by those skilled in the art based on the actual situation; the above description is merely an example and does not constitute a limitation.
[0091] By following the steps above, we can accurately determine the changed class, changed code block, and the corresponding code equivalent using the standard code equivalent calculation principle. This makes the code equivalent more consistent with the degree of change and workload of the code block, thereby improving the accuracy of overall application testing progress monitoring and ultimately improving the efficiency of overall application testing.
[0092] In one alternative implementation, such as Figure 2 As shown, obtaining the equivalent weight of the changed code block based on the equivalent code in the changed code block of the target application includes the following steps:
[0093] S201: The code equivalents of all the modified code blocks in the modified class are summed to obtain the total code equivalents corresponding to the modified class.
[0094] S202: Divide the equivalent code of the modified code block in the modified class by the total equivalent code to obtain the equivalent weight of the modified code block.
[0095] For example, a change code block corresponds to an equivalent weight. Correspondingly, step S202 can be, but is not limited to, dividing the code equivalent corresponding to a certain change code block by the total code equivalent to obtain the equivalent weight corresponding to that single change code block.
[0096] By taking the steps described above, we can more accurately obtain the equivalent weight that can characterize the relative testing value of the changed code block, based on the proportion of the code equivalent of a single code block in the total cumulative code equivalent of the overall change class, while fully considering relevant mathematical and computer principles. This further improves the accuracy of overall application testing progress monitoring and, consequently, the efficiency of overall application testing.
[0097] In an optional implementation, it further includes:
[0098] Before determining the importance weight of the changed class based on its class code size, call hierarchy, and number of methods,
[0099] Based on the preset code analysis tool and the modified class, the corresponding class code size, call hierarchy, and number of methods are obtained.
[0100] For example, obtaining the corresponding class code size, call hierarchy, and number of methods based on the preset code analysis tool and the modified class can be, but is not limited to, using the code analysis tool to parse the modified class to obtain the corresponding class code size, call hierarchy, and number of methods. The code analysis tool can be, but is not limited to, tools such as starTool. One modified class corresponds to one class code size, one call hierarchy, and one number of methods. It should be noted that the specific implementation method and the type of code analysis tool used to obtain the corresponding class code size, call hierarchy, and number of methods based on the preset code analysis tool and the modified class can be determined by those skilled in the art based on the actual situation. The above description is merely an example and does not constitute a limitation.
[0101] For example, the class code size can be, but is not limited to, the number of lines of code in the corresponding modified class; the call hierarchy can be, but is not limited to, the hierarchy to which the modified class belongs in the corresponding call chain; and the number of methods can be, but is not limited to, the number of methods included or involved in the corresponding modified class. It should be noted that the specific nature of the class code size, call hierarchy, and number of methods can be determined by those skilled in the art based on the actual situation. The above description is merely an example and does not constitute a limitation.
[0102] By following the steps above, we can quickly and accurately determine the importance and testing value of the changes, thereby improving the accuracy and speed of overall test progress monitoring and ultimately increasing the efficiency of overall application testing.
[0103] In an optional implementation, obtaining the importance weight corresponding to the change class based on the change class includes:
[0104] The importance weight of the modified class is obtained based on the class code size, call hierarchy, and number of methods of the modified class.
[0105] By following the steps above, the importance weights can be fully integrated with relevant information that characterizes the importance of change classes and their testing value. This results in importance weights that are more consistent with the actual importance of change classes and can more fully characterize their relative testing value. Consequently, the accuracy and speed of overall test progress monitoring are improved, and thus the efficiency of overall application testing is increased.
[0106] In one alternative implementation, such as Figure 3 As shown, obtaining the importance weight of the modified class based on its class code size, call hierarchy, and number of methods includes the following steps:
[0107] S301: Based on the class code size and the preset code size mapping information, obtain the code size weight corresponding to the class code size.
[0108] S302: Based on the call level and the preset call level mapping information, obtain the call level weight corresponding to the call level.
[0109] S303: Based on the number of methods and the preset method number mapping information, obtain the method number weight corresponding to the number of methods.
[0110] S304: The importance weight is obtained based on the code volume weight, call level weight, and method number weight.
[0111] For example, step S301 may involve, but is not limited to, querying the code amount mapping information using the class code amount to obtain the code amount weight corresponding to the class code amount. The code amount mapping information may be, but is not limited to, mapping information representing the correspondence between the corresponding code amount value range and the code amount weight. For example, when the number of lines of code is 0 to 10, the code amount weight is 1; when the number of lines of code is 10 to 20, the code amount weight is 2, etc. It should be noted that the specific implementation of step S301 and the specific content of the code amount mapping information can be determined by those skilled in the art based on actual circumstances. The above description is merely an example and does not constitute a limitation.
[0112] For example, step S302 can be, but is not limited to, querying the call level mapping information using the call level to obtain the call level weight corresponding to the call level. The call level mapping information can be, but is not limited to, mapping information representing the correspondence between the value range of the corresponding call level and the call level weight. For example, when the call level is from the lowest level (e.g., there exists a call chain: class A calls class B, class B calls class C, and class C calls class D, and the class is changed to D, then the level where D is located is the lowest level) to the 3rd level, the code weight is 1; when the code level is from the 3rd level to the 5th level, the code weight is 2, etc. It should be noted that the specific implementation of step S302 and the specific content of the call level mapping information can be determined by those skilled in the art based on the actual situation. The above description is only an example and does not constitute a limitation.
[0113] For example, step S303 may involve, but is not limited to, querying the method quantity mapping information using the number of methods to obtain the method quantity weight corresponding to the number of methods. The method quantity mapping information may be, but is not limited to, mapping information representing the correspondence between the range of corresponding method quantity values and the method quantity weight. For example, when the number of methods is 0 to 5 rows, the method quantity weight is 1; when the number of methods is 10 to 20 rows, the method quantity weight is 2, and so on. It should be noted that the specific implementation of step S303 and the specific content of the method quantity mapping information can be determined by those skilled in the art based on actual circumstances. The above description is merely an example and does not constitute a limitation.
[0114] By taking the steps described above, we can fully consider the correlation between the code size of the modified class and the complexity of its business logic, the correlation between the call level and the importance and amount of business logic in the modified class (for example, classes with lower-level call relationships, such as abstract classes or interface classes, have almost no business logic), and the correlation between the number of methods and the complexity and importance of the business logic in the modified class. By specifically quantifying and calculating these attributes such as class code size, call level, and number of methods, the resulting importance weights are more consistent with the actual importance of the modified class and fully represent the relative testing value of the modified class, thereby improving the accuracy of overall test progress monitoring and ultimately improving the efficiency of overall application testing.
[0115] In an optional implementation, obtaining the importance weight based on the code volume weight, call hierarchy weight, and method number weight includes:
[0116] The importance parameter corresponding to the change class is obtained by superimposing the code volume weight, call level weight, and method number weight corresponding to the change class;
[0117] The total importance parameter is obtained by summing the importance parameters corresponding to all the change classes of the target application.
[0118] The importance weight corresponding to the change class is obtained by dividing the importance parameter corresponding to the total importance parameter.
[0119] For example, one change class corresponds to one importance parameter, all change classes in a target application correspond to one total importance parameter, and one change class corresponds to one importance weight.
[0120] For example, dividing the importance parameter corresponding to the change class by the total importance parameter to obtain the importance weight corresponding to the change class can be, but is not limited to, dividing the importance parameter corresponding to a certain change class by the total importance parameter to obtain the importance weight corresponding to that single change class.
[0121] By following the steps above, the importance weights can reflect the proportion of importance in the overall target application, further improving the accuracy of determining the importance weights, thereby improving the accuracy of overall test progress monitoring and ultimately improving the efficiency of overall application testing.
[0122] In one alternative implementation, such as Figure 4 As shown, obtaining the initial coverage rate corresponding to the change class based on the change code volume, the covered code volume, and the equivalent weight of the change code block includes the following steps:
[0123] S401: Based on the coverage code amount and equivalent weight, obtain the coverage parameter corresponding to the changed code block.
[0124] S402: Based on the change code quantity and equivalent weight, obtain the change degree parameter corresponding to the change code block.
[0125] S403: The coverage parameters corresponding to all the change code blocks of the change class are summed to obtain the total coverage parameter.
[0126] S404: The change degree parameters corresponding to all the change code blocks of the change class are summed to obtain the total change degree parameter.
[0127] S405: Divide the total coverage parameter by the total change parameter to obtain the initial coverage rate corresponding to the change class.
[0128] For example, a modified code block corresponds to a modified code quantity and a covered code quantity. The modified code quantity can be, but is not limited to, the number of lines of code in the modified code block that have changed compared to the previous version of the target application, and can be determined through, but is not limited to, comparison and parsing methods. The covered code quantity can be, but is not limited to, the number of lines of code in the modified code block that have been tested, and can be determined through, but is not limited to, corresponding parsing or recording. It should be noted that the meaning and acquisition method of the modified code quantity and the covered code quantity can be determined by those skilled in the art based on the actual situation. The above description is only an example and does not constitute a limitation.
[0129] For example, step S401 can be, but is not limited to, multiplying the coverage code amount and the equivalent weight to obtain the corresponding coverage parameter. It should be noted that the specific implementation of step S401 can be determined by those skilled in the art based on actual circumstances; the above description is merely an example and does not constitute a limitation.
[0130] For example, step S402 can be, but is not limited to, multiplying the amount of changed code and the equivalent weight to obtain the corresponding change degree parameter. It should be noted that the specific implementation of step S402 can be determined by those skilled in the art based on actual circumstances; the above description is merely an example and does not constitute a limitation.
[0131] For example, all the change code blocks of a change class correspond to a total coverage parameter and a total change parameter. A change class corresponds to an initial coverage.
[0132] Through the above steps, the changes in code volume, the amount of covered code, and the equivalent weight can be further refined and deepened. Based on the principles and mathematical principles of application testing, the granularity of the operation object is further refined by taking the changed code block in the change class as the operation object, which greatly improves the accuracy of determining the initial coverage, thereby improving the accuracy of overall test progress monitoring and thus improving the efficiency of overall application testing.
[0133] In one alternative implementation, such as Figure 5 As shown, obtaining the corrected coverage rate corresponding to the change class based on the corresponding initial coverage rate and importance weight includes the following steps:
[0134] S501: Multiply the initial coverage by the importance weight to obtain the corrected coverage corresponding to the change class.
[0135] Through the above steps, the accurate initial coverage rate can be combined with the importance weights that fully characterize the relative test value and importance of the change class. Furthermore, it fully considers the close relationship between the actual testing situation of the change class and its own nature and the nature of the change code blocks it includes. This allows for a more accurate revised coverage rate that fully characterizes the test value and test volume of the code change class. The revised coverage rate more accurately represents and conforms to the test time, actual test volume, and test importance of the corresponding change class, which are closely related to the test progress. As a result, the revised coverage rate is more consistent with the actual test progress of the application change class, further improving the accuracy of test progress monitoring. This, in turn, facilitates the accurate adjustment and optimization of the overall test, and improves the efficiency of the overall application test.
[0136] In an optional implementation, testing the corresponding change class of the target application based on the corrected coverage includes:
[0137] Determine whether the correction coverage rate is less than a preset correction coverage rate threshold. If so, test the change class corresponding to the correction coverage rate.
[0138] For example, the corrected coverage threshold can be, but is not limited to, a threshold belonging to the value range [60%, 80%]. It should be noted that the corrected coverage threshold can be determined by those skilled in the art based on the actual situation; the above description is merely an example and does not constitute a limitation.
[0139] For example, the testing of the change class corresponding to the corrected coverage can be, but is not limited to, performing conventional automated testing or manual testing on the corresponding change class. The specific method of automated testing or manual testing can be determined by those skilled in the art based on the actual situation, and the embodiments of the present invention do not impose any restrictions on this.
[0140] Preferably, tests can also be prioritized for change classes whose correction coverage is less than a preset correction coverage threshold.
[0141] Preferably, when the corresponding correction coverage is determined to be less than a preset correction coverage threshold, an alarm message for the corresponding change type is sent to the relevant testers so that the relevant testers can test the change type with low correction coverage as soon as possible, thereby improving the speed and coordination of the overall test.
[0142] By following the steps above, we can expedite the testing of the corresponding modified code when the testing progress is slow, thereby improving the overall application testing speed. Furthermore, by using the modified class as the specific granularity, we can more deeply and accurately adjust and optimize the corresponding testing process based on the testing progress, thus significantly improving the overall application testing efficiency.
[0143] Based on the same principle, this invention discloses an application testing device 600, such as... Figure 6 As shown, the application testing apparatus 600 includes:
[0144] The weight parsing module 601 is used to obtain the equivalent weight of the changed code block based on the equivalent code of the changed code block in the change class of the target application; and to obtain the importance weight corresponding to the change class based on the change class.
[0145] The initial coverage determination module 602 is used to obtain the initial coverage corresponding to the change class based on the amount of changed code, the amount of covered code, and the equivalent weight of the changed code block.
[0146] The application testing module 603 is used to obtain the corrected coverage corresponding to the change class based on the initial coverage and importance weight; and to test the corresponding change class of the target application based on the corrected coverage.
[0147] In an optional implementation, a code equivalent determination module is further included, for:
[0148] Before obtaining the equivalent weight of the modified code block based on the code equivalent corresponding to the modified code block in the target application's modified class,
[0149] The current code and the code before the change of the target application are determined, and the current code and the code before the change are parsed to determine the change class of the target application and the change code block in the change class, and further determine the editing type and node type corresponding to the change code block;
[0150] The corresponding editing type weight is determined based on the editing type, and the corresponding node type weight is determined based on the node type;
[0151] Based on the corresponding node type weight and edit type weight, the code equivalent of the modified code block is obtained.
[0152] In an optional implementation, the weight parsing module 601 is configured to:
[0153] The total code equivalent of the change class is obtained by summing the code equivalents of all the change code blocks in the change class.
[0154] The equivalent weight of the code block corresponding to the change in the change class is obtained by dividing the equivalent code weight by the total equivalent code weight.
[0155] In an optional implementation, a class information determination module is further included, for:
[0156] Before determining the importance weight of the changed class based on its class code size, call hierarchy, and number of methods,
[0157] Based on the preset code analysis tool and the modified class, the corresponding class code size, call hierarchy, and number of methods are obtained.
[0158] In an optional implementation, the weight parsing module 601 is configured to:
[0159] The importance weight of the modified class is obtained based on the class code size, call hierarchy, and number of methods of the modified class.
[0160] In an optional implementation, the weight parsing module 601 is configured to:
[0161] Based on the class code size and the preset code size mapping information, the code size weight corresponding to the class code size is obtained;
[0162] Based on the call level and the preset call level mapping information, the call level weight corresponding to the call level is obtained;
[0163] Based on the number of methods and the preset method number mapping information, the method number weight corresponding to the number of methods is obtained;
[0164] The importance weight is obtained based on the code volume weight, call level weight, and method number weight.
[0165] In an optional implementation, the weight parsing module 601 is configured to:
[0166] The importance parameter corresponding to the change class is obtained by superimposing the code volume weight, call level weight, and method number weight corresponding to the change class;
[0167] The total importance parameter is obtained by summing the importance parameters corresponding to all the change classes of the target application.
[0168] The importance weight corresponding to the change class is obtained by dividing the importance parameter corresponding to the total importance parameter.
[0169] In an optional implementation, the initial coverage determination module 602 is configured to:
[0170] Based on the amount of covered code and the equivalent weight, the coverage parameter corresponding to the changed code block is obtained;
[0171] Based on the amount of changed code and the equivalent weight, the degree of change parameter corresponding to the changed code block is obtained;
[0172] The coverage parameters corresponding to all the change code blocks of the change class are summed to obtain the total coverage parameter;
[0173] The total change degree parameter is obtained by summing up the change degree parameters corresponding to all the change code blocks of the change class.
[0174] Divide the total coverage parameter by the total change parameter to obtain the initial coverage rate corresponding to the change class.
[0175] In an optional implementation, the application testing module 603 is used for:
[0176] Multiply the initial coverage by the importance weight to obtain the corrected coverage corresponding to the change class.
[0177] In an optional implementation, the application testing module 603 is used for:
[0178] Determine whether the correction coverage rate is less than a preset correction coverage rate threshold. If so, test the change class corresponding to the correction coverage rate.
[0179] Since the principle of this application testing device 600 in solving the problem is similar to the above methods, the implementation of this application testing device 600 can refer to the implementation of the above methods, and will not be repeated here.
[0180] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer device, specifically, a computer device can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0181] In a typical example, a computer device specifically includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method described above.
[0182] The following is for reference. Figure 7 It shows a schematic diagram of the structure of a computer device 700 suitable for implementing the embodiments of this application.
[0183] like Figure 7As shown, the computer device 700 includes a central processing unit (CPU) 701, which can perform various appropriate tasks and processes based on programs stored in read-only memory (ROM) 702 or programs loaded from storage section 708 into random access memory (RAM) 703. The RAM 703 also stores various programs and data required for the operation of the system 700. The CPU 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0184] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, mouse, etc.; an output section 707 including a cathode ray tube (CRT), liquid crystal feedback (LCD), etc., and speakers, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 710 as needed so that computer programs read from it can be installed in the storage section 708 as needed.
[0185] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program including program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 709, and / or installed from removable medium 711.
[0186] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0187] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.
[0188] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0189] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0190] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0191] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0192] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0193] This application can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0194] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0195] The above description is merely an embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of this application should be included within the scope of the claims of this application.
Claims
1. An application testing method, characterized in that, include: The equivalent weight of the modified code block is obtained based on the equivalent code of the modified code block in the modified class of the target application. Based on the change class, the importance weight corresponding to the change class is obtained; The initial coverage rate corresponding to the change class is obtained based on the amount of changed code, the amount of covered code, and the equivalent weight of the changed code block; Based on the initial coverage rate and importance weight, the corrected coverage rate corresponding to the change class is obtained; Based on the corrected coverage, test the corresponding change classes of the target application; The step of obtaining the equivalent weight of the changed code block based on the code equivalent of the changed code block in the change class of the target application includes: summing the code equivalents of all the changed code blocks in the change class to obtain the total code equivalent of the change class; and dividing the code equivalent of the changed code block in the change class by the total code equivalent to obtain the equivalent weight of the changed code block. The step of obtaining the importance weight corresponding to the change class based on the change class includes: Based on the class code size of the changed class and the preset code size mapping information, the code size weight corresponding to the class code size is obtained; Based on the call level of the changed class and the preset call level mapping information, the call level weight corresponding to the call level is obtained; Based on the number of methods in the changed class and the preset method number mapping information, the method number weight corresponding to the number of methods is obtained; The importance weight is obtained based on the code volume weight, the call level weight, and the number of methods weight.
2. The method according to claim 1, characterized in that, Further includes: Before obtaining the equivalent weight of the modified code block based on the code equivalent corresponding to the modified code block in the target application's modified class, The current code and the code before the change of the target application are determined, and the current code and the code before the change are parsed to determine the change class of the target application and the change code block in the change class, and further determine the editing type and node type corresponding to the change code block; The corresponding editing type weight is determined based on the editing type, and the corresponding node type weight is determined based on the node type; Based on the corresponding node type weight and edit type weight, the code equivalent of the modified code block is obtained.
3. The method according to claim 1, characterized in that, Further includes: Before determining the importance weight of the changed class based on its class code size, call hierarchy, and number of methods, Based on the preset code analysis tool and the modified class, the corresponding class code size, call hierarchy, and number of methods are obtained.
4. The method according to claim 1, characterized in that, The importance weight is derived based on the code volume weight, call hierarchy weight, and method number weight, including: The importance parameter corresponding to the change class is obtained by superimposing the code volume weight, call level weight, and method number weight corresponding to the change class; The total importance parameter is obtained by summing the importance parameters corresponding to all the change classes of the target application. The importance weight corresponding to the change class is obtained by dividing the importance parameter corresponding to the total importance parameter.
5. The method according to claim 1, characterized in that, The step of obtaining the initial coverage rate corresponding to the change class based on the change code volume, the covered code volume, and the equivalent weight of the change code block includes: Based on the amount of covered code and the equivalent weight, the coverage parameter corresponding to the changed code block is obtained; Based on the amount of changed code and the equivalent weight, the degree of change parameter corresponding to the changed code block is obtained; The coverage parameters corresponding to all the change code blocks of the change class are summed to obtain the total coverage parameter; The total change degree parameter is obtained by summing up the change degree parameters corresponding to all the change code blocks of the change class. Divide the total coverage parameter by the total change parameter to obtain the initial coverage rate corresponding to the change class.
6. The method according to claim 1, characterized in that, The step of obtaining the corrected coverage corresponding to the change class based on the corresponding initial coverage and importance weight includes: Multiply the initial coverage by the importance weight to obtain the corrected coverage corresponding to the change class.
7. The method according to claim 1, characterized in that, The step of testing the corresponding change classes of the target application based on the corrected coverage includes: Determine whether the correction coverage rate is less than a preset correction coverage rate threshold. If so, test the change class corresponding to the correction coverage rate.
8. An application testing device, characterized in that, include: The weight parsing module is used to obtain the equivalent weight of the changed code block based on the equivalent code of the changed code block in the changed class of the target application. Based on the change class, the importance weight corresponding to the change class is obtained; The initial coverage determination module is used to obtain the initial coverage corresponding to the change class based on the amount of changed code, the amount of covered code, and the equivalent weight of the changed code block. The application testing module is used to obtain the corrected coverage corresponding to the change class based on the initial coverage and importance weight; and to test the corresponding change class of the target application based on the corrected coverage. The weight parsing module is used to: sum up the code equivalents of all the changed code blocks in the changed class to obtain the total code equivalents corresponding to the changed class; The equivalent weight of the code block corresponding to the change in the change class is obtained by dividing the equivalent code of the total code by the equivalent code of the change. The weight parsing module is used to obtain the code weight corresponding to the code size of the class based on the code size of the changed class and the preset code size mapping information. Based on the call level of the changed class and the preset call level mapping information, the call level weight corresponding to the call level is obtained; Based on the number of methods in the changed class and the preset method number mapping information, the method number weight corresponding to the number of methods is obtained; The importance weight is obtained based on the code volume weight, the call level weight, and the number of methods weight.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1-7.
10. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Code coverage test method and device, computer equipment and storage medium
CN115248779A
Workload determination method and device, computer equipment and readable storage medium
CN115345531A