Demand test coverage rate statistical method and device, electronic equipment and storage medium

By obtaining and processing the code data associated with requirements and calculating the requirements test coverage rate, the problem of insufficient accuracy of traditional code test coverage statistics is solved, high-precision statistics of the requirements-related code is realized, and the analysis ability of the test process is improved.

CN119201677APending Publication Date: 2024-12-27SHENZHEN PANGO MICROSYST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411124655.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-15
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Traditional code test coverage statistics technology cannot achieve the accuracy of the requirement level and cannot effectively distinguish the code part associated with the requirements during development and testing, resulting in insufficient statistical accuracy.

Method used

By obtaining the requirement number, original code line click data and the list of requirements related code files, calculate the requirement correlation change code line, convert it into a requirement correlation rule file, and calculate the requirement test coverage rate based on the preset formula to filter out the code that is not related to the requirement. Improve statistical accuracy.

Benefits of technology

It realizes accurate calculation of the coverage rate of the requirement test, improves the analysis accuracy, avoids interference with the coverage calculation by the requirement-independent code, and improves statistical accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201677A_ABST
    Figure CN119201677A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of software testing, and discloses a demand test coverage rate statistical method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring an original code line click data list and a demand associated code file list according to a demand number; obtaining a demand association change code line list according to the demand association code file list and the received current to-be-tested demand data; converting the demand association change code line list into a demand association rule file through a preset first data conversion rule; analyzing the demand association rule file to obtain a demand association rule, and executing the demand association rule according to the original code line click data list to obtain target demand association code line click data; and according to a preset demand test coverage rate formula and the target demand associated code line, clicking data calculation to obtain a corresponding demand test coverage rate, and filtering interference of a demand-independent code, so that the coverage rate precision and accuracy are further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing technology, and in particular to a method, device, electronic device and storage medium for statistical coverage of demand testing. Background Art

[0002] In software testing technology, code test coverage is an important indicator to measure the scope of software code covered by test cases. On the one hand, code test coverage can assist testers in judging whether test cases are effective and sufficient, and promptly discover errors and defects in the software. On the other hand, code test coverage can assist developers in improving code quality. Traditional software testing technology already has a variety of code test coverage statistics schemes, including line coverage, branch coverage, path coverage, and condition coverage. The difference between the aforementioned traditional code coverage statistics schemes is that coverage statistics are performed according to different code area definitions. However, in the actual software development process, developers will conduct self-tests after completing demand development, and only after the self-tests pass will they submit them to testers for retesting. At this time, developers and testers only need to pay attention to the test coverage data of the code part associated with the demand. The traditional code test coverage statistics scheme cannot achieve the code coverage statistics of the demand level dimension required by the aforementioned test scenarios. Summary of the invention

[0003] The main technical problem solved by the implementation methods of the present application is that the statistical accuracy of traditional code coverage statistics technology is insufficient.

[0004] To solve the above technical problems, the first technical solution adopted by the implementation method of the present application is: to provide a requirement test coverage statistics method, including: obtaining an original code line click data list and a requirement-associated code file list according to the requirement number; obtaining a requirement-associated changed code line list according to the requirement-associated code file list and the received current requirement data to be tested; converting the requirement-associated changed code line list into a requirement association rule file by presetting a first data conversion rule; parsing the requirement association rule file to obtain requirement association rules, and executing the requirement association rules according to the original code line click data list to obtain target requirement-associated code line click data; calculating according to the preset requirement test coverage formula and the target requirement-associated code line click data to obtain the corresponding requirement test coverage.

[0005] Optionally, the step of obtaining the original code line click data list and the requirement-associated code file list according to the requirement number includes: obtaining the line numbers of the executed code lines in the self-test process and the transfer test process, and the click count information of the executed code lines according to the requirement number; obtaining the changed code files corresponding to the current requirement test from the code management tool, wherein the changed code files include newly added code files and modified code files.

