Method and system for reducing load of server performing code coverage analysis

By obtaining and decompressing archive files from the virtual machine environment, obtaining intermediate code and source code files, and generating code coverage analysis reports, the problems of high server load and complex compiled scripts in the existing technology are solved, and fast and efficient code coverage analysis is achieved.

CN119645475APending Publication Date: 2025-03-18BMW (NANJING) INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311188711.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-14
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

In the prior art, when executing code coverage analysis, the server load is too high, the compilation script configuration is complex, and multiple projects are compiled simultaneously, resulting in downtime.

Method used

By obtaining the packaged archive file from the virtual machine environment where the target application is running, decompressing it to obtain the directory structure, obtaining intermediate code files and parsing metadata files to determine the source code files, and using the code coverage analysis tool to generate reports to avoid server-side compilation.

Benefits of technology

It reduces the server load and the analysis time, shortens from about 10 minutes to within ten seconds, avoiding the problem of complex configuration of compiled scripts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645475A_ABST
    Figure CN119645475A_ABST
Patent Text Reader

Abstract

The invention relates to a method and system for reducing the load of a server performing code coverage analysis. The method for reducing the load of the server executing code coverage rate analysis comprises the steps that the server obtains an archived file corresponding to a target application from a virtual machine environment running the target application, and the archived file is packaged in a specific packaging mode; decompressing the archived file to obtain a directory structure comprising a plurality of folders; obtaining at least one intermediate code file of the target application from a first specific folder in the plurality of folders; analyzing a metadata file in a second specific folder in the plurality of folders to determine at least one source code file corresponding to the target application; and generating a code coverage analysis report based at least in part on the at least one intermediate code file and the at least one source code file by utilizing a tool for executing code coverage analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of software testing, and more particularly, to a method, a computer system, and a computer-readable storage medium for reducing the load of a server that performs code coverage analysis. Background Art

[0002] Code coverage analysis is a software testing method that measures the amount of code that is actually run during testing. This analysis can help identify blind areas of test coverage, thereby determining areas where more test cases need to be added. Code coverage analysis can provide detailed information about the program code covered by test cases. If a part of the code is not covered by the test, then this may mean that there are potential errors or undiscovered defects there. Therefore, through code coverage analysis, we can design and execute test cases more effectively, thereby improving the quality and reliability of the software.

[0003] JaCoCo is an open source code coverage analysis tool for measuring code coverage of Java applications. It is based on the Java Virtual Machine (JVM), so it can be integrated with various build and development tools, including Ant, Maven, and Eclipse. JaCoCo provides a variety of features, including coverage analysis of instructions, branches, lines, methods, types, and cyclomatic complexity.

[0004] In the implementation of the Java code coverage analysis solution based on JaCoCo technology, it is necessary to obtain the class file of the target application (i.e., the intermediate code file with the suffix ".class"). The class file is usually generated by pulling the source code and then compiling it. Maven or Gradle can be used for compilation, for example. Depending on the organizational structure of the project or the actual situation of the project, there may be some special cases where specific compilation scripts need to be configured. As a general code coverage analysis server, it is very costly to configure compilation scripts for different software projects separately. In addition, later project upgrades may cause changes in the compilation script, which will lead to the problem of untimely synchronization. In addition, since the code coverage analysis server serves multiple users at the same time, compiling multiple projects at the same time will cause the server to be overloaded and even cause downtime. Therefore, there are many disadvantages in obtaining the class files of the target application in the traditional way. Summary of the invention

[0005] The present disclosure is directed to providing a method, a computer system, and a computer-readable medium for reducing the load of a server that performs code coverage analysis.

[0006] According to some embodiments of the present disclosure, a method for reducing the load of a server that performs code coverage analysis is provided, comprising: obtaining, by the server, an archive file corresponding to a target application from a virtual machine environment that runs the target application, wherein the archive file is packaged in a specific packaging manner; decompressing the archive file to obtain a directory structure including multiple folders; obtaining at least one intermediate code file of the target application from a first specific folder among the multiple folders; parsing a metadata file in a second specific folder among the multiple folders to determine at least one source code file corresponding to the target application; and generating a code coverage analysis report based at least in part on the at least one intermediate code file and the at least one source code file using a tool that performs code coverage analysis.

