CN114676065A - Code coverage report generation method, device, computer equipment and medium - Google Patents

Code coverage report generation method, device, computer equipment and medium Download PDF

Info

Publication number
CN114676065A
CN114676065A CN202210386122.3A CN202210386122A CN114676065A CN 114676065 A CN114676065 A CN 114676065A CN 202210386122 A CN202210386122 A CN 202210386122A CN 114676065 A CN114676065 A CN 114676065A
Authority
CN
China
Prior art keywords
code coverage
code
class file
report
source code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210386122.3A
Other languages
Chinese (zh)
Inventor
徐轲
薛海伟
鲁健翔
戴小村
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan Changyin May 8th Consumer Finance Co ltd
Original Assignee
Hunan Changyin May 8th Consumer Finance Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan Changyin May 8th Consumer Finance Co ltd filed Critical Hunan Changyin May 8th Consumer Finance Co ltd
Priority to CN202210386122.3A priority Critical patent/CN114676065A/en
Publication of CN114676065A publication Critical patent/CN114676065A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Abstract

The application relates to a code coverage report generation method, a code coverage report generation device, a computer device, a storage medium and a computer program product, wherein the method comprises the following steps: acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file; reading a resource file required by a class file, packaging and deploying the class file and the resource file to an application server to execute a preset jaccorefit.sh script, and collecting code coverage rate data from the application server; and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode. In the whole process, source codes and deployment projects are automatically acquired, code coverage rate data are automatically collected from an application server by adopting a mode of executing jaccoreport.

Description

