CN115687129A - Coverage rate report generation method and device, storage medium and computer equipment - Google Patents

Coverage rate report generation method and device, storage medium and computer equipment Download PDF

Info

Publication number
CN115687129A
CN115687129A CN202211379668.2A CN202211379668A CN115687129A CN 115687129 A CN115687129 A CN 115687129A CN 202211379668 A CN202211379668 A CN 202211379668A CN 115687129 A CN115687129 A CN 115687129A
Authority
CN
China
Prior art keywords
code
coverage
coverage rate
file
version information
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
CN202211379668.2A
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.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank 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 Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202211379668.2A priority Critical patent/CN115687129A/en
Publication of CN115687129A publication Critical patent/CN115687129A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application discloses a coverage rate report generation method, a coverage rate report generation device, a storage medium and computer equipment, wherein the method comprises the following steps: acquiring a code of a current version in a code library in a packaging server and version information corresponding to the code; packaging the codes to generate a corresponding test packet, and testing the test packet to generate a corresponding coverage rate file; sending the test package and the coverage rate file to a coverage rate statistical server; acquiring version information corresponding to a source code and an initial coverage rate file corresponding to the source code in a coverage rate statistical server, and comparing the version information corresponding to the code with the version information corresponding to the source code; and if the version information corresponding to the code is the same as the version information corresponding to the source code, generating a coverage rate report according to the coverage rate file corresponding to the code and the initial coverage rate file corresponding to the source code. The technical scheme of the invention can solve the technical problem of generating errors of the coverage rate report due to inconsistent versions of the codes.

Description