[0007] According to some embodiments of the present disclosure, the virtual machine environment is a Java virtual machine (JVM) environment, the archive file is a JAR file, the intermediate code file is a class file, and the source code file is a Java source code file.

[0008] According to some embodiments of the present disclosure, obtaining the archive file corresponding to the target application includes the virtual machine environment streaming the archive file to the server in response to a request from the server.

[0009] According to some embodiments of the present disclosure, the method further includes, before acquiring the archive file, configuring the domain name or IP address of the target application on the server side so as to be able to access the target application.

[0010] According to some embodiments of the present disclosure, the target application is bound to a plug-in, and the plug-in can obtain the current location of the target application and can stream the archive file.

[0011] According to some embodiments of the present disclosure, the binding includes integrating the plug-in into the target application by reference in a Maven coordinate manner.

[0012] According to some embodiments of the present disclosure, the first specific folder is sc / BOOT-INF / classes / , the second specific folder is sc / META-INF / , and the metadata file is a MANIFEST.MF file.

[0013] According to some embodiments of the present disclosure, the at least one source code file is determined from a plurality of source code files associated with the target application, and the plurality of source code files are obtained by the server from a distributed version control system hosting the target application.

[0014] According to some embodiments of the present disclosure, parsing the metadata file in the second specific folder among the multiple folders includes identifying the implementation title and / or entry class of the target application from the metadata file.

[0015] According to some embodiments of the present disclosure, determining at least one source code file corresponding to the target application includes: finding a directory of a first application component corresponding to the implementation title and / or the entry class in the source code files of the target application; and determining all source code files under the source code directory under the directory of the first application component as the at least one source code file.

[0016] According to some embodiments of the present disclosure, the method further includes: analyzing a configuration file of a first application component in a plurality of source code files associated with the target application to determine that the first application component depends on a second application component; obtaining all source code files in a source code directory under a directory of the second application component as at least one second source code file; finding an archive file of the second application component from a specific folder of the plurality of folders based on information about the second application component in the configuration file; and decompressing the archive file of the second application component to obtain at least one second intermediate code file corresponding to the second application component.

[0017] According to some embodiments of the present disclosure, generating a code coverage analysis report also includes: using a tool for performing code coverage analysis to generate a code coverage analysis report based at least in part on the at least one intermediate code file, the at least one source code file, the at least one second source code file, and the at least one second intermediate code file.

[0018] According to some embodiments of the present disclosure, generating a code coverage analysis report is further based on a code coverage log generated for the target application by a tool that performs code coverage analysis.

[0019] According to some embodiments of the present disclosure, the specific folder in which the archive file of the second application component is found is sc / BOOT-INF / lib / .

[0020] According to some embodiments of the present disclosure, a computer system is provided, comprising: one or more processors, and a memory coupled to the one or more processors, the memory storing computer-readable program instructions, which when executed by the one or more processors perform the method described above.

[0021] According to some embodiments of the present disclosure, a computer-readable storage medium is provided, on which computer-readable program instructions are stored. When the instructions are executed by the processor, the method described above is performed.

[0022] According to some embodiments of the present disclosure, there is provided a device for reducing the load of a server that performs code coverage analysis, including means for implementing the steps of the method described above. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The above and other objects, features and advantages of the present disclosure will become more apparent through a more detailed description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components in the exemplary embodiments of the present disclosure.

[0024] Figure 1 A block diagram of an exemplary computer system / server 12 suitable for use in implementing embodiments of the present invention is shown.

[0025] Figure 2 A flow chart of a method for generating a code coverage analysis report according to the prior art is shown.

[0026] Figure 3 A flowchart of a method for reducing the load of a server performing code coverage analysis according to an embodiment of the present disclosure is shown.