[0006] Optionally, the step of obtaining a list of requirement-associated changed code lines based on the requirement-associated code file list and the received current requirement data to be tested includes: traversing the change types of the change code files in the requirement-associated code file list; if the change type is a new addition type, adding the corresponding new change code file to the requirement-associated change code line list; if the change type is a modified type, obtaining the modified line number of the modified code line in the corresponding modified change code file, and adding the corresponding modified change code file and the corresponding modified line number to the requirement-associated change code line list.

[0007] Optionally, the step of converting the requirement-associated change code line list into a requirement association rule file by presetting a first data conversion rule includes: parsing the requirement-associated change code line list, and traversing the change content corresponding to the change code file corresponding to the requirement number; if the change content is the corresponding change code file, generating a first requirement association rule in a first format, wherein the first format includes the file name, code branch name and requirement number; if the change content is the code line of the corresponding change code file, generating a second requirement association rule in a second format, wherein the second format includes the file name, code branch name, requirement number and line number index data; after the traversal is completed, adding the first requirement association rule and the second requirement association rule to the requirement association rule file.

[0008] Optionally, the step of parsing the requirement association rule file to obtain requirement association rules, and executing the requirement association rules according to the original code line click data list to obtain target requirement associated code line click data includes: parsing the requirement association rule file to obtain file-level association data and code line level association data; traversing the original code line click data list; if the code file currently being traversed is not included in the requirement association rule file, deleting the code line click data corresponding to the code file currently being traversed; if the code file currently being traversed is included in the file-level association data, adding all the code line click data of the code file currently being traversed to the target requirement associated code line click data; if the code file currently being traversed is included in the code line level association data, parsing the code line level association data to obtain the corresponding associated code line number, and adding the code line click data corresponding to the associated code line number in the code file currently being traversed to the target requirement associated code line click data.

[0009] Optionally, the step of parsing the code line level association data to obtain the corresponding associated code line number, and adding the code line click data corresponding to the associated code line number in the currently traversed code file to the target requirement associated code line click data includes: parsing the code line level association data to obtain the corresponding single-line code line number and code line number range; traversing the line numbers of the current code file; if the current traversed line number is equal to the single-line code line number, or the current traversed line number is within the code line number range, then adding the code line click data of the current traversed line number to the target requirement associated code line click data.

[0010] Optionally, the step of calculating the corresponding requirement test coverage rate according to the preset requirement test coverage rate formula and the target requirement-associated code line click data includes: obtaining the total number of lines of code files in the requirement-associated code file list; obtaining the number of test coverage lines with a click count greater than 0 in the target requirement-associated code line click data; calculating the requirement test coverage rate according to the preset requirement test coverage rate formula, wherein the requirement test coverage rate formula is expressed as:

[0011]

[0012] Among them, P table represents the required test coverage, N cl ick The table shows the number of lines covered by the test, N total Table represents the total number of rows.

[0013] To solve the above technical problems, the second technical solution adopted in the implementation mode of the present application is: to provide a requirement test coverage statistics device, including: a list data acquisition module, used to obtain the original code line click data list and the requirement-related code file list according to the requirement number; a change list data module, used to obtain the requirement-related change code line list according to the requirement-related code file list and the received current requirement data to be tested; an association rule conversion module, used to convert the requirement-related change code line list into a requirement association rule file through a preset first data conversion rule; an association rule execution module, used to parse the requirement association rule file to obtain the requirement association rule, and execute the requirement association rule according to the original code line click data list to obtain the target requirement-related code line click data; a coverage calculation module, used to calculate according to the preset requirement test coverage formula and the target requirement-related code line click data to obtain the corresponding requirement test coverage.

[0014] To solve the above technical problems, the third technical solution adopted in the implementation mode of the present application is: to provide an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the requirement test coverage statistics method as described above.

