Code coverage rate file superposition method and system

By generating a full coverage file initially and then generating incremental coverage files and overlaying them, the problem of long processing time and large storage space required for code coverage file overlay is solved, achieving more efficient file processing and storage management.

CN121880167APending Publication Date: 2026-04-17CHINA EVERBRIGHT BANK
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA EVERBRIGHT BANK
Filing Date
2025-11-24
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

In existing technologies, the process of overlaying code coverage files is time-consuming and consumes a lot of storage space, especially when the amount of code is large, which affects server performance and storage efficiency.

Method used

The system generates a full coverage file initially, and then generates an incremental coverage file for each subsequent update. The full and incremental files are then overlaid to reduce line-by-line merging operations and store only the incremental data.

Benefits of technology

It reduces the time and storage space required for the code coverage file overlay process, and improves processing efficiency and storage utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121880167A_ABST
    Figure CN121880167A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a code coverage rate file superposition method and system, and relates to the technical field of software test.The method comprises the steps that an initial code version is tested for the first time to generate a full coverage rate file; testing the new code version updated each time to generate an incremental coverage rate file; wherein the byte quantity of the incremental coverage rate file is smaller than the byte quantity of the full coverage rate file; and carrying out file superposition on the full coverage rate file and the incremental coverage rate file generated by each update test to generate a complete coverage rate file. Through the embodiment of the invention, the problems of long time consumption and large occupied storage space in the superposition process of the code coverage rate file in the related technology are at least solved, and the effect of reducing the time consumption and the occupied storage space in the superposition process of the code coverage rate file is further realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of software testing, and more specifically, to a method and system for overlaying code coverage files. Background Technology

[0002] With the ongoing digital transformation of the banking industry, software quality has become fundamental to ensuring its smooth implementation. Software testing, as a crucial part of the software development process, plays an indispensable role in guaranteeing high-quality software. Code coverage in software testing refers to the proportion or extent to which code is executed during testing. By analyzing code coverage, we can statistically determine code execution status and thus measure the overall quality of software testing.

[0003] Currently, most open-source code coverage tools store the collected code coverage data in various formats of code coverage files. These files contain information about whether each line of code has been covered by tests. From start to finish, due to code defect fixing, the code version used in testing often changes continuously, and different code versions generate independent full code coverage files during the testing process. To view the overall code coverage during the testing process, it is necessary to overlay the code coverage files from different versions.

[0004] In traditional technical solutions, code coverage files are overlaid using full data overlay, which means merging line coverage information from full code coverage files generated on different code versions line by line. The final coverage file after merging stores complete line coverage information from the start to the end of the test.

[0005] However, firstly, since the process of overlaying coverage files often requires line-by-line execution, when the codebase is large (e.g., over 100,000 lines), a single overlay can take tens of minutes or even over an hour, resulting in prolonged CPU resource consumption and severely impacting the server's multitasking capabilities. Secondly, because code coverage files store full coverage data, multiple coverage files for different code versions can consume significant storage space when the codebase is large. Regularly cleaning up coverage files would result in the loss of historical data, hindering users' ability to trace past test results. Summary of the Invention

[0006] This invention provides a method and system for overlaying code coverage files, which at least solves the problems of long time consumption and large storage space occupation in the overlay process of code coverage files in related technologies.

[0007] According to an embodiment of the present invention, a method for overlaying code coverage files is provided, comprising: performing an initial test on an initial code version to generate a full coverage file;

[0008] Each updated version of the code is tested to generate an incremental coverage file; wherein the size of the incremental coverage file is smaller than the size of the full coverage file.

[0009] The full coverage file and the incremental coverage file generated in each update test are overlaid to generate a complete coverage file.

[0010] In one implementation, testing is performed on each updated version of the code to generate an incremental coverage file, including:

[0011] Obtain the first code class file that has been tested and covered during the testing process; wherein, the size of the first code class file is smaller than the size of the initial code version;

[0012] The new code version corresponding to the test process is compared with the initial code version to obtain a second code class file; wherein, the second code class file is a code class file that is added and / or modified in the new code version compared with the initial code version;