[0027] Figure 4 An example of a partial directory structure obtained by decompressing a JAR file of a target application packaged by Maven is shown.

[0028] Figure 5 An example of a partial directory structure of source code of a target application fetched from a distributed version control system is shown. DETAILED DESCRIPTION

[0029] The preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.

[0030] Figure 1 A block diagram of an exemplary computer system / server 12 suitable for use in implementing embodiments of the present invention is shown. Figure 1 The computer system / server 12 shown is merely an example and should not bring any limitation to the functionality and scope of use of embodiments of the present invention.

[0031] like Figure 1As shown, computer system / server 12 is in the form of a general-purpose computing device. Components of computer system / server 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).

[0032] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The computer system / server 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media. Although Figure 1 Not shown, a magnetic disk drive and an optical disk drive may also be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the various embodiments of the present invention.

[0033] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described herein.

[0034] The computer system / server 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), one or more devices that enable a user to interact with the computer system / server 12, and / or any device that enables the computer system / server 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. In addition, the computer system / server 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the computer system / server 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the computer system / server 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0035] Figure 2 A flow chart of a method for generating a code coverage analysis report according to the prior art is shown. Figure 2 In the example, the application to be tested is called the target application. In step 210, the target application is started, for example, the target application can be started by JavaAgent. Java Agent is a function provided by the Java virtual machine, which can monitor and analyze the virtual machine itself, and even intervene in its operation. It is a technology that can dynamically modify Java bytecode, so that we can change the running Java program through the Instrumentation API without modifying the program code. Java Agent usually enables the agent to access the startup process of the JVM by passing in specific parameters when the JVM is started, thereby realizing functions such as monitoring and analysis. In step 220, the pre-designed test case is executed to test the target application. The code coverage log is generated for the target application using the API of JaCoCo (for example, the dump command), and the code coverage log is, for example, a file with the suffix ".exec". In step 230, the source code file of the target application is pulled. For example, the source code file can be pulled from a distributed version control system (such as Github) that hosts the target application. In this example, the source code file is a file with the suffix ".java". In step 240, the source code file (i.e., .java file) is compiled to generate an intermediate code file (i.e., .class file). In step 250, the ".exec" file, ".java" file, and ".class" file obtained in steps 220 to 240 are used as inputs to generate a code coverage analysis report using the API of JaCoCo (e.g., report command).

[0036] As mentioned above, generating code coverage reports through bytecode enhancement techniques such as JaCoCo requires the class files of the target application as input. Generating the class files by compiling on the server side running the JaCoCo tool is accompanied by a series of disadvantages, such as long compilation time, complex compilation script configuration, and high server load.

[0037] In order to solve at least one of the above problems, the inventor of the present invention proposes a method and system for reducing the load of a server performing code coverage analysis. The method and system can quickly obtain the class files of the target application, solving the problem of long compilation time in step 240 of the above method and excessive server load when multiple projects are compiled at the same time. Since the method avoids compilation on the server side, it also solves the problem that some legacy projects or projects with complex dependencies need to configure compilation scripts separately and specially.

[0038] View now Figure 3 , Figure 3 A flowchart of a method 300 for reducing the load of a server performing code coverage analysis according to an embodiment of the present disclosure is shown. The method 300 is, for example, Figure 1 The computer system / server 12 executes the method 300. The method 300 includes an archive file acquisition step 310, an archive file decompression step 320, an intermediate code file acquisition step 330, a source code file determination step 340, and a report generation step 350.

[0039] The method 300 starts at an archive file acquisition step 310. In the archive file acquisition step 210, the server that performs the code coverage analysis acquires an archive file corresponding to the target application from the virtual machine environment that runs the target application. Here, the archive file is packaged in a specific packaging manner. In the following description of the present disclosure, for simplicity, a Java application will be used as an example of a target application. In the case of a Java application, the virtual machine environment is a Java virtual machine (JVM) environment, the archive file is a JAR file, the intermediate code file is a class file, and the source code file is a java source code file.