[0015] In order to solve the above-mentioned technical problems, the fourth technical solution adopted in the implementation mode of the present application is: providing a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by an electronic device, the electronic device executes the requirement test coverage statistics method as described above.

[0016] Different from the related art, this application not only further refines the calculation accuracy of the original test coverage to the requirement level, so that the analysis of the test process and test results can obtain more accurate data for analysis, but also filters out the code irrelevant to the requirements in the process of calculating the requirement test coverage, avoiding the interference of the code irrelevant to the requirements on the calculation of the requirement test coverage, and further improving the accuracy of the requirement test coverage statistics. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] One or more embodiments are exemplarily described by corresponding drawings, which do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and the figures in the drawings do not constitute proportional limitations unless otherwise stated.

[0018] Figure 1 It is a schematic diagram of the operating environment of the requirement test coverage statistics method provided in the embodiment of the present application.

[0019] Figure 2 It is a schematic diagram of the execution flow of a requirement test coverage statistics method provided in an embodiment of the present application.

[0020] Figure 3 It is a schematic diagram of the execution flow of obtaining the original code line click data list and the requirement-associated code file list in the requirement test coverage statistics method provided in an embodiment of the present application.

[0021] Figure 4 It is a schematic diagram of the execution flow of obtaining a list of requirement-associated code lines in the requirement test coverage statistics method provided in an embodiment of the present application.

[0022] Figure 5 It is a schematic diagram of the execution flow of obtaining a requirement association rule file in the requirement test coverage statistics method provided in an embodiment of the present application.

[0023] Figure 6 It is a schematic diagram of the execution flow of obtaining target requirement-associated code line click data in the requirement test coverage statistics method provided in an embodiment of the present application.

[0024] Figure 7 It is a schematic diagram of the processing flow after the code file is included in the code line level associated data in the requirement test coverage statistics method provided in the embodiment of the present application.

[0025] Figure 8 It is a schematic diagram of the execution flow of calculating the requirement test coverage in the requirement test coverage statistics method provided in an embodiment of the present application.

[0026] Fig. 9 It is a schematic diagram of the system structure of the requirement test coverage statistics device provided in an embodiment of the present application.

[0027] Fig.10 It is a schematic diagram of the hardware structure of an electronic device for executing the requirement test coverage statistics method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0029] It should be noted that, if there is no conflict, the various features in the embodiments of the present application can be combined with each other, all within the scope of protection of the present application. In addition, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a different order than the module division in the device schematic diagram or the order in the flow chart.

[0030] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used in this specification includes any and all combinations of one or more of the related listed items.

[0031] To facilitate understanding of this embodiment, firstly, a method for statistically analyzing the coverage of demand testing disclosed in the embodiment of this application is introduced in detail. Figure 1 , Figure 1is a schematic diagram of the operating environment of the method for statistical coverage of demand test provided in the embodiment of the present application. The execution subject of the method for statistical coverage of demand test provided in the embodiment of the present application is generally an electronic device with certain computing capabilities, such as Figure 1 The computer device in the term "computer device" may be, but is not limited to, various personal computers and laptops. The computer device may also be a server. The server may be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. It is understood that Figure 1 The number of computer devices in the example is only illustrative and can be expanded to any number according to actual needs. In some possible implementations, the requirement test coverage statistics method can be implemented by a processor calling computer-readable instructions stored in a memory.

[0032] The following uses a computer device as an example to illustrate the statistical method for demand test coverage provided by the embodiment of the present application. Please continue to refer to Figure 2 , Figure 2 This is a schematic diagram of an execution flow of a method for statistically analyzing demand test coverage provided by an embodiment of the present application, as shown in the figure, including:

[0033] S10. Obtain the original code line click data list and the requirement-associated code file list according to the requirement number.

[0034] The requirement number can be obtained from the corresponding requirement management tool. The requirement management tool is a software tool used to collect, track and manage project requirements. It can collect and organize requirements, track requirements, perform version control, manage requirement priorities, requirements relevance and team collaboration, etc. Specific requirement management tools can use Jira, Trello, etc.