Code coverage rate report generation method, device, computer equipment and medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a computer device, a storage medium, and a computer program product for generating a code coverage report.
Background
With the development of computer technology, various software programs and software service platforms appear, and the programs and the platforms can realize corresponding functions based on written code programs, so that convenience is brought to people.
Code coverage testing is very important in computer programming. In particular, code coverage is a measure of software testing that describes the proportion and extent to which source code is tested in a program, the resulting proportion being referred to as code coverage. When performing unit tests, code coverage is often taken as an index to measure the quality of the test.
In the conventional technology, code coverage is generated by a specific tester through simulating various test environments, manually recording corresponding test data, and generating a final code coverage report after filling. Although the scheme based on manual generation of the code coverage rate report can finally obtain the required report, the whole process needs a professional technician to perform multiple operations on a computer, and the code coverage rate report generation efficiency is low.
Disclosure of Invention
In view of the above, it is necessary to provide an automatic code coverage report generation method, apparatus, computer device, computer readable storage medium and computer program product for solving the above technical problems.
In a first aspect, the present application provides a method for generating a code coverage report, the method comprising:
acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file;
reading resource files required by the class file, and packaging and deploying the class file and the resource files to an application server;
sh script is executed, and code coverage rate data is collected from the application server;
and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
In one embodiment, generating a readable code coverage report from the code coverage data, the project source code, and the class file in combination comprises:
generating a binary code coverage rate file according to the code coverage rate data;
and generating a readable code coverage report by combining the binary code coverage file, the project source code and the class file.
In one embodiment, generating a readable code coverage report in conjunction with the binary code coverage file, the project source code, and the class file comprises:
and calling a report command provided by a JaCoCo tool, combining the binary code coverage file with the project source code and the class file, and converting to generate a code coverage report in an HTML (HyperText Markup Language) format.
In one embodiment, the preset jaccoreport.sh script is executed, and the collecting of the code coverage data from the application server comprises:
executing a preset jaccoreport.
Code coverage data is collected from the application server by invoking the dump command provided by the JaCoCo tool.
In one embodiment, obtaining the item source code comprises:
and accessing the SVN server, and acquiring the item source code through a checkout command.
In one embodiment, after generating the readable code coverage report according to the combination of the code coverage data, the project source code and the class file, the method further comprises:
responding to a code coverage rate report online viewing request sent by a user platform;
and starting the pre-deployed Nginx service, and pushing the readable code coverage rate report to the user platform in a reverse proxy mode.
In a second aspect, the present application further provides an apparatus for generating a code coverage report, where the apparatus includes:
the compiling module is used for acquiring a project source code, locally constructing and compiling the project source code and obtaining a compiled class file;
the deployment module is used for reading the resource files required by the class file, and packaging and deploying the class file and the resource files to the application server;
the script execution module is used for executing a preset jaccoreport.sh script and collecting code coverage rate data from the application server;
and the report generation module is used for generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory and a processor, the memory stores a computer program, and the processor realizes the following steps when executing the computer program:
acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file;
reading resource files required by the class file, and packaging and deploying the class file and the resource files to an application server;
sh script is executed, and code coverage rate data is collected from the application server;
and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
In a fourth aspect, the present application further provides a computer-readable storage medium. A computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of:
acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file;
reading resource files required by the class file, and packaging and deploying the class file and the resource files to an application server;
sh script is executed, and code coverage rate data is collected from the application server;
and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
In a fifth aspect, the present application further provides a computer program product. Computer program product comprising a computer program which, when executed by a processor, performs the steps of:
acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file;
reading resource files required by the class file, and packaging and deploying the class file and the resource files to an application server;
sh script is executed, and code coverage rate data is collected from the application server;
and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
The code coverage rate report generation method, the code coverage rate report generation device, the computer equipment, the storage medium and the computer program product are used for acquiring a project source code, locally constructing and compiling the project source code and obtaining a compiled class file; reading a resource file required by a class file, packaging and deploying the class file and the resource file to an application server, executing a preset jaccoreport. And generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode. In the whole process, source codes and deployment projects are automatically obtained, code coverage rate data are automatically collected from an application server by adopting a mode of executing jaccoreport.
Drawings
FIG. 1 is a diagram of an application environment for a method of generating a code coverage report in one embodiment;
FIG. 2 is a flow diagram that illustrates a method for generating a code coverage report, according to one embodiment;
FIG. 3 is a flowchart illustrating a method for generating a code coverage report according to another embodiment;
FIG. 4 is an interaction diagram of a code coverage report generation method in an application example;
FIG. 5 is a block diagram of an apparatus for generating a code coverage report in one embodiment;
FIG. 6 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The code coverage report generation method provided by the embodiment of the application can be applied to the application environment shown in fig. 1. The method comprises the steps that an engineering capacity platform, a Jenkins server, an application server and an SVN server form a networking network, the engineering capacity platform and the Jenkins server are matched to execute the scheme of the code coverage rate report generation method, the Jenkins server accesses the SVN server to obtain project source codes, the project source codes are locally constructed and compiled, and a compiled class file is obtained; reading resource files required by the class file, and packaging and deploying the class file and the resource files to an application server; a user clicks a report generation button on an engineering capacity platform, a code coverage rate test request is initiated to be generated to a Jenkins server, the Jenkins server calls a preset jaccoreport.sh script, an application server port and an address transmitted by the engineering capacity platform are used as access parameters, the preset jaccoreport.sh script is executed, and code coverage rate data are collected from the application server; and combining and generating a readable code coverage report according to the code coverage data, the project source code and the class file, and feeding the generated code coverage report back to the engineering capability platform.
In one embodiment, as shown in fig. 2, there is provided a code coverage report generation method, including the steps of:
s100: and acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file.
Jenkins is a piece of open source continuous integration and continuous deployment software used to automate various tasks, including building, testing, and deploying software. Jenkins server refers to a server loaded with Jenkins. In practical application, the Jenkins server obtains the project source code, and the Jenkins server can specifically obtain the project source code by accessing the SVN server. The SVN is an abbreviation of Subversion and is a version control system for opening sources, and source codes of an application system are stored and managed in a central version library of the SVN. Specifically, the Jenkins server accesses the SVN server and obtains the item source code through a checkout command. The project source code refers to a source code for executing a current target task, for example, if an ABS project needs to be executed, the project source code is the ABS project source code. And (4) locally constructing and compiling the project source code, and obtaining a class file after compiling. Furthermore, the Jenkins server can also cache the compiled class file according to a specified path so as to facilitate subsequent reading and calling.
S200: reading the resource files required by the class file, packaging and deploying the class file and the resource files to the application server, and recording the address and the port of the application server.
The Jenkins server reads resource files required by the class files, the class files and the resource files are packaged, the packaging specifically can be that data are directly packaged into a WAR package, and the packaged compressed package is deployed to an application server. Namely, after the Jenkins server packs and generates a project compression package, the project compression package is sent to the application server for deployment S300: and executing a preset jaccoreport.
The Jenkins server is pre-stored with a preset jaccoreport. And the Jenkins server executes a preset jaccoreport. Specifically, an ant script on a Jenkins server is executed through a preset jacocoreport.sh script, and the ant script calls a dump command provided by the JaCoCo to read code execution related information from an application server, namely, code coverage rate data is collected.
S400: and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
The code coverage data needs to incorporate the project source code and the class file to ultimately generate a readable code coverage report. Thus, the Jenkins server combines the code coverage data, the project source code, and the class file to generate a readable code coverage report. Specifically, after the Jenkins server acquires the code coverage rate data, the code coverage rate data is stored according to the specified path, and then the calling command, the storage path of the specified code coverage rate data, the storage path of the project source code and the storage path of the class file are combined and converted to obtain a readable code coverage rate report.
The code coverage rate report generation method comprises the steps of obtaining a project source code, locally constructing and compiling the project source code, and obtaining a compiled class file; reading a resource file required by a class file, packaging and deploying the class file and the resource file to an application server to execute a preset jaccorefit.sh script, and collecting code coverage rate data from the application server; and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode. In the whole process, source codes and deployment projects are automatically obtained, code coverage rate data are automatically collected from an application server by adopting a mode of executing jaccoreport.
As shown in fig. 3, in one embodiment, S400 includes:
s420: generating a binary code coverage rate file according to the code coverage rate data;
s440: and generating a readable code coverage report by combining the binary code coverage file, the project source code and the class file.
And the Jenkins server generates a binary code coverage rate file according to the code coverage rate data, and combines the binary code coverage rate file, the project source code and the class file for a readable code coverage rate report which is finally obtained. Further, the whole combination process can be realized by a script call command, wherein the call command is used for writing the code coverage data collected from the application server into an initial binary code coverage file to generate a binary code coverage file, the binary code coverage file is not readable, the call command is continued to combine the binary code coverage file with the project source code and the class file, and finally a readable code coverage report is generated.
In one embodiment, generating a readable code coverage report in conjunction with the binary code coverage file, the project source code, and the class file comprises:
and calling a report command provided by a JaCoCo tool, combining the binary code coverage rate file with the project source code and the class file, and converting to generate a code coverage rate report in an HTML format.
The Jenkins server stores a preset jaccoreport.sh script, and the jaccoreport.sh script executes an ant script to call a report command provided by a JaCoCo tool, combine the binary code coverage rate file with the item source code and the class file, and convert and generate a code coverage rate report in an HTML format. JaCoCo modifies bytecode methods based on ASM technology, dynamically changing class behavior before the class is loaded into the Java virtual machine JVM. JVM starts an instrumentation agent program through a javacent parameter to specify a specific jaccoagent. jar file (provided by a JaCoCo library), the agent program judges whether the file is converted and modified or not before loading the class file, if not, a probe (statistical code) is inserted into the class file, and finally, analysis of the coverage rate is completed in the process of executing the test code by the JVM.
In one embodiment, executing a preset jacocoreport.sh script, and collecting code coverage data from an application server comprises:
executing a preset jaccoreport. Code coverage data is collected from the application server by invoking the dump command provided by the JaCoCo tool.
And similarly, executing an ant script by a jacocoreport.sh script in the Jenkins server, calling a dump command provided by a JaCoCo tool, and reading code execution related information from the application server, namely collecting code coverage rate data from the application server.
In practical application, a jaccoreport.sh script is stored in a Jenkins server, receives an application server address and a port transmitted from the outside, calls a dump command provided by JaCoCo, and writes code coverage rate data collected by the application server into a jacoco.exec binary file. The binary file report is unreadable, and the JacOCO converts the binary file into a readable code coverage report in an HTML format by combining the project source code and the compiled class file.
In one embodiment, after generating the readable code coverage report according to the combination of the code coverage data, the project source code and the class file, the method further comprises:
responding to a code coverage rate report online viewing request sent by a user platform; and starting the pre-deployed Nginx service, and pushing the readable code coverage rate report to the user platform in a reverse proxy mode.
In practical application, when a user needs to check a code coverage rate report online, the user operates on a platform, the user clicks a 'report generation' button, the user platform generates a code coverage rate report online checking request and sends the request to a Jenkins server, the Jenkins server starts a pre-deployed Nginx service, and a readable code coverage rate report is pushed to the user platform in a reverse proxy mode. In particular, the Nginx services are open source, high performance, highly reliable Web and reverse proxy services. The Jenkins server is provided with Nginx service, and after reverse proxy, the readable code coverage rate report can be viewed on line through a terminal browser.
In order to describe the technical solution of the code coverage report generating method and the effect thereof in detail, a specific application example is adopted below, and is expanded by combining with an interaction diagram fig. 4.
In a specific application example, a Jenkins server forms a network with an engineering capability platform (user platform), an application system server (application server) and an SVN server respectively, and taking an ABS project as an example, the generation of the whole code coverage rate report comprises the following steps:
1. the Jenkins server (100.74.128.135) gets ABS project source codes from the SVN server (100.74.128.138) checkout and locally constructs the ABS project source codes on the Jenkins server, the source codes are downloaded into a path/var/lib/Jenkins/works space/ABS/src, and a compiled class file is generated into the path/var/lib/Jenkins/works space/ABS/webapp/WEB-INF/classes.
2. War packs the class file of ABS and other required resource files into ABS, deploys to Tomcat of ABS test environment application system server (100.74.128.124), and restarts Tomcat. The JaCoCo Agent program deployed on the application server will take effect and start monitoring the JVM, collecting the relevant data of code execution.
3. When a 'report generation' button corresponding to an ABS project on an engineering capacity platform (100.74.128.136) is clicked, a background program of the engineering capacity platform is remotely connected with a Jenkins server (100.74.128.135), a/home/Jenkins/jacocorecord.sh script is executed, and parameters such as Jenkins project names ABS, Jacoco monitoring server IP addresses 100.74.128.124 and ports 7781 are transmitted.
4. The script calls a dump command provided by the JacoCo to read code execution related information from a JVM of an ABS application server, and then a code coverage rate binary code coverage rate report file JacoC.exec is exported to a position under an ABS engineering path/var/lib/Jenkins/workbench/ABS/JacoC.exec.
5. Exec is a binary code coverage report file that must be combined with the source code and class files to be converted into readable report content. Therefore, a report command provided by the JacCoo is continuously called in a fourth step script jacoco.xml, a source code path/var/lib/jenkins/workspace/abs/src and a class file path/var/lib/jenkins/workspace/abs/webapp/WEB-INF/classes are specified, and jacoco.exec is converted into a code coverage rate report file in an HTML format to be placed under the path/home/jenkins/report/abs; nginx on Jenkins Server will reverse all HTML files under proxy/home/Jenkins/report/abs path so that testers can access http://100.74.128.135/abs through browser to view code coverage reports online.
It should be understood that, although the steps in the flowcharts related to the embodiments are shown in sequence as indicated by the arrows, the steps are not necessarily executed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in the flowcharts related to the above embodiments may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least a part of the steps or stages in other steps.
Based on the same inventive concept, the embodiment of the present application further provides a code coverage report generating device for implementing the above-mentioned code coverage report generating method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so specific limitations in one or more embodiments of the code coverage report generating device provided below can refer to the above limitations on the code coverage report generating method, and details are not described here.
In one embodiment, as shown in fig. 5, there is provided a code coverage report generating apparatus including:
the compiling module 100 is used for acquiring a project source code, locally constructing and compiling the project source code, and obtaining a compiled class file;
the deployment module 200 is used for reading the resource files required by the class file, and packaging and deploying the class file and the resource files to the application server;
the script execution module 300 is configured to execute a preset jaccoreport.sh script and collect code coverage data from an application server;
and a report generation module 400, configured to generate a readable code coverage report according to the code coverage data, the project source code, and the class file.
The code coverage rate report generating device acquires a project source code, locally constructs and compiles the project source code to obtain a compiled class file; reading a resource file required by a class file, packaging and deploying the class file and the resource file to an application server to execute a preset jaccorefit.sh script, and collecting code coverage rate data from the application server; and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode. In the whole process, source codes and deployment projects are automatically obtained, code coverage rate data are automatically collected from an application server by adopting a mode of executing jaccoreport.
In one embodiment, the report generation module 400 is further configured to generate a binary code coverage file based on the code coverage data; and generating a readable code coverage report by combining the binary code coverage file, the project source code and the class file.
In one embodiment, the report generation module 400 is further configured to invoke a report command provided by the JaCoCo tool, combine the binary code coverage file with the project source code and the class file, and convert to generate the code coverage report in HTML format.
In one embodiment, the script execution module 300 is further configured to execute a preset jaccoreport. Code coverage data is collected from the application server by invoking the dump command provided by the JaCoCo tool.
In one embodiment, the compiling module 100 is further configured to access the SVN server and obtain the source code of the item through a checkout command.
In one embodiment, the code coverage report generating device further comprises a report viewing module for responding to a code coverage report online viewing request sent by the user platform; and starting the pre-deployed Nginx service, and pushing the readable code coverage rate report to the user platform in a reverse proxy mode.
The modules in the code coverage report generating device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing preset script data. The network interface of the computer device is used for communicating with an external user platform through a network connection. The computer program is executed by a processor to implement a code coverage report generation method.
It will be appreciated by those skilled in the art that the configuration shown in fig. 6 is a block diagram of only a portion of the configuration associated with the present application, and is not intended to limit the computing device to which the present application may be applied, and that a particular computing device may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file;
reading resource files required by the class file, and packaging and deploying the class file and the resource files to an application server;
sh script is executed, and code coverage rate data is collected from an application server;
and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
generating a binary code coverage rate file according to the code coverage rate data; and generating a readable code coverage report by combining the binary code coverage file, the project source code and the class file.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and calling a report command provided by a JaCoCo tool, combining the binary code coverage file with the project source code and the class file, and converting to generate a code coverage report in an HTML (HyperText Markup Language) format.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
executing a preset jaccoreport. Code coverage data is collected from the application server by invoking the dump command provided by the JaCoCo tool.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and accessing the SVN server, and acquiring the item source code through a checkout command.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
responding to a code coverage rate report online viewing request sent by a user platform; and starting the pre-deployed Nginx service, and pushing the readable code coverage rate report to the user platform in a reverse proxy mode.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, performs the steps of:
acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file;
reading resource files required by the class file, and packaging and deploying the class file and the resource files to an application server;
sh script is executed, and code coverage rate data is collected from an application server;
and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
In one embodiment, the computer program when executed by the processor further performs the steps of:
generating a binary code coverage rate file according to the code coverage rate data; and generating a readable code coverage report by combining the binary code coverage file, the project source code and the class file.
In one embodiment, the computer program when executed by the processor further performs the steps of:
and calling a report command provided by a JaCoCo tool, combining the binary code coverage file with the project source code and the class file, and converting to generate a code coverage report in an HTML (HyperText Markup Language) format.
In one embodiment, the computer program when executed by the processor further performs the steps of:
executing a preset jaccoreport. Code coverage data is collected from the application server by invoking the dump command provided by the JaCoCo tool.
In one embodiment, the computer program when executed by the processor further performs the steps of:
and accessing the SVN server, and acquiring the item source code through a checkout command.
In one embodiment, the computer program when executed by the processor further performs the steps of:
responding to a code coverage rate report online viewing request sent by a user platform; and starting the pre-deployed Nginx service, and pushing the readable code coverage rate report to the user platform in a reverse proxy mode.
In one embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, performs the steps of:
acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file;
reading resource files required by the class file, and packaging and deploying the class file and the resource files to an application server;
executing a preset jaccoreport.sh script, and collecting code coverage rate data from an application server;
and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
In one embodiment, the computer program when executed by the processor further performs the steps of:
generating a binary code coverage rate file according to the code coverage rate data; and generating a readable code coverage report by combining the binary code coverage file, the project source code and the class file.
In one embodiment, the computer program when executed by the processor further performs the steps of:
and calling a report command provided by a JaCoCo tool, combining the binary code coverage file with the project source code and the class file, and converting to generate a code coverage report in an HTML (HyperText Markup Language) format.
In one embodiment, the computer program when executed by the processor further performs the steps of:
executing a preset jaccoreport. The dump command provided by the JaCoCo tool is invoked to collect code coverage data from the application server.
In one embodiment, the computer program when executed by the processor further performs the steps of:
and accessing the SVN server, and acquiring the item source code through a checkout command.
In one embodiment, the computer program when executed by the processor further performs the steps of:
responding to a code coverage rate report online viewing request sent by a user platform; and starting the pre-deployed Nginx service, and pushing the readable code coverage rate report to the user platform in a reverse proxy mode.
It should be noted that, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high-density embedded nonvolatile Memory, resistive Random Access Memory (ReRAM), Magnetic Random Access Memory (MRAM), Ferroelectric Random Access Memory (FRAM), Phase Change Memory (PCM), graphene Memory, and the like. Volatile Memory can include Random Access Memory (RAM), external cache Memory, and the like. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others. The databases referred to in various embodiments provided herein may include at least one of relational and non-relational databases. The non-relational database may include, but is not limited to, a block chain based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing based data processing logic devices, etc., without limitation.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not to be construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims (10)