Coverage rate report generation method and device, storage medium and computer equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a coverage report generation method, apparatus, storage medium, and computer device.
Background
Coverage is a measure of test integrity and test validity, as represented by the executed code, for reliability, stability, and performance.
Test coverage is an assessment of the completeness of a test, which is represented by test requirements and coverage of test cases or coverage of executed code, based on an evaluation of test results and an analysis of change requests determined during the test.
At present, a coverage rate tool can calculate coverage rate data only under the condition that a code is not changed, but a system development changes a code due to a requirement change or defect repair at a test stage, so that one version has a plurality of test packages, for example, a developer a packages a code of the version 9 on a packaging server to obtain a test package of a code corresponding to the version 9, the tester packages the code of the version 9 when testing, if another developer B subsequently adds or deletes the code of the version 9 on the basis of the developer a to obtain an updated code of the version 10, and then, the packaging server packages the code of the version 10 to obtain a test package of a code corresponding to the version 10, because the instrumented code in the test package corresponding to the code of the version 10 is different from the instrumented code in the test package corresponding to the code of the version 9, a source code on a coverage rate statistical server is still the code of the version 9, and a signal is generated due to an error in the test package of the version 10 corresponding to the code of the version 9.
Disclosure of Invention
The embodiment of the invention provides a method, a device, a storage medium and computer equipment for generating a coverage rate report, which are used for preventing the technical problem of generating errors of the coverage rate report due to the fact that the version of an interpolation stub code in a test packet packaged by a packaging server is inconsistent with the version of a source code in a coverage rate statistics server.
The embodiment of the invention provides a method for generating a coverage rate report, which comprises the following steps:
acquiring a code of a current version in a code library in a packaging server and version information corresponding to the code;
packaging the codes to generate corresponding test packets, and testing the test packets to generate corresponding coverage rate files;
sending the test packet and the coverage rate file to a coverage rate statistical server;
acquiring version information corresponding to a source code in the coverage rate statistical server and an initial coverage rate file corresponding to the source code, and comparing the version information corresponding to the code with the version information corresponding to the source code;
and if the version information corresponding to the code is the same as the version information corresponding to the source code, generating a coverage report according to the coverage file corresponding to the code and the initial coverage file corresponding to the source code.
An embodiment of the present invention further provides an electronic device, where a coverage report generating system is stored on the electronic device, and the coverage report generating system includes:
the code and version information acquisition module is used for acquiring a code of a current version in a code library in the packaging server and version information corresponding to the code;
the packaging test module is used for packaging the codes to generate a corresponding test package, and testing the test package to generate a corresponding coverage rate file;
the file sending module is used for sending the test packet and the coverage rate file to a coverage rate statistical server;
the version comparison module is used for acquiring version information corresponding to a source code in the coverage rate statistical server and an initial coverage rate file corresponding to the source code, and comparing the version information corresponding to the code with the version information corresponding to the source code;
and if the version information corresponding to the code is the same as the version information corresponding to the source code, the coverage report generating module generates a coverage report according to the coverage file corresponding to the code and the initial coverage file corresponding to the source code.
In some embodiments of the present invention, there may also be provided a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method as described above when executing the computer program.
In some embodiments of the invention, there may also be provided a computer-readable storage medium having stored thereon a computer program which, when run on a computer, causes the computer to perform the steps of the method as described above.
The invention has the beneficial effects that: in the invention, by comparing the version information corresponding to the code in the packaging server with the version information corresponding to the source code in the coverage rate statistical server, when the version information corresponding to the code is the same as the version information corresponding to the source code, a coverage rate report is generated according to the coverage rate file corresponding to the code and the initial coverage rate file corresponding to the source code, and when the version information corresponding to the code is different from the version information corresponding to the source code, the version of the code sent to the coverage rate statistical server is reduced, so that the problem that when a client tests, the pile insertion of the code sent to the coverage rate statistical server is inconsistent with the pile insertion of the source code in the coverage rate statistical server, and the coverage rate detail on the coverage rate statistical server is accessed, the error report cannot be displayed is avoided.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flow chart of a coverage report generation method provided by an embodiment of the present invention;
fig. 2 is a schematic flowchart of step S3 in the coverage report generating method according to the embodiment of the present invention;
fig. 3 is a schematic flowchart of step S5 in the coverage report generating method according to the embodiment of the present invention;
FIG. 4 is a schematic structural diagram of an electronic device according to an embodiment of the invention;
fig. 5 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
The embodiment of the invention provides a coverage rate report generation method and device, computer equipment and a storage medium.
The computer device can be a mobile phone, a tablet computer, a notebook computer and other terminal devices, and also can be a wearable device, a smart television or other intelligent terminals.
The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, middleware service, a domain name service, a security service, a CDN, and a big data and artificial intelligence platform, but is not limited thereto.
The following are detailed below. It should be noted that the following description of the embodiments is not intended to limit the preferred order of the embodiments.
As shown in fig. 1, a coverage report generating method provided in an embodiment of the present invention includes the following steps:
s1, acquiring a code of a current version in a code library in a packaging server and version information corresponding to the code;
generally, after a programmer writes a program, the program is uploaded to a specific code library, and the uploaded program contains the version number of the code and the corresponding commit ID.
The ID in the commit ID refers to a hash value that is a value obtained by logical operation from data of the contents of the file, and hash values obtained for different files (even for the same file name) are different, and the hash value can be used as an identification card for identifying each file.
When the code needs to be tested, the latest code (namely the code of the current version) can be pulled from the code library through a git command, wherein git is an open-source distributed version control system, and various project version management can be effectively processed at high speed.
Taking an installer as an example, since the same version of installer may be modified many times during the development process, and a new version of code is generated every time of modification, there may be multiple versions of code in the code library of the server. Specifically, taking an example that a code of a current version and version information corresponding to the code are obtained from the code library through a git command, and a child process module of nodejs is selected to execute a shell statement, where the shell statement can obtain information related to git, and a method for extracting the code of the current version and the version information corresponding to the code is as follows:
obtaining commit ID: child _ process. Execsync ('gitrev-part HEAD'). ToString (). Trim ();
obtaining git branch information: child _ process. Execsync ('gitrev-part-abbrev-ref HEAD'). ToString (). Trim ();
obtaining the submitter and submission time information of git: execsync (' git log-pretty) Format: "submitter:% cn; commit time:% cd "HEAD-1- -date = format:"% y-% M-% d% H:% M:% S' ") toString ().
Understandably, the git branch information and the commit ID of different versions of the code are different, and the different versions of the code can be distinguished by comparing the git branch information and the commit ID.
S2, packaging the codes to generate corresponding test packets, and testing the test packets to generate corresponding coverage rate files;
in this embodiment, the codes are packaged to generate corresponding test packages, and the codes are compiled to generate compiled files, so that the codes in the test packages can be tested by a tool for testing the code coverage of a program to generate corresponding coverage files.
The compiled file is obtained by instrumentation of the code, the process is called program instrumentation, the program instrumentation is a method for realizing a test purpose by means of insertion operation into a tested program, namely, probes (also called probes) are inserted into the program on the basis of ensuring the original logic integrity of the tested program, the probes are essentially code segments for information acquisition, and can be assignment statements or function calls for acquiring coverage information, and the running characteristic data of the program is output through the execution of the probes. Based on the analysis of these feature data, the internal behavior and features of the program are revealed.
S3, sending the test packet and the coverage rate file to a coverage rate statistical server;
and the coverage rate statistical server can acquire the codes of the current version of the code base in the packaging server and the version information corresponding to the codes according to the received test packet.
The version information corresponding to the code includes git branch information of the code, a version number of the code, and commit ID of the code.
Further, referring to fig. 2, the step S3 may specifically include the following steps:
s31, modifying the project file path of the coverage rate file from an absolute path to a relative path to obtain the coverage rate file with the project file path as the relative path;
and S32, sending the coverage rate file with the test packet and the project file path as the relative path to the coverage rate statistical server.
The absolute path is a path where a file really exists on a hard disk, the relative path is a relative position relative to a certain target file, the item file path of the coverage rate file generated during packaging is an item file path in the packaging server, and if the absolute path of the coverage rate file is/a/b/f, only the item file path of f is reserved.
The coverage rate statistics server can conveniently search the coverage rate file by modifying the project file path of the coverage rate file from an absolute path to a relative path.
S4, acquiring version information corresponding to a source code in the coverage rate statistical server and an initial coverage rate file corresponding to the source code, and comparing the version information corresponding to the code with the version information corresponding to the source code;
if the codes of the versions corresponding to the source codes in the coverage rate statistics server are not completely tested, and developers update the versions of the codes and upload the updated codes to the packaging server for code updating, the versions of the codes of the current versions in the packaging server are higher than the versions of the source codes in the coverage rate statistics server, and if the tests of the codes of the current versions corresponding to the source codes in the coverage rate statistics server are completely finished, testers update the versions of the source codes in the coverage rate statistics server, and update the versions of the source codes to be consistent with the versions of the codes of the current versions in the packaging server, the versions of the codes in the packaging server are the same as the versions of the source codes in the coverage rate statistics server.
Therefore, in this embodiment, after the version information corresponding to the source code in the coverage rate statistics server and the version information corresponding to the current code in the packaging server are obtained, the two version information need to be compared, and different programs are subsequently executed according to the comparison result, so as to avoid that the stub of the code sent to the coverage rate statistics server is inconsistent with the stub of the source code in the coverage rate statistics server, which causes an error in reporting and the coverage rate detail on the coverage rate statistics server cannot be displayed when accessing the coverage rate statistics server.
And S5, if the version information corresponding to the code is the same as the version information corresponding to the source code, generating a coverage rate report according to the coverage rate file corresponding to the code and the initial coverage rate file corresponding to the source code.
Further, referring to fig. 3, the step S5 may specifically include the following steps:
s51, acquiring a corresponding coverage rate value according to the coverage rate file corresponding to the code;
s52, combining the coverage rate value with a coverage rate value in an initial coverage rate file corresponding to the source code to obtain a combined coverage rate value;
and S53, generating a coverage rate report according to the combined coverage rate value.
The coverage values may be merged with the coverage values in the initial coverage file by a merging algorithm, after which a coverage report is generated based on the merged coverage values.
Wherein, the step S51 may specifically include the following steps:
s511, extracting coverage rate objects in the coverage rate file;
s512, traversing the key value pairs of the coverage rate objects to obtain the corresponding coverage rate values.
The coverage rate object comprises an assignment statement in a key-value format, assignment judgment or function call for collecting coverage information.
In this embodiment, the coverage rate files sent to the coverage rate statistics server may all be named by using keys as file names, the coverage rate files may be found by traversing files whose file names are keys, and then the coverage rate objects are extracted from the coverage rate files, where it needs to be noted that the extracted coverage rate objects are some probes inserted when instrumentation is performed on the code, the probes are code segments for performing information acquisition, and operation characteristic data of a program is output through execution of the probes. Based on the analysis of these feature data, the internal behavior and features of the program are revealed.
Key-value pairs (key = value), i.e. each key corresponds to a value, and by traversing the key-value pairs of the coverage object, i.e. by a probe inserted into the code, it is able to know the code segments that have been tested and the code segments that have not been tested, so as to obtain the corresponding coverage values.
And then combining the coverage rate value with a coverage rate value in an initial coverage rate file corresponding to the source code to obtain a combined coverage rate value, and generating a coverage rate report based on the combined coverage rate value.
In this embodiment, if the version information corresponding to the code in the packaging server is different from the version information corresponding to the source code in the coverage statistics server, the current version of the code in the code library in the packaging server is reduced.
Still taking the version of the code in the packaging server as version 10 and the version of the source code in the coverage statistics server as version 9 for example, because the instrumentation code in the test package corresponding to the code of version 10 is different from the instrumentation code in the test package corresponding to the source code of version 9, and the source code on the coverage statistics server is still the code of version 9 at this time, the version of the code sent to the coverage statistics server needs to be reduced from version 10 to version 9, and when the version of the code received at the coverage statistics server is the same as the version of the source code in the coverage statistics server, the test of the code of version 9 is continuously completed.
Understandably, after the test of the code of version 9 is completed, that is, the test proves that the program of the code of version 9 has no fault, the code version of the source code in the coverage rate statistics server is updated to version 10.
In this embodiment, by comparing the version information corresponding to the code in the package server with the version information corresponding to the source code in the coverage rate statistics server, when the version information corresponding to the code is the same as the version information corresponding to the source code, a coverage rate report is generated according to the coverage rate file corresponding to the code and the initial coverage rate file corresponding to the source code, and when the version information corresponding to the code is different from the version information corresponding to the source code, the version of the code sent to the coverage rate statistics server is reduced, so that when a client tests, the phenomenon that the instrumentation of the code sent to the coverage rate statistics server is inconsistent with the instrumentation of the source code in the coverage rate statistics server, which causes an error report and failure to display when the coverage rate details on the coverage rate statistics server are accessed, is avoided.
In order to better implement the above method, correspondingly, an embodiment of the present invention further provides an electronic device, which is specifically integrated in a terminal or a server, and the electronic device stores thereon a coverage report generating system, where the coverage report generating system includes: the following description will specifically describe specific functions of the program modules 100 to 500, where the program modules include a code and version information acquisition module 100, a packaging test module 200, a file transmission module 300, a version comparison module 400, and a coverage report generation module 500.
The code and version information obtaining module 100 is configured to obtain a code of a current version and version information corresponding to the code in a code library in the packaging server.
Generally, after a programmer writes a program, the program is uploaded to a specific code library, and the uploaded program contains the version number of the code and the corresponding commit ID.
The ID in the commit ID refers to a hash value that is a value obtained by logical operation from data of the contents of the file, and hash values obtained for different files (even for the same file name) are different, so the hash value can be used as an identification card for identifying each file.
When the code needs to be tested, the latest code (namely the code of the current version) is pulled from the code library through the git command, because the installation program of the same version can be modified for many times in the development process, and a new version of code is generated after each modification.
Specifically, a code of a current version and version information corresponding to the code can be acquired from the code library through a git command, and meanwhile, a child process module of nodejs is selected to execute a shell statement, wherein the shell statement can acquire information related to git, so that the extraction of the code of the current version and the version information corresponding to the code is realized.
The packaging test module 200 is configured to package the codes to generate corresponding test packages, and test the test packages to generate corresponding coverage files.
And then testing the codes in the test package through a tool for testing the code coverage rate of a program to generate a corresponding coverage rate file.
The compiled file is obtained by instrumentation of the code, the process is called program instrumentation, the program instrumentation is a method for realizing a test purpose by means of insertion operation into a tested program, namely, probes (also called probes) are inserted into the program on the basis of ensuring the original logic integrity of the tested program, the probes are essentially code segments for information acquisition, and can be assignment statements or function calls for acquiring coverage information, and the running characteristic data of the program is output through the execution of the probes. Based on the analysis of these feature data, the internal behavior and features of the program are revealed.
The file sending module 300 is configured to send the test package and the coverage file to a coverage statistics server.
The file sending module 300 includes a file path modifying unit and a file sending unit, where the file path modifying unit is configured to modify a project file path of the coverage file from an absolute path to a relative path, so as to obtain the coverage file with the project file path as the relative path; the file sending unit is used for sending the coverage rate file of which the test packet and the project file path are the relative paths to the coverage rate statistical server.
The absolute path refers to a path actually existing in a file on a hard disk, for example, a picture "bg.jpg" is stored in a directory of a hard disk "E: \ book \ webpage layout code \ chapter 2", that is, the absolute path of the picture "bg.jpg" is "E: \ book \ webpage layout \ code \ chapter 2 \ chapter bg.jpg", and if the background picture of a webpage is specified by using the absolute path, the following statements are required: (body backed = "E: \ book \ web page layout \ code \ Chapter 2 \ bg. Jpg").
In actual webpage programming, the absolute path is rarely used, if the position of the background picture is specified by using 'E: \ book \ webpage distribution \ code \ chapter 2 \ bg. Jpg', browsing on a specified computer is normal, but if the background picture is uploaded to a Web server to be browsed, the background picture cannot be displayed.
To avoid this, it is common to choose to use a relative path, i.e. a position relative to a target document, when specifying a document in a web page.
In this embodiment, the item file path of the coverage file generated during packaging is the item file path in the packaging server, and assuming that the absolute path of the coverage file is/a/b/f, only the item file path of f is reserved.
And modifying the project file path of the coverage rate file from an absolute path to a relative path, so that the coverage rate file is conveniently searched by the coverage rate statistical server.
The version comparison module 400 is configured to obtain version information corresponding to a source code in the coverage statistics server and an initial coverage file corresponding to the source code, and compare the version information corresponding to the code with the version information corresponding to the source code.
The version of the source code in the coverage rate statistics server may be the same as or different from the current version of the code in the packaging server, if the test of the code of the current version is completely completed, the version of the code in the packaging server is the same as the version of the source code in the coverage rate statistics server, and if the test of the code of the current version is not completed, the version of the total code of the packaging server has a version higher than the version of the source code in the coverage rate statistics server.
Therefore, in this embodiment, after the version information corresponding to the source code in the coverage statistics server and the version information corresponding to the current code in the packaging server are obtained, the two version information need to be compared.
The coverage report generating module 500 is configured to generate a coverage report according to the coverage file corresponding to the code and the initial coverage file corresponding to the source code if the version information corresponding to the code is the same as the version information corresponding to the source code.
The coverage report generating module 500 includes a coverage value obtaining unit, a coverage value combining unit, and a coverage report generating unit, where the coverage value obtaining unit is configured to obtain a corresponding coverage value according to the coverage file corresponding to the code; the coverage rate combining unit is configured to combine the coverage rate value with a coverage rate value in an initial coverage rate file corresponding to the source code to obtain a combined coverage rate value, and the coverage rate report generating unit is configured to generate a coverage rate report according to the combined coverage rate value.
The coverage value may be merged with the coverage value in the initial coverage file by a merging algorithm.
Further, in this embodiment, if the version information corresponding to the code in the packaging server is different from the version information corresponding to the source code in the coverage statistics server, the current version of the code in the code library in the packaging server is reduced.
Still taking the version of the code in the packaging server as version 10, and the version of the source code in the coverage statistics server as version 9 for example, because the instrumentation code in the test package corresponding to the code of version 10 is different from the instrumentation code in the test package corresponding to the source code of version 9, and the source code on the coverage statistics server is still the code of version 9 at this time, the version of the code sent to the coverage statistics server needs to be reduced from version 10 to version 9, and when the version of the code received at the coverage statistics server is the same as the version of the source code in the coverage statistics server, the test on the code of version 9 is continuously completed.
In addition, an embodiment of the present invention further provides a computer device, where the computer device may be a terminal or a server, as shown in fig. 5, which shows a schematic structural diagram of a computer device according to an embodiment of the present invention, and specifically:
the computer device may include components such as a processor 401 of one or more processing cores, memory 402 of one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that the computer device configuration illustrated in FIG. 4 does not constitute a limitation of computer devices, and may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components. Wherein:
the processor 401 is a control center of the computer device, connects various parts of the entire computer device using various interfaces and lines, and performs various functions of the computer device and processes data by running or executing software programs and/or modules stored in the memory 402 and calling data stored in the memory 402, thereby monitoring the computer device as a whole. Alternatively, processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications and data processing by operating the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 access to the memory 402.
The computer device further comprises a power supply 403 for supplying power to the various components, and preferably, the power supply 403 is logically connected to the processor 401 via a power management system, so that functions of managing charging, discharging, and power consumption are implemented via the power management system. The power supply 403 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
The computer device may also include an input unit 404, and the input unit 404 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
Although not shown, the computer device may further include a display unit and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 401 in the computer device loads the executable file corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 runs the application programs stored in the memory 402, thereby implementing various functions as follows:
acquiring a code of a current version in a code library in a packaging server and version information corresponding to the code;
packaging the codes to generate corresponding test packets, and testing the test packets to generate corresponding coverage rate files;
sending the test packet and the coverage rate file to a coverage rate statistical server;
acquiring version information corresponding to a source code in the coverage rate statistical server and an initial coverage rate file corresponding to the source code, and comparing the version information corresponding to the code with the version information corresponding to the source code;
and if the version information corresponding to the code is the same as the version information corresponding to the source code, generating a coverage rate report according to the coverage rate file corresponding to the code and the initial coverage rate file corresponding to the source code.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, the embodiment of the present invention further provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the method provided in various optional implementation manners in the embodiment of the present invention.
According to an aspect of the application, there is also provided a computer program product or a computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method provided in the various alternative implementations in the embodiments described above.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Wherein the storage medium may include: read Only Memory (ROM), random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the storage medium may execute the steps in the coverage report generating method provided in the embodiment of the present invention, beneficial effects that can be achieved by the coverage report generating method provided in the embodiment of the present invention may be achieved, for which details are given in the foregoing embodiments and are not described herein again.
The coverage rate report generating method, apparatus, computer device and storage medium provided by the embodiments of the present invention are described in detail above, and a specific example is applied in the present disclosure to explain the principle and the implementation of the present invention, and the description of the above embodiments is only used to help understanding the method and the core idea of the present invention; meanwhile, for those skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A method for generating a coverage report, comprising the steps of:
acquiring a code of a current version in a code library in a packaging server and version information corresponding to the code;
packaging the codes to generate corresponding test packets, and testing the test packets to generate corresponding coverage rate files;
sending the test packet and the coverage rate file to a coverage rate statistical server;
acquiring version information corresponding to a source code in the coverage rate statistical server and an initial coverage rate file corresponding to the source code, and comparing the version information corresponding to the code with the version information corresponding to the source code;
and if the version information corresponding to the code is the same as the version information corresponding to the source code, generating a coverage report according to the coverage file corresponding to the code and the initial coverage file corresponding to the source code.
2. The method of claim 1, wherein the step of sending the test package and the coverage file to a coverage statistics server comprises:
modifying the project file path of the coverage rate file from an absolute path to a relative path to obtain the coverage rate file with the project file path as the relative path;
and sending the coverage rate file with the test packet and the project file path as the relative path to the coverage rate statistical server.
3. The method of claim 2, wherein the step of generating a coverage report from the coverage file corresponding to the code and the initial coverage file corresponding to the source code comprises:
acquiring a corresponding coverage rate value according to the coverage rate file corresponding to the code;
combining the coverage value with a coverage value in an initial coverage file corresponding to the source code to obtain a combined coverage value;
and generating a coverage rate report according to the combined coverage rate value.
4. The method according to claim 3, wherein the step of obtaining the corresponding coverage value according to the coverage file corresponding to the code comprises:
extracting a coverage rate object in the coverage rate file;
and traversing the key value pair of the coverage rate object to obtain the corresponding coverage rate value.
5. The coverage report generation method of claim 4, wherein the coverage object comprises an assignment statement in a key-value format, an assignment decision, or a function call to collect coverage information.
6. The coverage report generation method of claim 1, wherein the version information corresponding to the code comprises a version number of the code and a corresponding commit ID.
7. The method of claim 1, wherein if the version information corresponding to the code in the packaging server is different from the version information corresponding to the source code in the coverage statistics server, then reducing the current version of the code in the code library in the packaging server.
8. An electronic device having a coverage report generating system stored thereon, the coverage report generating system comprising:
the code and version information acquisition module is used for acquiring a code of a current version in a code library in the packaging server and version information corresponding to the code;
the packaging test module is used for packaging the codes to generate a corresponding test package, and testing the test package to generate a corresponding coverage rate file;
the file sending module is used for sending the test packet and the coverage rate file to a coverage rate statistical server;
the version comparison module is used for acquiring version information corresponding to a source code in the coverage rate statistical server and an initial coverage rate file corresponding to the source code, and comparing the version information corresponding to the code with the version information corresponding to the source code;
and if the version information corresponding to the code is the same as the version information corresponding to the source code, the coverage report generating module generates a coverage report according to the coverage file corresponding to the code and the initial coverage file corresponding to the source code.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the computer program implements the steps of the coverage report generation method according to any of the claims 1 to 7.
10. A computer-readable storage medium, having stored thereon a computer program, for causing a computer to perform the steps of the coverage report generating method according to any of claims 1 to 7, when the computer program is run on the computer.
CN202211379668.2A 2022-11-04 2022-11-04 Coverage rate report generation method and device, storage medium and computer equipment Pending CN115687129A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211379668.2A CN115687129A (en) 2022-11-04 2022-11-04 Coverage rate report generation method and device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211379668.2A CN115687129A (en) 2022-11-04 2022-11-04 Coverage rate report generation method and device, storage medium and computer equipment

Publications (1)

Publication Number Publication Date
CN115687129A true CN115687129A (en) 2023-02-03

Family

ID=85050694

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211379668.2A Pending CN115687129A (en) 2022-11-04 2022-11-04 Coverage rate report generation method and device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN115687129A (en)

Similar Documents

Publication Publication Date Title
CN113127347B (en) Interface testing method, device, equipment and readable storage medium
CN111026647B (en) Method and device for acquiring code coverage rate, computer equipment and storage medium
CN110858172A (en) Automatic test code generation method and device
CN114116496A (en) Automatic testing method, device, equipment and medium
CN111240955A (en) Automatic testing method and device for Http interface, storage medium and electronic device
CN103186463B (en) Determine the method and system of the test specification of software
CN115080398A (en) Automatic interface test system and method
CN113590454A (en) Test method, test device, computer equipment and storage medium
CN115576600A (en) Code change-based difference processing method and device, terminal and storage medium
US20190220549A1 (en) Analysis model preparing system, programming apparatus, and analysis model preparing method
CN109582347B (en) Method and device for acquiring front-end codes
CN116578282A (en) Code generation method, device, electronic equipment and medium
CN111666201A (en) Regression testing method, device, medium and electronic equipment
CN112463574A (en) Software testing method, device, system, equipment and storage medium
CN115687129A (en) Coverage rate report generation method and device, storage medium and computer equipment
CN113220586A (en) Automatic interface pressure test execution method, device and system
CN115964061A (en) Plug-in updating method and device, electronic equipment and computer readable storage medium
CN115129355B (en) Page repair method, system and computer equipment thereof
CN113656044B (en) Android installation package compression method and device, computer equipment and storage medium
CN117235107B (en) Data access processing method and device, electronic equipment and storage medium
CN117130945B (en) Test method and device
CN112363870B (en) Application program development processing method and device, computer equipment and storage medium
CN111324542B (en) Web application regression test case selection system, method and equipment
CN110309038B (en) Performance test method and device, electronic equipment and computer readable storage medium
CN117950991A (en) Program testing method, device, electronic equipment and computer readable storage medium

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