[0040] However, it should be understood by those skilled in the art that other applications or projects based on the JVM environment (such as Kotlin, Scala projects, etc.) can also use the idea of ​​the present invention to quickly extract class files, thereby speeding up the entire code coverage analysis report generation process. In an embodiment of a Java application, the above-mentioned archive file is a Java Archive file, that is, a JAR file. In addition, in the following description of the present disclosure, Maven will be used as an example of a project management and compilation tool for illustration. That is to say, the specific packaging method used by the archive file can be, for example, the method in which a JAR package is generated by Maven. Maven is a project management tool software that uses a project object model (POM) to describe the construction, reporting, and documentation of a project, and it can also perform compilation. Here, Maven is only an example given for illustration, and other compilers known to those skilled in the art, such as Gradle, etc., can also be used.

[0041] According to an embodiment of the present disclosure, the target application is bound to a plug-in, which can obtain the current location of the target application and stream the archive file. By adopting the plug-in, the target application under test can return its JAR file by only changing the configuration file of the target application without changing the source code of the target application. In an example according to the present disclosure, the name of the JAR file of the target application can be obtained and a file stream can be formed by the following code.

[0042] String jarName=PluginAController.class.getProtectionDomain().getCodeSource().getLocation().getFile();

[0043] InputStream is=FileUtils.openInputStream(new File(jarName));

[0044] Here, PluginAController is the class of the core code of the plug-in. According to one embodiment of the present disclosure, the above-mentioned binding includes referencing and integrating the plug-in into the target application in the form of Maven coordinates. Maven coordinates are information used to uniquely identify a project or component. It consists of three main parts: organization (Group), name (Artifact) and version (Version). Coordinates are usually expressed in the form of a string and are used to reference and locate components in Maven projects. Organization (Group) is a unique identifier of a project or component, usually expressed in the form of a reverse domain name (Reverse Domain Name). It is used to distinguish projects or components under different organizations. Name (Artifact) is the name of a project or component, used to identify a specific project or component. The name is usually related to the function of the project or component. Version (Version) is used to represent different versions of a project or component. The version number can be a combination of numbers, letters or other characters.

[0045] In an example according to the present disclosure, for example, the coordinates of the pluginA component (ie, the plugin) managed by Maven are given in the pom.xml file:

[0046] <groupid> com.joy< / groupid>

[0047] <artifactid> pluginA< / artifactid>

[0048] <version> 0.0.8-SNAPSHOT< / version>

[0049] Through the above Maven coordinate triples, the component pluginA can be globally and uniquely identified, and the file pluginA-0.0.8-SNAPSHOT.jar will be generated after packaging.

[0050] On the other hand, the component can be integrated into the target application by referencing the Maven coordinates in the target application's own pom.xml file. For example, the component pluginA can be referenced in the target application's own pom.xml file through the following configuration:

[0051] <dependency>

[0052] <groupid> com.joy< / groupid>

[0053] <artifactid> pluginA< / artifactid>

[0054] <version> 0.0.8-SNAPSHOT< / version>

[0055] < / dependency>

[0056] Here, the pom.xml file is a configuration file used by Maven to describe the project structure, and it can also be used to guide the compilation of the application.

[0057] According to one embodiment of the present disclosure, method 300 may further include, before obtaining the archive file, configuring the domain name or IP address of the target application on the server side so as to access the target application. By configuring the domain name or IP address of the target application on the server side, the server can send an archive file transfer request to the target application under test. According to one embodiment of the present disclosure, obtaining an archive file corresponding to the target application includes the virtual machine environment streaming the archive file to the server in response to a request from the server. In one example, the virtual machine environment running the target application sends an HTTP response to the server in response to an HTTP request from the server, and the HTTP response includes streaming of the archive file (e.g., a JAR file) of the target application requested by the server.