1. A method of generating a code coverage report, the method comprising:
acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file;
reading the resource files required by the class file, and packaging and deploying the class file and the resource files to an application server;
sh script is executed, and code coverage rate data is collected from the application server;
and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
2. The method of claim 1, wherein said combining to generate a readable code coverage report based on said code coverage data, said project source code, and said class file comprises:
generating a binary code coverage rate file according to the code coverage rate data;
and generating a readable code coverage report by combining the binary code coverage file, the project source code and the class file.
3. The method of claim 2, wherein generating a readable code coverage report in conjunction with the binary code coverage file, the project source code, and the class file comprises:
and calling a report command provided by a JaCoCo tool, combining the binary code coverage rate file with the project source code and the class file, and converting to generate a code coverage rate report in an HTML format.
4. The method of claim 1, wherein the executing a pre-defined jacocoreport.sh script, and wherein collecting code coverage data from the application server comprises:
executing a preset jaccoreport.
And calling dump commands provided by a JacCoO tool to collect code coverage data from the application server.
5. The method of claim 1, wherein obtaining item source code comprises:
and accessing the SVN server, and acquiring the item source code through a checkout command.
6. The method of claim 1, after said combining and generating a readable code coverage report based on said code coverage data, said project source code, and said class file, further comprising:
responding to a code coverage rate report online viewing request sent by a user platform;
and starting a pre-deployed Nginx service, and pushing the readable code coverage rate report to the user platform in a reverse proxy mode.
7. An apparatus for generating a code coverage report, the apparatus comprising:
the compiling module is used for acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file;
the deployment module is used for reading the resource files required by the class file and packaging and deploying the class file and the resource files to an application server;
the script execution module is used for executing a preset jaccoreport.sh script and collecting code coverage rate data from the application server;
and the report generation module is used for combining and generating a readable code coverage report according to the code coverage data, the project source code and the class file.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 6.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program realizes the steps of the method of any one of claims 1 to 6 when executed by a processor.
CN202210386122.3A 2022-04-13 2022-04-13 Code coverage report generation method, device, computer equipment and medium Pending CN114676065A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210386122.3A CN114676065A (en) 2022-04-13 2022-04-13 Code coverage report generation method, device, computer equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210386122.3A CN114676065A (en) 2022-04-13 2022-04-13 Code coverage report generation method, device, computer equipment and medium