[0035] As an optional implementation, please continue to refer to Figure 3 , Figure 3 This is a schematic diagram of the execution flow of obtaining the original code line click data list and the requirement-associated code file list in the requirement test coverage statistics method provided in an embodiment of the present application. As shown in the figure, the above step S10 may specifically include:

[0036] S101. Obtain the line numbers of the executed code lines in the self-test process and the transfer test process and the number of clicks of the executed code lines according to the requirement number.

[0037] S102: Obtain the changed code files corresponding to the current requirement test from the code management tool, wherein the changed code files include newly added code files and modified code files.

[0038] Among them, code management tools are tools used to manage and track code changes during the software development process. They provide a way to organize and control code so that teams can collaborate on development, track change history, resolve conflicts, and ensure code quality. They usually include the following functions: version control, branch management, code review, continuous integration and deployment, security and permission management, and document management. For example, Git (a distributed version control system) and SVN (a centralized version control system).

[0039] S20. Obtain a requirement-associated changed code line list according to the requirement-associated code file list and the received current requirement data to be tested.

[0040] As an optional implementation, please continue to refer to Figure 4 , Figure 4 This is a schematic diagram of the execution flow of obtaining a requirement-associated code line list in the requirement test coverage statistics method provided in an embodiment of the present application. As shown in the figure, the above step S20 may specifically include:

[0041] S201, traverse the change types of the changed code files in the requirement-associated code file list.

[0042] Among them, according to the historical changes of code files in the actual software development process, the types of code files can generally be divided into three categories, namely, addition (add), deletion (delete) and modification (modify).

[0043] S202: If the change type is a new addition type, add the corresponding new change code file to the requirement-associated change code line list.

[0044] S203. If the change type is a modification type, obtain the modified line number of the modified code line in the corresponding modified change code file, and add the corresponding modified change code file and the corresponding modified line number to the requirement-associated modified code line list.

[0045] As an example, when performing a test coverage statistics for a certain requirement, the following list of code lines associated with the requirement changes was obtained:

[0046]

[0047] Among them, in the process of executing the requirement test coverage statistics method provided in the embodiment of the present application, it is only necessary to pay attention to the coverage data of the two types of code files that are added (add) and modified (modify), because the coverage data of the deleted (deleted) code files is meaningless.

[0048] S30. Convert the requirement-related change code line list into a requirement-related rule file by presetting a first data conversion rule.

[0049] As an optional implementation, please continue to refer to Figure 5 , Figure 5 This is a schematic diagram of the execution flow of obtaining a requirement association rule file in the requirement test coverage statistics method provided in an embodiment of the present application. As shown in the figure, the above step S30 may specifically include:

[0050] S301, parsing the requirement-related change code line list, and traversing the change content corresponding to the change code file corresponding to the requirement number.

[0051] S302: If the changed content is a corresponding changed code file, a first requirement association rule in a first format is generated.

[0052] The first format includes the file name, code branch name and requirement number.

[0053] S303: If the changed content is a code line of a corresponding changed code file, a second requirement association rule in a second format is generated.

[0054] The second format includes the file name, code branch name, requirement number and line number index data.

[0055] S304 , after the traversal is completed, add the first requirement association rule and the second requirement association rule to the requirement association rule file.

[0056] As an example, the first requirement association rule in the first format may be as follows:

[0057] SF: file name @ code branch name @ requirement number

[0058] end_of_record

[0059] Among them, "SF:" is a specific mark, which is convenient for script identification to obtain file name, code branch name, and requirement number information; "end_of_record" is the end mark of the file content.

[0060] As another example, the second requirement association rule in the second format may be as follows:

[0061] SF: file name @ code branch name @ requirement number

[0062] CREQ_LINE:index1;

[0063] CREQ_RANGE:index2-index3;

[0064] end_of_record