[0058] Now return to reference Figure 3 In the archive file decompression step 320, the archive file is decompressed to obtain a directory structure including multiple folders. Figure 4 An example of a partial directory structure obtained by decompressing the JAR file of the target application packaged by Maven is shown. In this example, the name of the target application is, for example, ApplicationX. Figure 4 The arrows in the figure represent subdirectory relationships, for example, "sc" is a subdirectory of "ApplicationX", "BOOT-INF" is a subdirectory of "sc", and so on. Figure 4 The example is only a simplified example for illustration. Those skilled in the art know that the directory structure after the JAR file is decompressed may also include other folders or files not shown.

[0059] In the intermediate code file acquisition step 330, at least one intermediate code file of the target application is acquired from a first specific folder of the plurality of folders. In the example of using Maven to package the JAR file of the target application, the first specific folder is sc / BOOT-INF / classes / . Figure 4 In the example of , the first specific folder is sc / BOOT-INF / classes / under the target application folder ApplicationX / . In an example according to the present disclosure, for example, from Figure 4 The com / nec / peppa / PeppaClassScheduleServiceApplication.class file is obtained from the sc / BOOT-INF / classes / folder of the first specific folder. Although in this example, one class file is obtained from the first specific folder, in other examples, the class files obtained from the first specific folder may be multiple, for example, the com / nec / peppa / classschedule / utils / DateTool.class file may also be included.

[0060] Now return to reference Figure 3 In the source code file determination step 340, the metadata file in the second specific folder of the multiple folders is parsed to determine at least one source code file corresponding to the target application. According to one embodiment of the present disclosure, in an example of using Maven to package the JAR file of the target application, the second specific folder is sc / META-INF / , and the metadata file is the MANIFEST.MF file.

[0061] According to one embodiment of the present disclosure, the at least one source code file is determined from a plurality of source code files associated with the target application, and the plurality of source code files are obtained by the server from a distributed version control system that hosts the target application. According to one embodiment of the present disclosure, as in step 230 of the prior art method, the source code files of the target project are pulled from a distributed version control system (such as Github) that hosts the target application to the server, and then the source code files to be submitted to the code coverage analysis are determined from the source code files. Figure 5 An example of a partial directory structure of the source code of an application ApplicationX fetched from, for example, Github is shown. Figure 5The arrows in the figure represent subdirectory relationships, the rectangles represent directories, and the parallelograms represent Java source files. For example, "src" is a subdirectory of "peppa-classschedule-service", "com.nec.peppa" is a subdirectory of "java", and so on. Figure 5 The example is only a simplified example given for illustration, and those skilled in the art know that the source file directory structure of the target application may also include other folders or files not shown.

[0062] According to one embodiment of the present disclosure, parsing the metadata file in the second specific folder of the multiple folders includes identifying the implementation title and / or entry class of the target application from the metadata file. In the example of using Maven to form the JAR file of the target application, the metadata file is a MANIFEST.MF file. The following is an example of the content of the MANIFEST.MF file:

[0063] Manifest_Version:1.0

[0064] Spring-Boot-Classpath-Index:BOOT / -INF / classpath.idx

[0065] Implementation-Title:peppa-classschedule-service

[0066] Implementation-Version:0.0.1-SNAPSHOT

[0067] Start-Class:com.nec.peppa.PeppaClassScheduleServiceApplication

[0068] Spring-Boot-Classes:BOOT-INF / classes /

[0069] Spring-Boot-Lib:BOOT-INF / lib /

[0070] Spring-Boot-Version:2.7.6

[0071] Created-By:Maven JAR Plugin 3.2.2

[0072] Main-Class:org.springframework.boot.loader.JarLauncher

[0073] In the above MANIFEST.MF file, for example, it can be recognized through the bold lines that the implementation title (Implemetation-Title) is peppa-classschedule-service and the entry class (Start-Class) is com.nec.peppa.PeppaClassScheduleServiceApplication.