Publications (1)

Publication Number Publication Date
CN114676065A true CN114676065A (en) 2022-06-28

Family

ID=82077500

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210386122.3A Pending CN114676065A (en) 2022-04-13 2022-04-13 Code coverage report generation method, device, computer equipment and medium

Country Status (1)

Country Link
CN (1) CN114676065A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150161028A1 (en) * 2013-12-09 2015-06-11 International Business Machines Corporation System and method for determining test coverage
CN106681912A (en) * 2016-12-08 2017-05-17 武汉斗鱼网络科技有限公司 Method and device for automatic testing of code coverage rate, applied to Android system
CN110888817A (en) * 2019-12-18 2020-03-17 广州唯品会研究院有限公司 Method and device for generating code coverage rate report and readable storage medium
CN113986734A (en) * 2021-10-28 2022-01-28 中国平安人寿保险股份有限公司 Code coverage report generation method, device, equipment and medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150161028A1 (en) * 2013-12-09 2015-06-11 International Business Machines Corporation System and method for determining test coverage
CN106681912A (en) * 2016-12-08 2017-05-17 武汉斗鱼网络科技有限公司 Method and device for automatic testing of code coverage rate, applied to Android system
CN110888817A (en) * 2019-12-18 2020-03-17 广州唯品会研究院有限公司 Method and device for generating code coverage rate report and readable storage medium
CN113986734A (en) * 2021-10-28 2022-01-28 中国平安人寿保险股份有限公司 Code coverage report generation method, device, equipment and medium