[0013] The incremental coverage file is obtained based on the first code class file and the second code class file.

[0014] In one implementation, an initial test is performed on the initial code version to generate a full coverage file, including:

[0015] The third code class file is obtained based on the first command of the code coverage statistics tool; wherein, the third code class file contains the first code class that has been covered by the test in the first test;

[0016] The full coverage file is obtained based on the second command of the code coverage statistics tool; wherein, the second command takes the third code class file and the fourth code class file as execution parameters, the fourth code class file is generated after the full code of the initial code version is compiled, and the size of the fourth code class file is greater than the size of the first code class file.

[0017] In one implementation, obtaining the first code class file that has been covered by tests during the testing process includes:

[0018] The fifth type of code class file is obtained based on the first command of the code coverage statistics tool; wherein, the fifth type of code class file contains the second type of code class that has been covered by the test in the first test, and the size of the second type of code class is smaller than the size of the first type of code class that has been covered by the test in the first test;

[0019] The third command of the code coverage statistics tool is used to parse the fifth code class file to determine the second code class in the fifth code class file, so as to obtain the first code class file.

[0020] In one implementation, the new code version corresponding to the testing process is compared with the initial code version to obtain a second code class file, including:

[0021] Obtain the first code identifier after the initial code version is compiled;

[0022] Obtain the second code identifier after the new code version is compiled;

[0023] The second code identifier is compared with the first code identifier to obtain a second code class file based on the comparison result.

[0024] In one implementation, obtaining the incremental coverage file based on the first code class file and the second code class file includes:

[0025] The incremental coverage file is obtained based on the second command of the code coverage statistics tool; wherein the second command uses the first code class file and the second code class file as execution parameters.

[0026] In one implementation, the method further includes:

[0027] The third command of the code coverage statistics tool is used to parse the third code class file to determine the first code class that has been covered by the first test in the third code class file.

[0028] According to another embodiment of the present invention, a code coverage file overlay system is provided, comprising:

[0029] The first generation module is used to perform the first test on the initial code version to generate a full coverage file;

[0030] The second generation module is used to test the new code version after each update to generate an incremental coverage file; wherein the size of the incremental coverage file is smaller than the size of the full coverage file.

[0031] The overlay module is used to overlay the full coverage file and the incremental coverage file generated by each update test to generate a complete coverage file.

[0032] According to yet another embodiment of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.

[0033] According to yet another embodiment of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0034] According to yet another embodiment of the present invention, a computer program product is also provided, including computer instructions that, when executed by a processor, implement the steps in any of the above method embodiments.

[0035] In one embodiment of the present invention, addressing the issues of time-consuming and storage-intensive full data overlay methods in related technologies, a "first full overlay + subsequent incremental overlay" file generation and overlay technique is adopted. Specifically, an initial test is performed on the initial code version to generate a full coverage file to lay the data foundation. After each subsequent update to a new code version, only smaller incremental coverage files are generated. The full coverage file is then overlaid with the corresponding incremental coverage files for each update to generate a complete coverage file. This method avoids the redundant operation of merging large amounts of duplicate data line by line in traditional full overlay, reducing overlay time by decreasing the amount of data processing during the overlay process, and reducing storage space usage because only incremental data is stored subsequently instead of duplicate full data. Therefore, it at least solves the problems of time-consuming and storage-intensive code coverage file overlay processes in related technologies, thereby achieving the effect of reducing the time consumption and storage space usage of code coverage file overlay processes. Attached Figure Description

[0036] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:

[0037] Figure 1 This is a hardware structure block diagram of the code coverage file overlay method according to an embodiment of the present invention;

[0038] Figure 2 This is a flowchart of a code coverage file overlay method according to an embodiment of the present invention;

[0039] Figure 3 This is a flowchart of a method for performing an initial test on an initial code version to generate a full coverage file according to an embodiment of the present invention;

[0040] Figure 4 This is a flowchart of a method for testing each updated version of the code to generate an incremental coverage file, according to an embodiment of the present invention.