[0074] According to an embodiment of the present disclosure, determining at least one source code file corresponding to the target application includes: finding a directory of a first application component corresponding to the implementation title and / or the entry class in the source code file of the target application; and determining all source code files under the source code directory under the directory of the first application component as the at least one source code file. Figure 5 The source code directory structure is used as an example to illustrate. After determining that the implementation title is peppa-classschedule-service, the peppa-classschedule-service directory can be found in the source code directory structure, and all java files under the directory, such as PeppaClassScheduleServiceApplication.java and DateTool.java, are determined as inputs for code coverage analysis. In another embodiment, after determining that the entry class is com.nec.peppa.PeppaClassScheduleServiceApplication, the corresponding java file com.nec.peppa / PeppaClassScheduleServiceApplication.java can be found in the source code directory structure, and the file and other java files under the directory of the component peppa-classschedule-service corresponding to the file are determined as inputs for code coverage analysis. According to another embodiment of the present invention, the peppa-classschedule-service directory can also be found by combining the implementation title and the entry class found in the MANIFEST.MF file for dual positioning, thereby determining all java files under the directory.

[0075] Now return to reference Figure 3In the report generation step 350, a code coverage analysis report is generated based at least in part on the at least one intermediate code file and the at least one source code file using a tool for performing code coverage analysis. According to one embodiment of the present disclosure, the tool for performing code coverage analysis may be, for example, JaCoCo, or other tools known in the art. In the above example, the following class files and java source code files are obtained in steps 330 and 340, respectively:

[0076] PeppaClassScheduleServiceApplication.class

[0077] DateTool.class

[0078] PeppaClassScheduleServiceApplication.java

[0079] DateTool.java

[0080] These files are provided as input parameters to JaCoCo to generate code coverage analysis reports.

[0081] According to one embodiment of the present disclosure, the generation of the code coverage analysis report is also based on the code coverage log generated for the target application by the tool performing the code coverage analysis. As described in step 220 of the method of the prior art, the pre-designed test case is executed to test the target application. The JaCoCo API (e.g., the dump command) is used to generate a code coverage log for the target application, and the code coverage log is, for example, a file with a suffix of ".exec".

[0082] Finally, the code coverage log (i.e., the "exec" file) is also input to JaCoCo together with the class files and java files obtained in the method 300 of the present invention to generate a code coverage analysis report. When generating a code coverage analysis report, for example, the report command in the JaCoCo API can be used.

[0083] The target application does not always have only a single component peppa-classschedule-service as in the above example, and sometimes it depends on other components. According to an embodiment of the present disclosure, method 300 may also include: analyzing the configuration file of the first application component in the multiple source code files associated with the target application to determine that the first application component depends on the second application component. As described above, the first application component is the application component corresponding to the entry class and / or implementation title identified from the MANIFEST.MF file. Figure 4and Figure 5 As an example, since the first application component identified is peppa-classschedule-service, the pom.xml file of the peppa-classschedule-service component is analyzed, and the following dependencies are found, for example:

[0084] <dependency>

[0085] <groupid> com.nec.peppa< / groupid>

[0086] <artifactid> peppa-classschedule-interface< / artifactid>

[0087] <version> 0.0.1-SNAPSHOT< / version>

[0088] < / dependency>

[0089] Therefore, it can be determined that the first application component peppa-classschedule-service depends on another application component peppa-classschedule-interface (ie, the second application component).