[0065] Among them, the content "index1" of the "CREQ_LINE" row represents a single row number index, the content "index2-index3" of the "CREQ_RANGE" row represents a continuous row number index range "index2, index2+1, index2+2, ..., index3", and the index "index2" is smaller than "index3".

[0066] S40, parsing the requirement association rule file to obtain the requirement association rule, and executing the requirement association rule according to the original code line click data list to obtain the target requirement associated code line click data.

[0067] As an optional implementation, please continue to refer to Figure 6 , Figure 6 This is a schematic diagram of the execution flow of obtaining target requirement-associated code line click data in the requirement test coverage statistics method provided in an embodiment of the present application. As shown in the figure, the above step S40 may specifically include:

[0068] S401, parsing the requirement association rule file to obtain file-level association data and code line-level association data.

[0069] S402, traverse the original code lines and click on the data list.

[0070] S403: If the currently traversed code file is not included in the demand association rule file, the code line click data corresponding to the currently traversed code file is deleted.

[0071] S404: If the code file currently being traversed is included in the file-level associated data, add all code line click data of the code file currently traversed to the target requirement associated code line click data.

[0072] S405. If the currently traversed code file is included in the code line-level associated data, the code line-level associated data is parsed to obtain the corresponding associated code line number, and the code line click data corresponding to the associated code line number in the currently traversed code file is added to the target requirement associated code line click data.

[0073] As a preferred implementation, please continue to refer to Figure 7 , Figure 7 This is a schematic diagram of the processing flow after the code file is included in the code line level associated data in the requirement test coverage statistics method provided by the embodiment of the present application. As shown in the figure, the above step S405 may specifically include:

[0074] S4051. Parse the code line-level associated data to obtain the corresponding single-line code line number and code line number range.

[0075] S4052. Traverse the line numbers of the current code file.

[0076] S4053. If the current line number being traversed is equal to the single line code line number, or the current line number being traversed is within the code line number range, then add the code line click data of the current line number being traversed to the target requirement associated code line click data.

[0077] S50, calculating according to the preset requirement test coverage formula and the target requirement associated code line click data to obtain the corresponding requirement test coverage.

[0078] As an optional implementation, please continue to refer to Figure 8 , Figure 8 1 is a schematic diagram of the execution flow of calculating the requirement test coverage in the requirement test coverage statistics method provided in an embodiment of the present application. As shown in the figure, the above step S50 may specifically include:

[0079] S501. Obtain the total number of lines of code files in the requirement-associated code file list.

[0080] S502: Obtain the number of test coverage lines with a click count greater than 0 in the code line click data associated with the target requirement.

[0081] S503. Calculate the requirement test coverage rate according to a preset requirement test coverage rate formula, where the requirement test coverage rate formula is expressed as:

[0082]

[0083] Among them, P table represents the coverage of requirement test, N cl ick The table shows the number of test coverage lines, N total Table represents the total number of rows.

[0084] The requirement test coverage statistics method provided in the embodiment of the present application not only further refines the calculation accuracy of the original test coverage to the requirement level, so that the analysis of the test process and test results can obtain more accurate data for analysis, but also filters out the code irrelevant to the requirements in the process of calculating the requirement test coverage, thereby avoiding the interference of the code irrelevant to the requirements in the calculation of the requirement test coverage, and further improving the accuracy of the requirement test coverage statistics.

[0085] Please continue reading Fig. 9 , Fig. 9 It is a system structure diagram of the requirement test coverage statistics device provided in an embodiment of the present application, including: a list data acquisition module 91, a change list data module 92, an association rule conversion module 93, an association rule execution module 94 and a coverage calculation module 95.

[0086] The list data acquisition module 91 is used to acquire the original code line click data list and the requirement-related code file list according to the requirement number;

[0087] The change list data module 92 is used to obtain a requirement-related change code line list according to the requirement-related code file list and the received current requirement data to be tested;