[0041] Figure 5 This is a flowchart of a method for obtaining a first code class file that has been tested and covered during the testing process, according to an embodiment of the present invention;

[0042] Figure 6 This is a flowchart of a method according to an embodiment of the present invention for comparing a new code version corresponding to a test process with an initial code version to obtain a second code class file;

[0043] Figure 7 This is a structural block diagram of a code coverage file overlay system according to an embodiment of the present invention. Detailed Implementation

[0044] The present invention will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the embodiments of the present invention can be combined with each other.

[0045] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0046] The methods and embodiments provided in this invention can be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking execution on a computer terminal as an example... Figure 1 This is a hardware structure block diagram of the code coverage file overlay method according to an embodiment of the present invention, such as... Figure 1 As shown, a hardware board may include one or more ( Figure 1 Only one is shown in the diagram. A processor 12 (which may include, but is not limited to, a microprocessor MCU or programmable logic device, etc.) and a memory 14 for storing data are also shown. The computer terminal may further include a transmission device 16 for communication functions and an input / output device 18. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0047] The memory 14 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the code coverage file overlay method in this embodiment of the invention. The processor 12 executes various functional applications and implements the methods described above by running the computer programs stored in the memory 14. The memory 14 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 14 may further include memory remotely located relative to the processor 12, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0048] The transmission device 16 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a telecommunications provider. In one example, the transmission device 16 includes a Network Interface Controller (NIC), which can connect to other network devices via a gateway to communicate with the Internet. In another example, the transmission device 16 may be a Radio Frequency (RF) module used for wireless communication with the Internet.

[0049] This invention provides a method for overlaying code coverage files. Figure 2 This is a flowchart of a code coverage file overlay method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes:

[0050] Step S201: Perform the first test on the initial code version to generate a full coverage file;

[0051] In one exemplary implementation, for example, the first test can be performed on the code version of the first test (e.g., version V1) to generate a full coverage file using some open-source code coverage statistics tool. This open-source code coverage statistics tool could be jacoco.

[0052] Step S202: Test the new code version after each update to generate an incremental coverage file; wherein the size of the incremental coverage file is smaller than the size of the full coverage file.

[0053] In one exemplary implementation, for example, testing can be performed on each updated version of the code (e.g., V2, V3, ..., VN, etc.) to generate a full coverage file using some open-source code coverage statistics tools.

[0054] Step S203: Overlay the full coverage file and the incremental coverage file generated by each update test to generate a complete coverage file.

[0055] In one exemplary implementation, the full coverage file generated in step S201 is overlaid with all incremental coverage files generated in step S202 for each updated version. For example, the full coverage file for version V1 is merged sequentially with the incremental coverage files for versions V2, V3, ..., VN. Therefore, coverage information for all code versions from the start to the end of the test is integrated, preserving the complete data of the initial version while incorporating the incremental changes of each updated version, ensuring that the overall code coverage of the entire testing process is presented.

[0056] Through steps S201 to S203 above, to address the issues of time-consuming and storage-intensive full data overlay methods in related technologies, a "first full overlay + subsequent incremental overlay" file generation and overlay technique is adopted. Specifically, a full coverage file is generated for the initial code version to lay the data foundation. After each subsequent update to a new code version, only smaller incremental coverage files are generated. The full coverage file is then overlaid with the corresponding incremental coverage files for each update to generate a complete coverage file. This method avoids the redundant operation of merging large amounts of duplicate data line by line in traditional full overlay, reducing overlay time by decreasing the amount of data processing during the overlay process, and reducing storage space usage because only incremental data is stored instead of duplicate full data. Therefore, this method at least solves the problems of time-consuming and storage-intensive code coverage file overlay processes in related technologies, thereby reducing both the time consumption and storage space usage of the code coverage file overlay process.

[0057] Figure 3 This is a flowchart of a method for performing an initial test on an initial code version to generate a full coverage file, according to an embodiment of the present invention. Figure 3 As shown, in one implementation, an initial test is performed on the initial code version to generate a full coverage file, including:

[0058] Step S301: Obtain the third code class file based on the first command of the code coverage statistics tool; wherein, the third code class file contains the first code class that has been covered by the test in the first test;

[0059] In one exemplary implementation, for example, an exec file containing Java classes that have been tested and covered can be obtained using jacoco's dump command (first command).

[0060] Step S302: Obtain the full coverage file based on the second command of the code coverage statistics tool; wherein, the second command takes the third code class file and the fourth code class file as execution parameters, the fourth code class file is generated after the full code of the initial code version is compiled, and the size of the fourth code class file is greater than the size of the first code class file.

[0061] In one exemplary implementation, for example, the report command (second command) can be executed by jacoco with the exec file obtained in step S301 and the full .class file compiled from the initial code version as parameters to generate a full coverage file.

[0062] Through the above steps S301 to S302, the coverage information of all Java classes in the initial code version is completely preserved, including both the classes that are tested and covered, as well as the classes that are not covered. This provides complete total lines of code and basic data for subsequent overlay, avoiding coverage distortion due to missing total lines of code during subsequent statistics.

[0063] In one implementation, the method further includes: parsing a third code class file based on a third command of a code coverage statistics tool to determine the first code class in the third code class file that has been covered by the first test.

[0064] In one exemplary implementation, for example, the exec file obtained by the dump command can be parsed using the jacoco execinfo command (the third command) to obtain a set of Java class files that have been tested and covered.

[0065] Figure 4 This is a flowchart of a method for testing each updated code version to generate an incremental coverage file, according to an embodiment of the present invention. Figure 4 As shown, in one implementation, testing is performed on the new code version after each update to generate an incremental coverage file, including:

[0066] Step S401: Obtain the first code class file that has been tested and covered during the testing process; wherein, the size of the first code class file is smaller than the size of the initial code version.

[0067] In one exemplary implementation, for example, a first code class file that has been tested and covered can be extracted from the testing process of a new code version based on relevant commands from a code coverage statistics tool. This first code class file contains only the code classes that have been executed during testing, and its size is much smaller than the total size of the initial code version. Therefore, effective coverage data can be accurately filtered out, redundant code class information that has not been tested can be eliminated, and the data size for subsequent incremental files can be reduced, avoiding the storage and processing burden caused by full data.

[0068] Step S402: Compare the new code version corresponding to the test process with the initial code version to obtain the second code class file; wherein, the second code class file is the code class file that is added and / or modified in the new code version compared with the initial code version;

[0069] In one exemplary implementation, for example, the new code version being tested is specifically compared with the initial code version, focusing on the additions and modifications to code classes. Specifically, differences can be identified by comparing the compiled code identifiers of the two versions, resulting in a second code class file containing the added and / or modified code classes. Therefore, the core changes in the new code version can be accurately captured, ensuring that the incremental file fully covers code updates during version iterations and avoiding incomplete coverage statistics due to missed changes.

[0070] Step S403: Obtain the incremental coverage file based on the first code class file and the second code class file.

[0071] In one exemplary implementation, for example, the covered first code class file obtained in step S401 and the newly added / modified second code class file obtained in step S402 are used as core data, and integrated to generate an incremental coverage file using commands from a code coverage statistics tool (such as the report command in Jacoco). Therefore, the generated incremental file can contain only key coverage data and version change data, with a byte size much smaller than the full coverage file, ensuring the integrity of the incremental data while further compressing the file size.

[0072] Through steps S401 to S403, the already covered valid data is first filtered, then the change data of the new code version is captured, and finally the incremental files are integrated to generate an incremental file. This process accurately retains the core coverage information required for testing the new code version, while discarding redundant data that is not covered or unchanged in the full file. Ultimately, it achieves lightweight generation of incremental coverage files, reducing the amount of data processing and storage usage for subsequent file overlay stages.

[0073] Figure 5This is a flowchart of a method for obtaining a first code class file that has been tested and covered during the testing process, according to an embodiment of the present invention. Figure 5 As shown, in one implementation, obtaining the first code class file that has been covered by tests during the testing process includes:

[0074] Step S501: Obtain the fifth type of code class file based on the first command of the code coverage statistics tool; wherein, the fifth type of code class file contains the second type of code class that has been tested and covered in the first test, and the size of the second type of code class is smaller than the size of the first type of code class that has been tested and covered in the first test;

[0075] In one exemplary implementation, for example, the files of Java classes that have been covered by tests during the testing process can be obtained using jacoco's dump command (the first command).

[0076] Step S502: Based on the third command of the code coverage statistics tool, the fifth code class file is parsed to determine the second code class in the fifth code class file, so as to obtain the first code class file.

[0077] In one exemplary implementation, for example, the fifth code class file can be parsed using the jacoco execinfo command (the third command) to obtain the target file (determining the fifth code class file containing the second code class).

[0078] Through steps S501 to S502, the first command of the code coverage statistics tool (such as the dump command of jacoco) is used to obtain the fifth type of code class file containing the second code class that has been tested and covered. Then, the third command of the tool (such as the execinfo command of jacoco) is used to parse the fifth type of code class file, accurately filter out the second code class and form the first code class file. This ensures that the obtained first code class file contains only the code class information that is effectively covered, eliminates redundant data, and its byte size is smaller than that of the initial code version. It also provides accurate and concise core data support for the generation of subsequent incremental coverage files, further ensuring the lightweight nature of incremental files and the efficiency of the overlay process.

[0079] Figure 6 This is a flowchart illustrating a method for comparing a new code version corresponding to a testing process with an initial code version to obtain a second code class file, according to an embodiment of the present invention. Figure 6 As shown, in one implementation, the new code version corresponding to the testing process is compared with the initial code version to obtain a second code class file, including:

[0080] Step S601: Obtain the first code identifier after the initial code version is compiled;

[0081] In one exemplary implementation, for example, for an initial code version used as a baseline (e.g., version V1), after its code has been compiled, a first code identifier, uniquely identifying the code class, is extracted from the compilation artifacts. Specifically, the classId (class identifier) ​​contained in the .class file generated after compiling the initial version is read using a code coverage statistics tool (such as Jacoco). This identifier is unique and can accurately correspond to each code class in the initial version. Therefore, a stable and unique benchmark is provided for subsequent version comparisons, ensuring that the comparison of changes in subsequent new code versions has a clear "baseline" and avoiding differences in identification errors caused by inconsistent reference standards.

[0082] Step S602: Obtain the second code identifier after the new code version has been compiled;

[0083] In one exemplary implementation, for example, for each updated code version (such as V2, V3, ..., VN, etc.), after compilation, the same extraction logic and tools as in step S601 are used to extract the second code identifier (such as class Id) corresponding to each code class from the compilation artifacts (such as .class files) of the new code version. Therefore, the "homogeneity" and "comparability" of the new code version identifier and the initial version identifier are guaranteed, ensuring consistency in data format and identification dimensions. This lays a data foundation for subsequent accurate comparison of differences and avoids invalid comparisons caused by different identifier extraction methods.

[0084] Step S603: Compare the second code identifier with the first code identifier to obtain the second code class file based on the comparison result.

[0085] In one exemplary implementation, for example, the second code identifier of the new code version obtained in step S602 is compared one by one with the first code identifier of the initial version obtained in step S601. Identifiers that exist in the second code identifier but not in the first code identifier (corresponding to newly added code classes), and identifiers that correspond to the first code identifier but whose content has changed (corresponding to modified code classes), are then identified based on these differences. This results in a second code class file containing newly added code classes, or containing modified code classes, or containing both. Therefore, by comparing identifiers, the core changes of the new code version compared to the initial version are accurately and efficiently identified, avoiding the redundant operation of comparing the entire code line by line. This ensures that no newly added or modified code classes are missed, providing accurate content for the subsequent inclusion of version change data in the incremental coverage file.