[0090] According to this embodiment of the present disclosure, method 300 may also include obtaining all source code files in a source code directory under the directory of the second application component as at least one second source code file. Taking the above example as an example, in this step, for example, the peppa-classschedule-interface directory in the source file directory structure (which is in Figure 5 The source code files of the second application component obtained may include one or more source code files.

[0091] According to this embodiment of the present disclosure, method 300 may further include finding the archive file of the second application component from a specific folder of the plurality of folders based on the information about the second application component in the configuration file. According to one embodiment of the present disclosure, the specific folder from which the archive file of the second application component is found is sc / BOOT-INF / lib / . Taking the above example as an example, in this step, the dependency reference of the second application component in the pom.xml file of the first application component is obtained. <artifactid>and <version>The tag can determine that the package name of the second application component is peppa-classschedule-interface-0.0.1-SNAPSHOT.jar. Then, the file can be found in the compressed sc / BOOT-INF / lib / of the target application's JAR file.

[0092] According to an embodiment of the present disclosure, method 300 may further include decompressing the archive file of the second application component to obtain at least one second intermediate code file corresponding to the second application component. In the above example, by decompressing the peppa-classschedule-interface-0.0.1-SNAPSHOT.jar, for example, CourseQuery.class and TemplateQuery.class files corresponding to CourseQuery.java and TemplateQuery.java may be obtained.

[0093] According to one embodiment of the present disclosure, generating a code coverage analysis report further includes: using a tool for performing code coverage analysis to generate a code coverage analysis report based at least in part on the at least one intermediate code file, the at least one source code file, the at least one second source code file, and the at least one second intermediate code file. That is, in the case of a dependency relationship, in addition to providing the source code and intermediate code file of the first application component corresponding to the entry class, the source code and intermediate code file of the second application component on which the first application component depends are also provided as input to the code coverage analysis tool. To illustrate with the above example, for example, the following files need to be provided to JaCoCo as partial input:

[0094] PeppaClassScheduleServiceApplication.class

[0095] PeppaClassScheduleServiceApplication.java

[0096] DateTool.class

[0097] DateTool.java

[0098] CourseQuery.class

[0099] CourseQuery.java

[0100] TemplateQuery.class

[0101] TemplateQuery.java

[0102] The present invention can realize rapid acquisition of the class file of the target application, avoid compiling on the coverage analysis server side to generate the class file, and solve the problems of long compilation time and excessive server load caused by simultaneous compilation of multiple projects in the prior art. The original analysis process of about 10 minutes can be shortened to a dozen seconds.

[0103] The present invention may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.

[0104] According to one embodiment of the present invention, a computer system is provided, which includes one or more processors and a memory coupled to the one or more processors. The memory stores computer-readable program instructions, and the instructions are executed by the one or more processors: a server obtains an archive file corresponding to the target application from a virtual machine environment running the target application, wherein the archive file is packaged in a specific packaging manner; decompresses the archive file to obtain a directory structure including multiple folders; obtains at least one intermediate code file of the target application from a first specific folder among the multiple folders; parses a metadata file in a second specific folder among the multiple folders to determine at least one source code file corresponding to the target application; and generates a code coverage analysis report based at least in part on the at least one intermediate code file and the at least one source code file using a tool for performing code coverage analysis.

[0105] According to another embodiment of the present invention, a computer-readable storage medium is provided, on which computer-readable program instructions are stored, and when executed by a processor, the instructions perform: obtaining, by a server, an archive file corresponding to a target application from a virtual machine environment running the target application, wherein the archive file is packaged in a specific packaging manner; decompressing the archive file to obtain a directory structure including multiple folders; obtaining at least one intermediate code file of the target application from a first specific folder among the multiple folders; parsing a metadata file in a second specific folder among the multiple folders to determine at least one source code file corresponding to the target application; and generating a code coverage analysis report based at least in part on the at least one intermediate code file and the at least one source code file using a tool that performs code coverage analysis.

[0106] According to another embodiment of the present invention, a device for reducing the load of a server that performs code coverage analysis is provided, comprising: a device for obtaining, by the server, an archive file corresponding to a target application from a virtual machine environment that runs the target application, wherein the archive file is packaged in a specific packaging manner; a device for decompressing the archive file to obtain a directory structure including multiple folders; a device for obtaining at least one intermediate code file of the target application from a first specific folder among the multiple folders; a device for parsing a metadata file in a second specific folder among the multiple folders to determine at least one source code file corresponding to the target application; and a device for generating a code coverage analysis report based at least in part on the at least one intermediate code file and the at least one source code file using a tool that performs code coverage analysis.

[0107] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0108] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0109] The computer program instructions for performing the operation of the present invention may be assembler instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of a computer-readable program instruction, and the electronic circuit may execute a computer-readable program instruction, thereby realizing various aspects of the present invention.