[0088] The association rule conversion module 93 is used to convert the requirement association change code line list into a requirement association rule file by presetting a first data conversion rule;

[0089] The association rule execution module 94 is used to parse the requirement association rule file to obtain the requirement association rule, and execute the requirement association rule according to the original code line click data list to obtain the target requirement associated code line click data;

[0090] The coverage calculation module 95 is used to calculate the corresponding requirement test coverage according to the preset requirement test coverage formula and the target requirement associated code line click data.

[0091] As an optional implementation, the inventory data acquisition module 91 is specifically used to obtain the line numbers of the executed code lines in the self-test process and the transfer test process according to the requirement number, as well as the number of clicks information of the executed code lines; obtain the changed code files corresponding to the current requirement test from the code management tool, wherein the changed code files include newly added code files and modified code files.

[0092] As an optional implementation, the change list data module 92 is specifically used to traverse the change type of the change code file in the requirement-associated code file list; if the change type is a new type, then the corresponding new change code file is added to the requirement-associated change code line list; if the change type is a modified type, then the modified line number of the modified code line in the corresponding modified change code file is obtained, and the corresponding modified change code file and the corresponding modified line number are added to the requirement-associated change code line list.

[0093] As an optional implementation, the association rule conversion module 93 is specifically used to parse the requirement-associated change code line list, and traverse the change content corresponding to the change code file corresponding to the requirement number; if the change content is the corresponding change code file, a first requirement association rule in a first format is generated, wherein the first format includes the file name, code branch name and requirement number; if the change content is the code line of the corresponding change code file, a second requirement association rule in a second format is generated, wherein the second format includes the file name, code branch name, requirement number and line number index data; after the traversal is completed, the first requirement association rule and the second requirement association rule are added to the requirement association rule file.

[0094] As an optional implementation, the association rule execution module 94 is specifically used to parse the demand association rule file to obtain file-level association data and code line-level association data; traverse the original code line click data list; if the code file currently being traversed is not included in the demand association rule file, delete the code line click data corresponding to the code file currently being traversed; if the code file currently being traversed is included in the file-level association data, add all the code line click data of the code file currently being traversed to the target demand-associated code line click data; if the code file currently being traversed is included in the code line-level association data, parse the code line-level association data to obtain the corresponding associated code line number, and add the code line click data corresponding to the associated code line number in the code file currently being traversed to the target demand-associated code line click data.

[0095] As an optional implementation, the association rule execution module 94 is also used to parse the code line-level association data to obtain the corresponding single-line code line number and code line number range; traverse the line numbers of the current code file; if the traversed current line number is equal to the single-line code line number, or the traversed current line number is within the code line number range, then add the code line click data of the traversed current line number to the target requirement associated code line click data.

[0096] As an optional implementation, the coverage calculation module 95 is specifically used to obtain the total number of lines of code files in the requirement-associated code file list; obtain the number of test coverage lines with a click count greater than 0 in the target requirement-associated code line click data; calculate the requirement test coverage according to a preset requirement test coverage formula, wherein the requirement test coverage formula is expressed as:

[0097]

[0098] Among them, P table represents the required test coverage, N cl ickThe table shows the number of lines covered by the test, N total Table represents the total number of rows.

[0099] It should be noted that the above-mentioned requirement test coverage statistics device can execute the requirement test coverage statistics method provided in the embodiment of the present application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not fully described in the embodiment of the requirement test coverage statistics device, please refer to the requirement test coverage statistics method provided in the embodiment of the present application.

[0100] Please continue reading Fig.10 , Fig.10 1 is a schematic diagram of the hardware structure of an electronic device 1000 for executing a method for statistically analyzing coverage of a demand test provided in an embodiment of the present application. As shown in the figure, the electronic device 1000 includes:

[0101] One or more processors 1010 and memory 1020, Figure 6 A processor 1010 is taken as an example.

[0102] The processor 1010 and the memory 1020 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.