[0086] Through steps S601 to S603, using the unique compiled code identifier as the core comparison carrier, the comparability of the baseline and new version data is ensured. Furthermore, by replacing full code comparison with identifier comparison, the time spent on difference identification is significantly reduced. Simultaneously, the newly added and modified code classes are accurately located and a second code class file is created, ensuring that subsequent incremental coverage files fully cover version changes. This avoids incomplete coverage statistics due to missed changes, ultimately providing crucial "change data support" for the lightweight and accurate generation of incremental coverage files.

[0087] In one implementation, obtaining an incremental coverage file based on a first code class file and a second code class file includes: obtaining the incremental coverage file based on a second command of a code coverage statistics tool; wherein the second command uses the first code class file and the second code class file as execution parameters.

[0088] In one exemplary implementation, for example, the first code class file and the second code class file can be executed using the report command (second command) of the code coverage statistics tool jacoco to obtain an incremental coverage file.

[0089] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by adding necessary general-purpose hardware platforms with the aid of software. Of course, they can also be implemented using hardware, but in many cases, the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0090] This invention also provides a code coverage file overlay system for implementing the above embodiments and preferred embodiments; details already described will not be repeated. The term "module" as used below refers to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0091] Figure 7 This is a structural block diagram of a code coverage file overlay system according to an embodiment of the present invention, such as... Figure 7 As shown, the system includes:

[0092] The first generation module 71 is used to perform the first test on the initial code version to generate a full coverage file;

[0093] The second generation module 72 is used to test the new code version after each update to generate an incremental coverage file; wherein the size of the incremental coverage file is smaller than the size of the full coverage file.

[0094] The overlay module 73 is used to overlay the full coverage file and the incremental coverage file generated by each update test to generate a complete coverage file.

[0095] By adopting the above technical solution, the first generation module 71 generates a full coverage file for the initial code version, providing basic data for the overall coverage information; the second generation module 72 generates only a smaller incremental coverage file for each updated code version, avoiding the storage space redundancy caused by generating a full file for each update in related technologies, thus reducing storage consumption; the overlay module 73 overlays the full coverage file with each incremental coverage file, which significantly reduces the amount of data to be processed during the overlay process compared to the traditional method of merging full files line by line, thereby reducing the overlay time. The first generation module 71, the second generation module 72, and the overlay module 73 work together to reduce storage requirements through incremental files and shorten processing time by reducing the amount of overlay data. Therefore, this solves at least the problems of long overlay time and large storage space consumption in related technologies, thereby achieving the effect of reducing the time consumption and storage space consumption of the code coverage file overlay process.

[0096] In one implementation, the first generation module 71 includes:

[0097] The first generation submodule is used to obtain the third code class file based on the first command of the code coverage statistics tool; wherein, the third code class file contains the first code class that has been covered by the test in the first test;

[0098] The first generation submodule two is used to obtain a full coverage file based on the second command of the code coverage statistics tool; wherein, the second command takes a third code class file and a fourth code class file as execution parameters, the fourth code class file is generated after the full code of the initial code version is compiled, and the size of the fourth code class file is greater than the size of the first code class file.

[0099] In one implementation, the first generation submodule is further configured to: parse the third code class file based on the third command of the code coverage statistics tool, so as to determine the first code class in the third code class file that has been covered by the first test.

[0100] In one implementation, the second generation module 72 includes:

[0101] The second generation submodule one is used to obtain the first code class file that has been covered by the test during the test process; wherein, the size of the first code class file is smaller than the size of the initial code version;

[0102] The comparison module is used to compare the new code version corresponding to the test process with the initial code version to obtain a second code class file; wherein, the second code class file is the code class file that is added and / or modified in the new code version compared to the initial code version;

[0103] The second generation submodule is used to obtain the incremental coverage file based on the first code class file and the second code class file.

[0104] In one implementation, the second generation submodule one includes:

[0105] The first processing unit is used to obtain a fifth type of code class file based on the first command of the code coverage statistics tool; wherein, the fifth type of code class file contains a second type of code class that has been covered by the test in the first test, and the size of the second type of code class is smaller than the size of the first type of code class that has been covered by the test in the first test;