Similar Documents

Publication Publication Date Title
US8561024B2 (en) Developing software components and capability testing procedures for testing coded software component
US8978020B2 (en) Generating reusable test components out of remote application programming interface
CN111651366B (en) SDK test method, device, equipment and storage medium
US7725772B2 (en) Generic template to autogenerate reports for software target testing
US8510712B1 (en) Testing in-container software objects
US7900198B2 (en) Method and system for parameter profile compiling
US9491222B2 (en) System and method for interoperability between flex applications and .NET applications
US8918762B2 (en) Generating test plans and test cases from service-oriented architecture and process models
CN107391219B (en) Function Compilation Method and device
CN113568839A (en) Method, device, equipment and medium for software testing and statistical test coverage rate
CN107273298A (en) A kind of method of testing of shell adding instrument, apparatus and system
CN111221721A (en) Automatic recording and executing method and device for unit test cases
CN116911588A (en) Business process execution method, device, equipment and storage medium
CN108304230B (en) Implementation method and device for adjusting application attribute and readable storage medium
CN114676065A (en) Code coverage report generation method, device, computer equipment and medium
US8745587B2 (en) System and method for testing computer programs
CN112769609B (en) Method, system, medium, and article of manufacture for controlling fault simulation and simulating faults
CN112527312B (en) Test method and test device for embedded system
CN112346981A (en) Joint debugging test coverage rate detection method and system
Souter et al. TATOO: T esting and A nalysis T ool for O bject-O riented Software
CN111367512A (en) Method and device for creating Android library module dependency relationship in application development
CN112416735A (en) Application program detection method and device, terminal equipment and storage medium
CN117130917B (en) Ash box testing method, device and system for containerized Java application
CN117493162A (en) Data verification method, system, equipment and storage medium for interface test
CN115080431A (en) Code testing method, device, storage medium and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20220628

RJ01 Rejection of invention patent application after publication