[0103] The memory 1020, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the method for statistical coverage of demand test in the embodiment of the present application. The processor 1010 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions and modules stored in the memory 1020, that is, the method for statistical coverage of demand test in the above method embodiment is implemented.

[0104] The memory 1020 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created according to the use of the demand test coverage statistics device, etc. In addition, the memory 1020 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 1020 may optionally include a memory remotely arranged relative to the processor 1010, and these remote memories may be connected to the demand test coverage statistics device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0105] The one or more modules are stored in the memory 1020, and when executed by the one or more processors 1010, the requirement test coverage statistics method in any of the above method embodiments is executed, for example, the above described Figure 2 Steps S10 to S50 of the method, Figure 3 Steps S101 to S102 of the method, Figure 4 Steps S201 to S203 of the method, Figure 5 Steps S301 to S304 of the method, Figure 6 Steps S401 to S405 of the method, Figure 7 Steps S4051 to S4053 of the method, Figure 8 Steps S501 to S503 of the method are implemented Fig. 9 The functions of modules 91-95 in.

[0106] The above-mentioned product can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided in the embodiment of the present application.

[0107] The embodiment of the present application provides a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors, such as Fig.10 A processor 1010 in the embodiment may enable the one or more processors to execute the method for statistically analyzing the coverage of the required test in any of the above method embodiments, for example, executing the above described Figure 2 Steps S10 to S50 of the method, Figure 3 Steps S101 to S102 of the method, Figure 4 Steps S201 to S203 of the method, Figure 5 Steps S301 to S304 of the method, Figure 6 Steps S401 to S405 of the method, Figure 7 Steps S4051 to S4053 of the method, Figure 8 Steps S501 to S503 of the method are implemented Fig. 9 The functions of modules 91-95 in.

[0108] The present application provides a computer program product, wherein the computer program product includes a computer program stored on a non-volatile computer-readable storage medium, wherein the computer program includes program instructions, and when the program instructions are executed by the electronic device, the electronic device is enabled to execute the requirement test coverage statistics method in any of the above method embodiments, for example, to execute the above described Figure 2 Steps S10 to S50 of the method, Figure 3 Steps S101 to S102 of the method, Figure 4 Steps S201 to S203 of the method, Figure 5 Steps S301 to S304 of the method, Figure 6 Steps S401 to S405 of the method, Figure 7 Steps S4051 to S4053 of the method, Figure 8 Steps S501 to S503 of the method are implemented Fig. 9 The functions of modules 91-95 in.

[0109] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0110] Through the description of the above implementation methods, ordinary technicians in this field can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. Ordinary technicians in this field can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0111] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Under the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes in different aspects of the present application as described above, which are not provided in detail for the sake of simplicity. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for statistically analyzing demand test coverage, characterized in that: include: Obtain the original code line click data list and requirement-related code file list based on the requirement number; Obtaining a requirement-associated changed code line list according to the requirement-associated code file list and the received current requirement data to be tested; By presetting a first data conversion rule, the requirement-related change code line list is converted into a requirement-related rule file; Parsing the requirement association rule file to obtain the requirement association rule, and executing the requirement association rule according to the original code line click data list to obtain the target requirement association code line click data; The corresponding requirement test coverage is calculated based on the preset requirement test coverage formula and the target requirement associated code line click data.

2. The method for statistically analyzing demand test coverage according to claim 1 is characterized in that: The step of obtaining the original code line click data list and the requirement-associated code file list according to the requirement number includes: Obtaining the line numbers of the executed code lines in the self-test process and the transfer test process and the number of clicks of the executed code lines according to the requirement number; Obtain the changed code files corresponding to the current requirement test from the code management tool, wherein the changed code files include newly added code files and modified code files.