[0110] Various aspects of the present invention are described herein with reference to the flow charts and / or block diagrams of the methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each box of the flow chart and / or block diagram and the combination of each box in the flow chart and / or block diagram can be implemented by computer-readable program instructions.

[0111] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0112] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0113] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0114] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terms used herein are selected to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.< / version> < / artifactid>

Claims

1. A method for reducing the load of a server performing code coverage analysis, comprising: The server obtains an archive file corresponding to the target application from a virtual machine environment running the target application, wherein the archive file is packaged in a specific packaging manner; decompressing the archive file to obtain a directory structure including a plurality of folders; Acquire at least one intermediate code file of the target application from a first specific folder among the multiple folders; parsing a metadata file in a second specific folder of the plurality of folders to determine at least one source code file corresponding to the target application; as well as A code coverage analysis report is generated, using a tool that performs code coverage analysis, based at least in part on the at least one intermediate code file and the at least one source code file.

2. The method according to claim 1, wherein the virtual machine environment is a Java virtual machine (JVM) environment, the archive file is a JAR file, the intermediate code file is a class file, and the source code file is a Java source code file. 3 . The method of claim 1 , wherein obtaining the archive file corresponding to the target application comprises the virtual machine environment streaming the archive file to the server in response to a request from the server.

4. The method according to claim 1 further includes configuring the domain name or IP address of the target application on the server side before obtaining the archive file so as to be able to access the target application. 5 . The method according to claim 1 , wherein the target application is bound to a plug-in, the plug-in being capable of obtaining a current location of the target application and being capable of streaming the archive file. 6 . The method according to claim 5 , wherein the binding comprises integrating the plug-in into the target application by reference in a Maven coordinate manner.

7. The method of claim 2, wherein the first specific folder is sc / BOOT-INF / classes / , the second specific folder is sc / META-INF / , and the metadata file is a MANIFEST.MF file.

8. The method according to claim 1, wherein: The at least one source code file is determined from a plurality of source code files associated with the target application, and the plurality of source code files are obtained by the server from a distributed version control system hosting the target application.

9. The method according to claim 8, wherein parsing the metadata file in a second specific folder among the multiple folders comprises identifying an implementation title and / or an entry class of the target application from the metadata file.

10. The method according to claim 9, wherein determining at least one source code file corresponding to the target application comprises: Finding a directory of a first application component corresponding to the implementation title and / or the entry class in a source code file of the target application; as well as All source code files in a source code directory under the directory of the first application component are determined as the at least one source code file.

11. The method according to claim 10, further comprising: analyzing a configuration file of a first application component in a plurality of source code files associated with the target application to determine that the first application component is dependent on a second application component; Obtaining all source code files in a source code directory under the directory of the second application component as at least one second source code file; Finding an archive file of the second application component from a specific folder of the plurality of folders based on the information about the second application component in the configuration file; as well as The archive file of the second application component is decompressed to obtain at least one second intermediate code file corresponding to the second application component.

12. The method according to claim 11, wherein generating a code coverage analysis report further comprises: A code coverage analysis report is generated using a tool that performs code coverage analysis based at least in part on the at least one intermediate code file, the at least one source code file, the at least one second source code file, and the at least one second intermediate code file. 13 . The method according to claim 1 , wherein generating a code coverage analysis report is further based on a code coverage log generated for the target application by a tool that performs code coverage analysis.

14. The method of claim 11, wherein the specific folder in which the archive file of the second application component is found is sc / BOOT-INF / lib / .

15. A computer system comprising: one or more processors; and A memory coupled to the one or more processors, the memory storing computer-readable program instructions, which when executed by the one or more processors perform the method of any one of claims 1-14.

16. A computer-readable storage medium storing computer-readable program instructions, wherein the instructions, when executed by a processor, perform the method according to any one of claims 1 to 14.

17. A device for reducing the load of a server performing code coverage analysis, comprising means for implementing the steps of the method according to any one of claims 1 to 14.