[0106] The second processing unit is used to parse the fifth code class file based on the third command of the code coverage statistics tool, so as to determine the second code class in the fifth code class file and obtain the first code class file.

[0107] In one implementation, the comparison module includes:

[0108] The first acquisition unit is used to acquire the first code identifier after the initial code version is compiled.

[0109] The second acquisition unit is used to acquire the second code identifier after the new code version has been compiled.

[0110] The comparison unit is used to compare the second code identifier with the first code identifier to obtain the second code class file based on the comparison result.

[0111] In one implementation, the second generation submodule is further configured to: obtain an incremental coverage file based on a second command of the code coverage statistics tool; wherein the second command uses the first code class file and the second code class file as execution parameters.

[0112] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.

[0113] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.

[0114] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0115] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.

[0116] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0117] Embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.

[0118] Specific examples in the embodiments of the present invention can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.

[0119] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.

[0120] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for overlaying code coverage files, characterized in that, include: Perform an initial test on the initial code version to generate a full coverage file; Each updated version of the code is tested to generate an incremental coverage file; wherein the size of the incremental coverage file is smaller than the size of the full coverage file. The full coverage file and the incremental coverage file generated in each update test are overlaid to generate a complete coverage file.

2. The method according to claim 1, characterized in that, Test each updated version of the code to generate an incremental coverage file, including: Obtain the first code class file that has been tested and covered during the testing process; wherein, the size of the first code class file is smaller than the size of the initial code version; The new code version corresponding to the test process is compared with the initial code version to obtain a second code class file; wherein, the second code class file is a code class file that is added and / or modified in the new code version compared with the initial code version; The incremental coverage file is obtained based on the first code class file and the second code class file.

3. The method according to claim 1, characterized in that, Perform an initial test on the initial code version to generate a full coverage file, including: The third code class file is obtained based on the first command of the code coverage statistics tool; wherein, the third code class file contains the first code class that has been covered by the test in the first test; The full coverage file is obtained based on the second command of the code coverage statistics tool; wherein, the second command takes the third code class file and the fourth code class file as execution parameters, the fourth code class file is generated after the full code of the initial code version is compiled, and the size of the fourth code class file is greater than the size of the first code class file.

4. The method according to claim 2, characterized in that, Obtain the first code class file that has been covered by tests during the testing process, including: The fifth type of code class file is obtained based on the first command of the code coverage statistics tool; wherein, the fifth type of code class file contains the second type of code class that has been covered by the test in the first test, and the size of the second type of code class is smaller than the size of the first type of code class that has been covered by the test in the first test; The third command of the code coverage statistics tool is used to parse the fifth code class file to determine the second code class in the fifth code class file, so as to obtain the first code class file.

5. The method according to claim 4, characterized in that, The new code version corresponding to the test process is compared with the initial code version to obtain a second code class file, including: Obtain the first code identifier after the initial code version is compiled; Obtain the second code identifier after the new code version is compiled; The second code identifier is compared with the first code identifier to obtain a second code class file based on the comparison result.

6. The method according to claim 5, characterized in that, The incremental coverage file is obtained based on the first code class file and the second code class file, including: The incremental coverage file is obtained based on the second command of the code coverage statistics tool; wherein the second command uses the first code class file and the second code class file as execution parameters.

7. The method according to claim 3, characterized in that, Also includes: The third command of the code coverage statistics tool is used to parse the third code class file to determine the first code class that has been covered by the first test in the third code class file.

8. A code coverage file overlay system, characterized in that, include: The first generation module is used to perform the first test on the initial code version to generate a full coverage file; The second generation module is used to test the new code version after each update to generate an incremental coverage file; wherein the size of the incremental coverage file is smaller than the size of the full coverage file. The overlay module is used to overlay the full coverage file and the incremental coverage file generated by each update test to generate a complete coverage file.

9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is executed by a processor to perform the method described in any one of claims 1 to 7.

10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method of any one of claims 1 to 7.

11. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the method of any one of claims 1 to 7.