3. The method for statistically analyzing demand test coverage according to claim 2 is characterized in that: The step of obtaining a requirement-associated changed code line list according to the requirement-associated code file list and the received current requirement data to be tested comprises: Traversing the change types of the changed code files in the requirement-associated code file list; If the change type is a new addition type, then add the corresponding new change code file to the requirement-associated change code line list; If the change type is a modification type, the modified line number of the modified code line in the corresponding modified change code file is obtained, and the corresponding modified change code file and the corresponding modified line number are added to the requirement-associated change code line list.

4. The method for statistically analyzing demand test coverage according to claim 1 is characterized in that: The step of converting the requirement-related change code line list into a requirement-related rule file by presetting a first data conversion rule comprises: Parse the requirement-related change code line list, and traverse the change content corresponding to the change code file corresponding to the requirement number; If the changed content is a corresponding changed code file, generating a first requirement association rule in a first format, wherein the first format includes a file name, a code branch name, and a requirement number; If the changed content is a code line of a corresponding changed code file, generating a second requirement association rule in a second format, wherein the second format includes a file name, a code branch name, a requirement number, and a line number index data; After the traversal is completed, the first requirement association rule and the second requirement association rule are added to the requirement association rule file.

5. The method for statistically analyzing demand test coverage according to claim 1 is characterized in that: The step of parsing the requirement association rule file to obtain the requirement association rule, and executing the requirement association rule according to the original code line click data list to obtain the target requirement associated code line click data includes: Parsing the requirement association rule file to obtain file-level association data and code line-level association data; Traverse the original code line click data list; If the currently traversed code file is not included in the demand association rule file, then deleting the code line click data corresponding to the currently traversed code file; If the code file currently being traversed is included in the file-level associated data, then all code line click data of the code file currently being traversed are added to the target requirement associated code line click data; If the currently traversed code file is included in the code line level associated data, the code line level associated data is parsed to obtain the corresponding associated code line number, and the code line click data corresponding to the associated code line number in the currently traversed code file is added to the target requirement associated code line click data.

6. The method for statistically analyzing demand test coverage according to claim 5 is characterized in that: The step of parsing the code line-level associated data to obtain the corresponding associated code line number, and adding the code line click data corresponding to the associated code line number in the currently traversed code file to the target requirement associated code line click data includes: Parsing the code line level associated data to obtain the corresponding single line code number and code line number range; Traverse the line number of the current code file; If the current line number being traversed is equal to the single line code line number, or the current line number being traversed is within the code line number range, the code line click data of the current line number being traversed is added to the target requirement associated code line click data.

7. The method for statistically analyzing demand test coverage according to claim 1 is characterized in that: The step of calculating the corresponding requirement test coverage rate according to the preset requirement test coverage rate formula and the target requirement associated code line click data comprises: Get the total number of lines in the code files in the list of code files associated with the requirement; Obtain the number of test coverage lines with a click count greater than 0 in the code line click data associated with the target requirement; The requirement test coverage is calculated according to a preset requirement test coverage formula, wherein the requirement test coverage formula is expressed as: Among them, P table represents the required test coverage, N click The table shows the number of lines covered by the test, N total Table represents the total number of rows.

8. A statistical device for demand test coverage, characterized in that: include: A list data acquisition module is used to obtain the original code line click data list and the requirement-related code file list according to the requirement number; A change list data module, used to obtain a requirement-related change code line list according to the requirement-related code file list and the received current requirement data to be tested; An association rule conversion module, used to convert the requirement association change code line list into a requirement association rule file by presetting a first data conversion rule; An association rule execution module is used to parse the requirement association rule file to obtain the requirement association rule, and execute the requirement association rule according to the original code line click data list to obtain the target requirement associated code line click data; The coverage calculation module is used to calculate the corresponding requirement test coverage based on the preset requirement test coverage formula and the code line click data associated with the target requirement.

9. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the requirement test coverage statistics method described in any one of claims 1-7.

10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by an electronic device, the electronic device executes the requirement test coverage statistics method described in any one of claims 1-7.