CN111078549B - Code coverage rate processing method and device and computer equipment - Google Patents

Code coverage rate processing method and device and computer equipment Download PDF

Info

Publication number
CN111078549B
CN111078549B CN201911244449.1A CN201911244449A CN111078549B CN 111078549 B CN111078549 B CN 111078549B CN 201911244449 A CN201911244449 A CN 201911244449A CN 111078549 B CN111078549 B CN 111078549B
Authority
CN
China
Prior art keywords
code
file
branch
difference
type
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.)
Active
Application number
CN201911244449.1A
Other languages
Chinese (zh)
Other versions
CN111078549A (en
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.)
Guangzhou Pinwei Software Co Ltd
Original Assignee
Guangzhou Pinwei Software 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 Guangzhou Pinwei Software Co Ltd filed Critical Guangzhou Pinwei Software Co Ltd
Priority to CN201911244449.1A priority Critical patent/CN111078549B/en
Publication of CN111078549A publication Critical patent/CN111078549A/en
Application granted granted Critical
Publication of CN111078549B publication Critical patent/CN111078549B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/3692Test management for test results analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application relates to a code coverage rate processing method, a device, a computer device and a storage medium, wherein the method comprises the following steps: acquiring a second source code of a second version of the test application program to obtain a difference code branch of the first type of file relative to a first source code of a first version of the test application program in the second type of file; obtaining second subcode coverage data of the difference code branch and third subcode coverage data other than the second subcode coverage data from a code coverage data file of the second source code; obtaining first subcode coverage data from a code coverage data file of the first source code, excluding code coverage data corresponding to the differential code branches; and combining the first subcode coverage rate data and the third subcode coverage rate data to obtain fourth subcode coverage rate data, and generating a third code coverage rate data file according to the second subcode coverage rate data and the fourth subcode coverage rate data. The method can reduce code repetition test.

Description

Method and device for processing code coverage rate and computer equipment
Technical Field
The present application relates to the field of software testing technologies, and in particular, to a method and an apparatus for processing code coverage, a computer device, and a storage medium.
Background
In software testing, statistics of code coverage for software testing procedures are often required. Code coverage characterizes how much code can be covered in a test. Generally, a software tester determines whether to repeatedly execute a software test according to the code coverage rate.
In the current software test, the release version of an application consists of N measurable small versions. That is, for each externally published version, a developer may submit multiple small versions of a software development kit to the server. However, because the identification codes of the compiled products of each submitted small version are different after the software test, the code coverage rate data obtained in the test process among the small versions cannot be directly merged. If the coverage rate data among the small versions cannot be combined, repeated tests are easily caused by directly referring to the code coverage rate data of the current small version. For example, the current small version and the previous small version both contain a code that has been tested to cover the previous version but has not been tested to cover the current small version, and the code coverage data referring to the current small version needs to be retested, thereby causing the code to be retested.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a processing method, an apparatus, a computer device, and a storage medium capable of merging code coverage data of multiple versions of an application in an appropriate amount to reduce code coverage of a code retest.
A method for processing code coverage, the method comprising: acquiring a second type of file compiled when a second source code of a second version of the application program is tested and a first type of file compiled when a first source code of a first version of the application program is tested, and acquiring a differential code branch which is different in the second type of file relative to the first type of file; acquiring a second code coverage rate data file generated when a second source code is tested according to the second type file, and acquiring second subcode coverage rate data and third subcode coverage rate data, wherein the second subcode coverage rate data is code coverage rate data corresponding to different code branches in the second code coverage rate data file, and the third subcode coverage rate data is code coverage rate data except the second subcode coverage rate data in the second code coverage rate data file; acquiring a first code coverage rate data file generated when a first source code is tested according to a first type of file, and screening first sub-code coverage rate data except code coverage rate data of a difference code branch mapped in the first code coverage rate data file from the first code coverage rate data file; and merging the first sub-code coverage rate data and the third sub-code coverage rate data to obtain merged fourth sub-code coverage rate data, and generating a third code coverage rate data file of a second version of the application program according to the second sub-code coverage rate data and the fourth sub-code coverage rate data.
In one embodiment, the method for processing code coverage further includes: code difference information of a second source code of the second version of the application program relative to a first source code of the first version of the application program is obtained; acquiring a difference code branch which is different in the second type of files relative to the first type of files, wherein the difference code branch comprises the following steps: and determining the different code branches in the second type files which are different from the first type files according to the code difference information.
In one embodiment, determining the differential code branch in the second type of file that is different from the first type of file according to the code difference information includes: acquiring a difference method name, a difference code branch name and/or a label of a difference code which is different from the first type file in the second type file according to the code difference information; if the difference method name exists, acquiring a first difference method which is different in the second type of files relative to the first type of files according to the difference method name, and determining a difference code branch which is different in the second type of files relative to the first type of files according to the first difference method; if the difference code branch name exists, determining the difference code branch which is different in the second type of file relative to the first type of file according to the difference code branch name; if the label of the difference code exists, a first difference code which is different from the first type of file in the second type of file is obtained according to the label of the difference code, and a difference code branch which is different from the first type of file in the second type of file is determined according to the first difference code.
In one embodiment, the method for processing code coverage further includes: if the difference code branch name and the difference method name exist at the same time, a second difference method which is different from the first type file in the second type file is obtained according to the difference method name, a first target code branch which is different from the first type file in the second type file is obtained according to the second difference method, a second target code branch which is different from the first type file in the second type file is obtained according to the difference code branch name, the second target code branch is used as the difference code branch when the first target code branch is matched with the second target code branch, and the second target code branch and the first target code branch are both used as the difference code branch when the first target code branch is not matched with the second target code branch; if the difference code branch name and the label number of the difference code exist at the same time, a second difference code which is different from the first type file in the second type file is obtained according to the label number of the difference code, a third target code branch which is different from the first type file in the second type file is obtained according to the second difference code, a fourth target code branch which is different from the first type file in the second type file is obtained according to the difference code branch name, the fourth target code branch is used as the difference code branch when the third target code branch is matched with the fourth target code branch, and the fourth target code branch and the third target code branch are both used as the difference code branch when the third target code branch is not matched with the fourth target code branch.
In one embodiment, generating a third code coverage data file for a second version of the application program based on the second subcode coverage data and the fourth subcode coverage data comprises: determining a first code branch which is covered by the test and a second code branch which is not covered by the test in the second type file according to the fourth subcode coverage rate data; if the difference code branch is determined to be covered by the test according to the second subcode coverage rate data, acquiring a code branch covered by the test and a code branch not covered by the test in the second version of the application program according to a determination result of the second subcode coverage rate data and a determination result of the fourth subcode coverage rate data, counting the code coverage rate of the code branch corresponding to the second version of the application program according to the code branch covered by the test and the code branch not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the code branch; if the difference code branch is determined not to be covered by the test according to the second sub-code coverage data, obtaining the code branch covered by the test and the code branch not covered by the test in the second version of the application program according to the determination result of the second sub-code coverage data and the determination result of the fourth sub-code coverage data, counting the code coverage of the code branch corresponding to the second version of the application program according to the code branch covered by the test and the code branch not covered by the test, and generating a third code coverage data file of the second version of the application program according to the code coverage of the code branch.
In one embodiment, the method for processing the code coverage further includes: acquiring a code source file of a second version of the application program according to the second type file; a code coverage report for the second version of the application is generated based on the third code coverage data file and the code source file.
In one embodiment, generating a code coverage report for a second version of an application from a third code coverage data file and a code source file comprises: marking codes covered by testing and codes not covered by testing in the code source file according to the second subcode coverage data and the fourth subcode coverage data; generating a code coverage report of a second version of the application program according to the marked code source file and the third code coverage data file; and/or marking the difference codes in the code source file according to the code difference information; a code coverage report for the second version of the application is generated based on the marked code source file and the third code coverage data file.
An apparatus for processing code coverage, the apparatus comprising: the first acquisition module is used for acquiring a second type of file obtained by compiling when testing a second source code of a second version of the application program and a first type of file obtained by compiling when testing a first source code of a first version of the application program, and acquiring a difference code branch which is different in the second type of file relative to the first type of file; a second obtaining module, configured to obtain, according to the second type of file, a second code coverage data file generated when the second source code is tested, and obtain second subcode coverage data and third subcode coverage data, where the second subcode coverage data is code coverage data corresponding to a difference code branch in the second code coverage data file, and the third subcode coverage data is code coverage data in the second code coverage data file except the second subcode coverage data; the third acquisition module is used for acquiring a first code coverage rate data file generated when the first source code is tested according to the first type of file, and screening first sub-code coverage rate data except code coverage rate data of the difference code branch mapped in the first code coverage rate data file from the first code coverage rate data file; and the generating module is used for merging the first subcode coverage rate data and the third subcode coverage rate data to obtain merged fourth subcode coverage rate data, and generating a second-version third code coverage rate data file of the application program according to the second subcode coverage rate data and the fourth subcode coverage rate data.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the method of any of the above embodiments when executing the computer program.
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 of the above embodiments.
According to the code coverage rate processing method, the code coverage rate processing device, the computer equipment and the storage medium, the server obtains the different code branches which are different in the second type of files of the second version of the application program relative to the first type of files of the first version of the application program, obtains the second code coverage rate data file generated when the second source code is tested according to the second type of files, and obtains the second subcode coverage rate data corresponding to the different code branches from the second code coverage rate data file, so that the code coverage rate data condition of the code branches of the second version of the application program, which is changed relative to the first version, can be determined, namely the code coverage rate data condition of the different code branches. Meanwhile, the server acquires a first code coverage rate data file generated when a first source code is tested according to the first type of file, screens out first sub-code coverage rate data except code coverage rate data of a difference code branch mapped in the first code coverage rate data file from the first code coverage rate data file, and combines the first sub-code coverage rate data and third sub-code coverage rate data, so that combination of code coverage rate data except non-difference code branches is realized. And finally, generating a second version third code coverage data file of the application program according to the fourth subcode coverage data obtained after the merging processing and the second subcode coverage data corresponding to the difference code branch. Therefore, the server can respectively obtain the code coverage rate data of the two versions according to the class files in the compilation products of the two versions of the application program to carry out corresponding data merging, and simultaneously generate a third code coverage rate data file of the second version according to the merged data and the code coverage rate data corresponding to different version difference code branches.
Drawings
FIG. 1 is a diagram of an application environment for a method of processing code coverage in one embodiment;
FIG. 2 is a flowchart of a method for processing code coverage in one embodiment;
FIG. 3 is a block diagram of an apparatus for processing code coverage in one embodiment;
FIG. 4 is a diagram of the internal structure of a computer device in one 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 and not restrictive on the broad application.
The application provides a processing method of code coverage rate, which is applied to an application environment as shown in fig. 1. The terminal 16 uploads development kits of versions of the application program to the server 12 through network connection, and the development kits include source codes of the application program. The development kits of each version uploaded by the terminal 16 include a plurality of development kits of small versions of the same version. After receiving the development kit of the application program uploaded by the terminal 16, the server 12 stores the development kit in the database 14. The terminal 18 requests the server 12 for a development kit for the application over the network connection to perform software testing on the development kit. Meanwhile, after the terminal 18 executes the software test, the test product obtained by the test application is sent back to the server 12. The test product includes compiled products obtained from each test, such as class files and the like. Server 12 stores the test products submitted by terminal 18 in database 14. When executing the code coverage processing method of the present application, the server 12 obtains, from the database 14, a second type file compiled when testing the second source code of the second version of the application program and a first type file compiled when testing the first source code of the first version of the application program, and obtains a difference code branch in the second type file that is different from the difference code branch in the first type file. Further, a second code coverage data file generated when the second source code is tested is obtained from the database 14 according to the second type file, second sub-code coverage data corresponding to the difference code branch and third sub-code coverage data except the second sub-code coverage data in the second code coverage data file are obtained from the second code coverage data file, and a first code coverage data file generated when the first source code is tested is obtained according to the first type file, and first sub-code coverage data except the code coverage data mapped in the first code coverage data file by the difference code branch is screened from the first code coverage data file. And finally, merging the first subcode coverage rate data and the third subcode coverage rate data to obtain merged fourth subcode coverage rate data, and generating a second-version third code coverage rate data file of the application program according to the second subcode coverage rate data and the fourth subcode coverage rate data. The terminals 16 and 18 may be computer devices such as a notebook computer and a desktop computer. The server 12 may also be implemented as a server cluster consisting of a plurality of servers.
The present application provides a method for processing code coverage, which is applied to the server 12 shown in fig. 1 as an example. As shown in fig. 2, the method for processing code coverage includes the following steps:
s102, a second type file obtained by compiling when testing a second source code of a second version of the application program and a first type file obtained by compiling when testing a first source code of a first version of the application program are obtained, and a difference code branch which is different in the second type file relative to the first type file is obtained.
In this embodiment, when the test terminal tests the second source code of the second version of the application program, the second type of file, i.e., the class file, obtained after compiling in the test process is uploaded to the server. Similarly, when the test terminal tests the first source code of the first version of the application program, the first type of file, namely the class file, obtained after compiling in the test process is uploaded to the server. The two test terminals may be the same terminal or different terminals. Wherein the second version of the application may be the current version as a commit. The first version of the application may be any version previously submitted, such as a previous version relative to the current version. The server acquires the different code branches in the second type of files which are different from the first type of files. In a specific implementation process, the server may read all code branches in the second type of file and all code branches in the first type of file, respectively. And comparing the code branches corresponding to the first class of files one by one, and determining the different code branches in the second class of files which are different from the first class of files. For example, assume that all code branches in the second type of file include code branch m, code branch n, and code branch s, and all code branches in the first type of file include code branch m, code branch n, code branch s, and code branch l. At this time, the differential code in the second type file, which is different from the first type file, is branched into a code branch l.
S104, a second code coverage rate data file generated when a second source code is tested is obtained according to the second type file, and second subcode coverage rate data and third subcode coverage rate data are obtained, wherein the second subcode coverage rate data are code coverage rate data corresponding to different code branches in the second code coverage rate data file, and the third subcode coverage rate data are code coverage rate data except the second subcode coverage rate data in the second code coverage rate data file.
In this embodiment, when the test terminal tests the second source code, the second code coverage data file, that is, the ec file, generated in the test process is uploaded to the server. At this time, in the server, the ec file corresponding to the second source code is associated with the second type file, i.e., the class file, corresponding to the second source code. The corresponding ec file can be read out through the class file. And the server acquires second subcode coverage data corresponding to the difference code branches from the second code coverage data file, acquires data except the second subcode coverage data in the second code coverage data file, and takes the data except the second subcode coverage data as third subcode coverage data. That is, the server divides the second code coverage data file corresponding to the second source code into two parts of data, one part of data is second subcode coverage data corresponding to the difference code branch, and the other part of data is data except the second subcode coverage data.
S106, acquiring a first code coverage rate data file generated when a first source code is tested according to the first type of file, and screening first sub-code coverage rate data except code coverage rate data of the first code coverage rate data file mapped in the first code coverage rate data file by the difference code branches.
In this embodiment, when the test terminal tests the first source code, the first code coverage data file, that is, the ec file, generated in the test process is uploaded to the server. At this time, in the server, the ec file corresponding to the first source code is associated with the class file, which is the first type file corresponding to the first source code. The corresponding ec file can be read out through the class file. The server screens the first subcode coverage data from the first code coverage data file except for code coverage data where the difference code branches map in the first code coverage data file. That is, the server divides the first code coverage data file corresponding to the first source code into two parts of data. A portion of the data is code coverage data in the first code coverage data file to which the differential code branch corresponding to the first source code is mapped. For example, a differential code branch is a code branch where the second version is increased relative to the first version, where the code coverage data mapped into the first code coverage data file is zero. If the difference code branch is a code branch of which the second version is modified relative to the first version, the code coverage data mapped into the first code coverage data file is the code coverage data corresponding to the code branch before the first version is modified. Another portion of the data is data other than the code coverage data mapped in the first code coverage data file.
And S108, merging the first subcode coverage rate data and the third subcode coverage rate data to obtain merged fourth subcode coverage rate data, and generating a second-version third code coverage rate data file of the application program according to the second subcode coverage rate data and the fourth subcode coverage rate data.
In this embodiment, the server performs merging processing on the first subcode coverage data and the third subcode coverage data to obtain merged fourth subcode coverage data. That is, the server merges the data between the second version and the first version except the code coverage data corresponding to the differential code branch. The merging may be performed in such a manner that when the same code is displayed as test coverage in any data corresponding to the first subcode coverage data and the third subcode coverage data, the code is displayed as test coverage in the merged fourth subcode coverage data. When the same code shows that both the first subcode coverage data and the third subcode coverage data correspond to the data which are not tested to be covered, the code shows that the code does not test to be covered in the merged fourth subcode coverage data. For example, code branch a is included in both the first and second versions, except for the difference code branch. And if the code branch a is displayed as untested coverage in the data corresponding to the first subcode coverage data and the third subcode coverage data, the code branch a is displayed as untested coverage in the merged fourth subcode coverage data. The code branch a displays tested coverage in any data corresponding to the first subcode coverage data and the third subcode coverage data, and may display tested coverage in the data of the first subcode coverage data or display tested coverage in the data of the third subcode coverage data, and then displays tested coverage in the merged fourth subcode coverage data. Therefore, the fourth subcode coverage rate data obtained after merging can accurately reflect the test conditions of other source codes except the test conditions of the source codes corresponding to the different code branches, and avoid repeated tests of other source codes.
Further, the server generates a third code coverage data file for the second version of the application program based on the second subcode coverage data and the fourth subcode coverage data. That is, the server generates the third code coverage data file of the second version of the application program according to the second sub-code coverage data corresponding to the difference code branch and the fourth sub-code coverage data obtained by merging the other data between the second version and the first version except the code coverage data corresponding to the difference code branch. Therefore, the finally generated third code coverage rate data file can more accurately reflect the coverage rate condition of the code testing process of the source code in the second version of the application program.
In the method for processing the code coverage rate, the server obtains the different code branches which are different in the second type file of the second version of the application program relative to the first type file of the first version of the application program, obtains the second code coverage rate data file generated when the second source code is tested according to the second type file, and obtains the second subcode coverage rate data corresponding to the different code branches from the second code coverage rate data file, so that the code coverage rate data condition of the code branch of the second version of the application program changed relative to the first version, namely the code coverage rate data condition of the different code branches can be determined. Meanwhile, the server obtains a first code coverage rate data file generated when testing the first source code according to the first type of file, screens out first sub-code coverage rate data except code coverage rate data of a difference code branch mapped in the first code coverage rate data file from the first code coverage rate data file, and combines the first sub-code coverage rate data and third sub-code coverage rate data, so that combination of code coverage rate data except non-difference code branches is realized. And finally, generating a third code coverage rate data file of a second version of the application program according to the fourth sub-code coverage rate data obtained after the merging processing and the second sub-code coverage rate data corresponding to the difference code branch. Therefore, the server can respectively obtain the code coverage rate data of the two versions according to the class file in the compilation product of the two versions of the application program to carry out corresponding data combination, and simultaneously generate a third code coverage rate data file of the second version according to the combined data and the code coverage rate data corresponding to the different version difference code branches.
In an embodiment, before step S102, the method further includes the steps of: code difference information of a second source code of the second version of the application program relative to a first source code of the first version of the application program is obtained. In step S102, obtaining a difference code branch in the second type of file that is different from the first type of file includes: and determining the different code branches in the second type files which are different from the first type files according to the code difference information.
Each time a test terminal for executing a software test submits a test product to a server, it contains identification information for identifying the test product that is submitted at the time. Each time a development terminal for developing an application submits a development kit to a server, the development terminal contains identification information for identifying the development kit that is submitted at the time. And the server generates an identification list according to the identification information submitted by the test terminal and the development terminal, and the identification list is used for recording the submission records of all the terminals. In this embodiment, the server obtains the second source code of the second version of the application program and the first source code of the first version of the application program according to the identification information in the identification list. Further, the server will obtain code difference information for the second version of the second source code relative to the first version of the first source code for the application. The code difference information may include a code that is different from the first source code in the second source code. The distinguished code may be a new code, a code modified on the basis of the first source code. And determining the different code branches in the second type files which are different from the first type files according to the different codes.
In a specific implementation process, a git diff command may be used to obtain a diff log (difference log) of the second source code and the first source code, and code difference information may be determined from the diff log. Specifically, the server obtains the identification numbers of all submitted records of the current version a relative to the last version B, and generates an identification list. For example, the test terminal submits a plurality of small versions of the current version A to the server, and each small version corresponds to an identification number. The identification number of the current version A comprises a1, a2, a3, a 8230, an and other identification numbers, the server acquires the identification number B of the last submitted version of the last version B and a plurality of identification numbers a1, a2, a3, a 8230, a 8230and an of the current version A, and an identification list is generated. The list of identifications can be expressed as commissions [ b1, a2, a3, 8230; an ]. committids identifies the list name. At this time, the server acquires the second source code and the first source code respectively through the identification numbers of the second version and the first version in the commit according to the identification number of the second version and the identification number of the first version in the commit. The identification number corresponding to each submitted small version can be identified by a hash value so as to uniquely identify the corresponding version. Further, a git diff command is adopted to obtain a diff log (difference log) of the second source code and the first source code, the diff log is further analyzed, a diff (difference) marking file for script recognition is generated, and code difference information between the first source code and the second source code is recorded by the diff marking file. Furthermore, the first source code and the second source code may be any two versions of corresponding source code. In a specific implementation, the first source code and the second source code are source code between two previous and next versions. The diff flag file may record code difference information between the previous and next versions.
In one embodiment, determining a differential code branch in the second type of file that is different from the first type of file according to the code difference information includes: acquiring a difference method name, a difference code branch name and/or a label of a difference code which is different from the first type file in the second type file according to the code difference information; if the difference method name exists, acquiring a first difference method which is different in the second type of files relative to the first type of files according to the difference method name, and determining a difference code branch which is different in the second type of files relative to the first type of files according to the first difference method; if the difference code branch name exists, determining the difference code branch which is different in the second type of file relative to the first type of file according to the difference code branch name; if the label of the difference code exists, acquiring a first difference code which is different in the second type of file relative to the first type of file according to the label of the difference code, and determining a difference code branch which is different in the second type of file relative to the first type of file according to the first difference code.
In this embodiment, the code difference information obtained by the server according to the second source code of the second version of the application program and the first source code of the first version of the application program may include a difference method name indicating that the second source code is different from the first source code. For example, a method s is added to the second source code, the server obtains the method name of the method s included in the code difference information, and at this time, the method name of the method s can be used to determine a different method name in the second type file that is different from the first type file, so as to determine a difference code branch in the second type file. The code difference information may also include a difference code branch name that characterizes a difference in the second source code relative to the first source code. And the differential code branch which is different in the second type file relative to the first type file can be directly determined according to the differential code branch name. The code difference information may further include a difference line code number that characterizes a difference code that is different in the second source code from the first source code. For example, the second source code modifies the line code k, the server obtains a difference line code label of the line code k, and then determines a difference code which is different in the second type of file relative to the first type of file according to the difference line code label, thereby determining a difference code branch in the second type of file. Therefore, the difference code branches in the second type of files can be quickly acquired in multiple ways.
In one embodiment, after obtaining the difference method name, the difference code branch name and/or the label of the difference code that is different in the second type of file relative to the first type of file according to the code difference information, the method further includes: if the difference code branch name and the difference method name exist at the same time, a second difference method which is different from the first type file in the second type file is obtained according to the difference method name, a first target code branch which is different from the first type file in the second type file is obtained according to the second difference method, a second target code branch which is different from the first type file in the second type file is obtained according to the difference code branch name, the second target code branch is used as a difference code branch when the first target code branch is matched with the second target code branch, and the second target code branch and the first target code branch are both used as difference code branches when the first target code branch is not matched with the second target code branch; if the difference code branch name and the label number of the difference code exist at the same time, a second difference code which is different from the first type file in the second type file is obtained according to the label number of the difference code, a third target code branch which is different from the first type file in the second type file is obtained according to the second difference code, a fourth target code branch which is different from the first type file in the second type file is obtained according to the difference code branch name, the fourth target code branch is used as the difference code branch when the third target code branch is matched with the fourth target code branch, and the fourth target code branch and the third target code branch are both used as the difference code branch when the third target code branch is not matched with the fourth target code branch.
In this embodiment, if a difference code branch name and a difference method name exist in the second type of file determined by the code difference information, relative to the first type of file, a first target code branch corresponding to the second difference method is obtained according to the difference code branch name, and a second target code branch corresponding to the second difference method is obtained according to the difference code branch name. When the first target code branch is matched with the second target code branch, the difference code branch corresponding to the difference code branch name belongs to the difference method corresponding to the difference method name, and at the moment, the second target code branch corresponding to the difference code branch name is taken as the difference code branch. When the first target code branch and the second target code branch are not matched, the difference code branch corresponding to the difference code branch name does not belong to the difference method corresponding to the difference method name, and at the moment, the first target code branch and the second target code branch are both the difference code branches. In addition, if a difference code branch name and a difference code label exist in the second type of file relative to the first type of file determined by the code difference information, a third target code branch of the corresponding second difference code is obtained according to the difference code label, and a corresponding fourth target code branch is obtained according to the difference code branch name. When the third target code branch is matched with the fourth target code branch, it is described that the second difference code corresponding to the label number of the difference code belongs to the difference code branch corresponding to the difference code branch name, and at this time, the fourth target code branch corresponding to the difference code branch name is taken as the difference code branch. When the third target code branch and the fourth target code branch are not matched, the second difference code corresponding to the label of the difference code does not belong to the difference code branch corresponding to the difference code branch name, and at this time, the fourth target code branch and the third target code branch are both taken as the difference code branch. Therefore, the difference code branches in the second type file can be quickly acquired in various ways.
In one embodiment, generating a third code coverage data file for the second version of the application program from the second subcode coverage data and the fourth subcode coverage data in step S108 includes: determining a first code branch which is covered by the test and a second code branch which is not covered by the test in the second type file according to the fourth subcode coverage rate data; if the difference code branch is determined to be covered by the test according to the second subcode coverage rate data, acquiring a code branch covered by the test and a code branch not covered by the test in the second version of the application program according to a determination result of the second subcode coverage rate data and a determination result of the fourth subcode coverage rate data, counting the code coverage rate of the code branch corresponding to the second version of the application program according to the code branch covered by the test and the code branch not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the code branch; if the difference code branch is determined not to be covered by the test according to the second subcode coverage rate data, obtaining the code branch covered by the test and the code branch method not covered by the test in the second version of the application program according to the determination result of the second subcode coverage rate data and the determination result of the fourth subcode coverage rate data, counting the code coverage rate of the corresponding code branch method of the second version of the application program according to the code branch method covered by the test and the code branch method not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the code branch.
In this embodiment, the second subcode coverage data corresponding to the difference code branch in the second type of file may determine that the difference code branch has been covered by the test, or the second subcode coverage data corresponding to the difference code branch in the second type of file may determine that the difference code branch has not been covered by the test. The fourth subcode coverage data may determine a first code branch in the second class of files that has been covered by the test and a second code branch that has not been covered by the test. That is, no matter the condition that the differential code branch is covered by the test or the condition that the differential code branch is not covered by the test is judged according to the second subcode coverage data corresponding to the differential code branch in the second type of file, the tested code branch and the code branch which is not tested in the second version of the application program can be determined according to the second subcode coverage data and the fourth subcode coverage data, so that the code coverage of the code branch corresponding to the second version of the application program is counted according to the code branch which is covered by the test and the code branch which is not covered by the test in the second version of the application program, and the third code coverage data file of the second version of the application program is generated according to the code coverage of the code branch corresponding to the second version. Therefore, the third code coverage data file can truly reflect the code coverage condition of the code branch of the second version of the application program in the process of executing the code test.
In one embodiment, after step S108, the method further includes: acquiring a code source file of a second version of the application program according to the second type file; a code coverage report for the second version of the application is generated based on the third code coverage data file and the code source file.
In this embodiment, the code coverage data file of the application depends on the class file (class file). At the same time, the code source files of the application also depend on the class files. The corresponding code source file can be associated by the class file. Thus, the server obtains the code source file for the second version of the application from the second type of file and generates a code coverage report for the second version of the application from the third code coverage data file and the code source file. Therefore, besides the test condition of the source code corresponding to the second version of the application program can be displayed through the code coverage rate report, the codes written by corresponding research and development personnel can be displayed through the code source file correspondingly, and the visibility of the code coverage rate report is improved.
In one embodiment, generating a code coverage report for a second version of an application from a third code coverage data file and a code source file comprises: marking codes covered by testing and codes not covered by testing in the code source file according to the second subcode coverage data and the fourth subcode coverage data; a code coverage report for the second version of the application is generated based on the marked code source file and the third code coverage data file.
In this embodiment, the server marks codes covered by the test and/or codes not covered by the test in the code source file according to the second sub-code coverage data corresponding to the difference code branch, marks codes covered by the test and/or codes not covered by the test in the code source file according to the fourth sub-code coverage data, and finally generates a code coverage report including marked code information, thereby further improving the visibility of the code coverage report.
In one embodiment, generating a code coverage report for a second version of an application from a third code coverage data file and a code source file comprises: marking difference codes in the code source file according to the code difference information; a code coverage report for the second version of the application is generated based on the marked code source file and the third code coverage data file.
In this embodiment, the server marks the difference code in the code source file of the second version of the application program according to the difference information, and the finally generated code coverage report includes the marked code information, so that the visibility of the code coverage report is further improved.
It should be understood that, although the steps in the flowchart are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not limited to being performed in the exact order illustrated and, unless explicitly stated herein, may be performed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least some of the sub-steps or stages of other steps.
The present application further provides a device for processing code coverage, as shown in fig. 3, the device includes:
the first obtaining module 10 is configured to obtain a second type of file compiled when testing the second source code of the second version of the application program and a first type of file compiled when testing the first source code of the first version of the application program, and obtain a difference code branch that is different in the second type of file with respect to the first type of file.
A second obtaining module 20, configured to obtain, according to the second type file, a second code coverage data file generated when the second source code is tested, and obtain second subcode coverage data and third subcode coverage data, where the second subcode coverage data is code coverage data corresponding to a difference code branch in the second code coverage data file, and the third subcode coverage data is code coverage data in the second code coverage data file except for the second subcode coverage data.
The third obtaining module 30 is configured to obtain, according to the first type of file, a first code coverage data file generated when the first source code is tested, and screen out, from the first code coverage data file, first sub-code coverage data except code coverage data mapped in the first code coverage data file by the difference code branch.
And the generating module 40 is configured to merge the first sub-code coverage data and the third sub-code coverage data to obtain merged fourth sub-code coverage data, and generate a second version of a third code coverage data file of the application program according to the second sub-code coverage data and the fourth sub-code coverage data.
In one embodiment, the processing device of code coverage further comprises (not shown in fig. 3):
the fourth acquisition module is used for acquiring the code difference information of the second source code of the second version of the application program relative to the first source code of the first version of the application program;
the first obtaining module comprises a first obtaining unit, and is used for determining a difference code branch which is different in the second type file relative to the first type file according to the code difference information.
In one embodiment, the first obtaining unit comprises (not shown in fig. 3):
the first obtaining subunit is used for obtaining the difference method name, the difference code branch name and/or the label of the difference code which are different in the second type of file relative to the first type of file according to the code difference information;
the first determining subunit is used for acquiring a first difference method which is different in the second type of files relative to the first type of files according to the difference method name if the difference method name exists, and determining a difference code branch which is different in the second type of files relative to the first type of files according to the first difference method;
the second determining subunit is used for determining the different code branches in the second type of files relative to the first type of files according to the different code branch names if the different code branch names exist;
and the third determining subunit is used for acquiring a first difference code which is different from the first type of file in the second type of file according to the label of the difference code if the label of the difference code exists, and determining a difference code branch which is different from the first type of file in the second type of file according to the first difference code.
In one embodiment, the processing device for code coverage further comprises (not shown in fig. 3):
a fourth determining subunit, configured to, if a difference code branch name and a difference method name exist at the same time, obtain a second difference method that is different in the second class file with respect to the first class file according to the difference method name, obtain a first target code branch that is different in the second class file with respect to the first class file according to the second difference method, obtain a second target code branch that is different in the second class file with respect to the first class file according to the difference code branch name, regard the second target code branch as the difference code branch when the first target code branch and the second target code branch are matched, and regard both the second target code branch and the first target code branch as the difference code branch when the first target code branch and the second target code branch are not matched;
and the fifth determining subunit is used for acquiring a second difference code which is different from the first type of file in the second type of file according to the label of the difference code if the branch name of the difference code and the label of the difference code exist at the same time, acquiring a third target code branch which is different from the first type of file in the second type of file according to the second difference code, acquiring a fourth target code branch which is different from the first type of file in the second type of file according to the branch name of the difference code, taking the fourth target code branch as the branch of the difference code when the third target code branch is matched with the fourth target code branch, and taking both the fourth target code branch and the third target code branch as the branch of the difference code when the third target code branch is not matched with the fourth target code branch.
In one embodiment, the generation module includes (not shown in FIG. 3):
a first determining unit, configured to determine, according to the fourth subcode coverage data, a first code branch that has been covered by a test and a second code branch that has not been covered by the test in the second class file;
a first generating unit, configured to, if it is determined that the differential code branch has been tested and covered according to the second sub-code coverage data, obtain, according to a determination result of the second sub-code coverage data and a determination result of the fourth sub-code coverage data, a code branch that has been tested and covered and a code branch that is not tested and covered in the second version of the application program, count, according to the code branch that has been tested and covered and the code branch that is not tested and covered, a code coverage of a code branch corresponding to the second version of the application program, and generate a third code coverage data file of the second version of the application program according to the code coverage of the code branch;
and the second generating unit is used for acquiring the code branch which is covered by the test and the code branch which is not covered by the test in the second version of the application program according to the determination result of the second subcode coverage rate data and the determination result of the fourth subcode coverage rate data if the difference code branch is determined not to be covered by the test according to the second subcode coverage rate data, counting the code coverage rate of the code branch corresponding to the second version of the application program according to the code branch which is covered by the test and the code branch which is not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the code branch.
In one embodiment, the processing device of code coverage further comprises (not shown in fig. 3):
the fifth acquisition module is used for acquiring the code source file of the second version of the application program according to the second type file;
and the first report generating module is used for generating a code coverage report of the second version of the application program according to the third code coverage data file and the code source file.
In one embodiment, the first report generating module (not shown in fig. 3) comprises:
a first report generating unit, configured to mark codes covered by the test and codes not covered by the test in the code source file according to the second sub-code coverage data and the fourth sub-code coverage data, and generate a code coverage report of a second version of the application program according to the marked code source file and the third code coverage data file; and/or the presence of a gas in the atmosphere,
and the second report generating unit is used for marking the difference codes in the code source file according to the code difference information and generating the code coverage report of the second version of the application program according to the marked code source file and the third code coverage data file.
For the specific definition of the processing device of the code coverage, reference may be made to the above definition of the processing method of the code coverage, and details are not described here. The modules in the code coverage processing device can be wholly or partially implemented 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. 4. The computer device includes a processor, a memory, a network interface, and a database 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 comprises a nonvolatile 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 network interface of the computer equipment is used for being connected with an external terminal so as to perform data interaction with the external terminal. The computer program is executed by a processor to implement a method for processing code coverage in any of the above embodiments.
It will be appreciated by those skilled in the art that the configuration shown in fig. 4 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 fewer components than shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
acquiring a second type of file compiled when a second source code of a second version of the application program is tested and a first type of file compiled when a first source code of a first version of the application program is tested, and acquiring a differential code branch which is different in the second type of file relative to the first type of file; acquiring a second code coverage rate data file generated when a second source code is tested according to the second type of file, and acquiring second subcode coverage rate data and third subcode coverage rate data, wherein the second subcode coverage rate data are code coverage rate data corresponding to different code branches in the second code coverage rate data file, and the third subcode coverage rate data are code coverage rate data except the second subcode coverage rate data in the second code coverage rate data file; acquiring a first code coverage rate data file generated when a first source code is tested according to a first type of file, and screening first sub-code coverage rate data except code coverage rate data of a difference code branch mapped in the first code coverage rate data file from the first code coverage rate data file; and merging the first sub-code coverage rate data and the third sub-code coverage rate data to obtain merged fourth sub-code coverage rate data, and generating a third code coverage rate data file of a second version of the application program according to the second sub-code coverage rate data and the fourth sub-code coverage rate data.
In one embodiment, the processor, when executing the computer program, performs the steps of: code difference information of a second source code of the second version of the application program relative to a first source code of the first version of the application program is obtained; when the processor executes the computer program to realize the branch step of obtaining the difference code which is different in the second type of file relative to the first type of file, the following steps are specifically realized: and determining the different code branches in the second type files relative to the first type files according to the code difference information.
In one embodiment, when the processor executes the computer program to implement the above-mentioned step of determining, according to the code difference information, a difference code branch in the second type of file that is different from the first type of file, the following steps are specifically implemented: acquiring a difference method name, a difference code branch name and/or a label of a difference code which is different from the first type file in the second type file according to the code difference information; if the difference method name exists, acquiring a first difference method which is different in the second type of files relative to the first type of files according to the difference method name, and determining a difference code branch which is different in the second type of files relative to the first type of files according to the first difference method; if the difference code branch name exists, determining the difference code branch which is different in the second type of file relative to the first type of file according to the difference code branch name; if the label of the difference code exists, acquiring a first difference code which is different in the second type of file relative to the first type of file according to the label of the difference code, and determining a difference code branch which is different in the second type of file relative to the first type of file according to the first difference code.
In one embodiment, the processor, when executing the computer program, performs the steps of: if a difference code branch name and a difference method name exist at the same time, a second difference method which is different from the first type of file in the second type of file is obtained according to the difference method name, a first target code branch which is different from the first type of file in the second type of file is obtained according to the second difference method, a second target code branch which is different from the first type of file in the second type of file is obtained according to the difference code branch name, the second target code branch is used as a difference code branch when the first target code branch is matched with the second target code branch, and the second target code branch and the first target code branch are both used as difference code branches when the first target code branch is not matched with the second target code branch; if the difference code branch name and the label number of the difference code exist at the same time, a second difference code which is different from the first type file in the second type file is obtained according to the label number of the difference code, a third target code branch which is different from the first type file in the second type file is obtained according to the second difference code, a fourth target code branch which is different from the first type file in the second type file is obtained according to the difference code branch name, the fourth target code branch is used as the difference code branch when the third target code branch is matched with the fourth target code branch, and the fourth target code branch and the third target code branch are both used as the difference code branch when the third target code branch is not matched with the fourth target code branch.
In one embodiment, when the processor executes the computer program to implement the step of generating the third code coverage data file of the second version of the application program according to the second subcode coverage data and the fourth subcode coverage data, the following steps are specifically implemented: determining a first code branch which is covered by the test and a second code branch which is not covered by the test in the second type file according to the fourth subcode coverage rate data; if the difference code branch is determined to be covered by the test according to the second subcode coverage rate data, obtaining the code branch covered by the test and the code branch not covered by the test in the second version of the application program according to the determination result of the second subcode coverage rate data and the determination result of the fourth subcode coverage rate data, counting the code coverage rate of the code branch corresponding to the second version of the application program according to the code branch covered by the test and the code branch not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the code branch; if the difference code branch is determined not to be covered by the test according to the second subcode coverage rate data, obtaining the code branch covered by the test and the code branch not covered by the test in the second version of the application program according to the determination result of the second subcode coverage rate data and the determination result of the fourth subcode coverage rate data, counting the code coverage rate of the code branch corresponding to the second version of the application program according to the code branch covered by the test and the code branch not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the code branch.
In one embodiment, the processor, when executing the computer program, performs the steps of: acquiring a code source file of a second version of the application program according to the second type file; a code coverage report for the second version of the application is generated based on the third code coverage data file and the code source file.
In one embodiment, when the processor executes the computer program to implement the step of generating the code coverage report of the second version of the application program from the third code coverage data file and the code source file, the following steps are specifically implemented: marking codes covered by testing and codes not covered by testing in the code source file according to the second subcode coverage rate data and the fourth subcode coverage rate data, and generating a code coverage rate report of a second version of the application program according to the marked code source file and the third code coverage rate data file; and/or marking difference codes in the code source file according to the code difference information; a code coverage report for the second version of the application is generated based on the marked code source file and the third code coverage data file.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
acquiring a second type of file compiled when a second source code of a second version of the application program is tested and a first type of file compiled when a first source code of a first version of the application program is tested, and acquiring a differential code branch which is different in the second type of file relative to the first type of file; acquiring a second code coverage rate data file generated when a second source code is tested according to the second type file, and acquiring second subcode coverage rate data and third subcode coverage rate data, wherein the second subcode coverage rate data is code coverage rate data corresponding to different code branches in the second code coverage rate data file, and the third subcode coverage rate data is code coverage rate data except the second subcode coverage rate data in the second code coverage rate data file; acquiring a first code coverage rate data file generated when a first source code is tested according to a first type of file, and screening first sub-code coverage rate data except code coverage rate data of a difference code branch mapped in the first code coverage rate data file from the first code coverage rate data file; and merging the first subcode coverage rate data and the third subcode coverage rate data to obtain merged fourth subcode coverage rate data, and generating a third code coverage rate data file of a second version of the application program according to the second subcode coverage rate data and the fourth subcode coverage rate data.
In one embodiment, the computer program when executed by a processor performs the steps of: acquiring code difference information of a second source code of the second version of the application program relative to a first source code of the first version of the application program; when the computer program is executed by the processor to implement the above-mentioned branch step of obtaining the difference code in the second type of file that is different from the first type of file, the following steps are specifically implemented: and determining the different code branches in the second type files relative to the first type files according to the code difference information.
In one embodiment, when the computer program is executed by the processor to implement the above-mentioned step of determining, according to the code difference information, a difference code branch in the second type of file that is different from the first type of file, the following steps are specifically implemented:
acquiring a difference method name, a difference code branch name and/or a label of a difference code which is different from the first type file in the second type file according to the code difference information; if the difference method name exists, acquiring a first difference method which is different in the second type of files relative to the first type of files according to the difference method name, and determining a difference code branch which is different in the second type of files relative to the first type of files according to the first difference method; if the difference code branch name exists, determining the difference code branch which is different in the second type of file relative to the first type of file according to the difference code branch name; if the label of the difference code exists, acquiring a first difference code which is different in the second type of file relative to the first type of file according to the label of the difference code, and determining a difference code branch which is different in the second type of file relative to the first type of file according to the first difference code.
In one embodiment, the computer program when executed by a processor performs the steps of: if a difference code branch name and a difference method name exist at the same time, a second difference method which is different from the first type of file in the second type of file is obtained according to the difference method name, a first target code branch which is different from the first type of file in the second type of file is obtained according to the second difference method, a second target code branch which is different from the first type of file in the second type of file is obtained according to the difference code branch name, the second target code branch is used as a difference code branch when the first target code branch is matched with the second target code branch, and the second target code branch and the first target code branch are both used as difference code branches when the first target code branch is not matched with the second target code branch; if the branch name of the difference code and the label of the difference code exist at the same time, a second difference code which is different from the first type file in the second type file is obtained according to the label of the difference code, a third target code branch which is different from the first type file in the second type file is obtained according to the second difference code, a fourth target code branch which is different from the first type file in the second type file is obtained according to the branch name of the difference code, the fourth target code branch is used as the branch of the difference code when the third target code branch is matched with the fourth target code branch, and the fourth target code branch and the third target code branch are both used as the branch of the difference code when the third target code branch is not matched with the fourth target code branch.
In one embodiment, when the computer program is executed by the processor to implement the step of generating the third code coverage data file of the second version of the application program according to the second subcode coverage data and the fourth subcode coverage data, the following steps are specifically implemented: determining a first code branch which is covered by the test and a second code branch which is not covered by the test in the second type file according to the fourth subcode coverage rate data; if the difference code branch is determined to be covered by the test according to the second subcode coverage rate data, acquiring a code branch covered by the test and a code branch not covered by the test in the second version of the application program according to a determination result of the second subcode coverage rate data and a determination result of the fourth subcode coverage rate data, counting the code coverage rate of the code branch corresponding to the second version of the application program according to the code branch covered by the test and the code branch not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the code branch; if the difference code branch is determined not to be covered by the test according to the second subcode coverage rate data, obtaining the code branch covered by the test and the code branch not covered by the test in the second version of the application program according to the determination result of the second subcode coverage rate data and the determination result of the fourth subcode coverage rate data, counting the code coverage rate of the code branch corresponding to the second version of the application program according to the code branch covered by the test and the code branch not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the code branch.
In one embodiment, the computer program when executed by the processor performs the steps of: acquiring a code source file of a second version of the application program according to the second type file; a code coverage report for the second version of the application is generated based on the third code coverage data file and the code source file.
In one embodiment, when the computer program is executed by the processor to implement the step of generating the code coverage report of the second version of the application program according to the third code coverage data file and the code source file, the following steps are specifically implemented: marking codes covered by testing and codes not covered by testing in the code source file according to the second sub-code coverage rate data and the fourth sub-code coverage rate data, and generating a code coverage rate report of a second version of the application program according to the marked code source file and the third code coverage rate data file; and/or marking difference codes in the code source file according to the code difference information; a code coverage report for the second version of the application is generated based on the marked code source file and the third code coverage data file.
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 may be implemented by hardware instructions of a computer program, which may be stored in a non-volatile computer-readable storage medium, and when executed, may include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), rambus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
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-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. 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 patent application shall be subject to the appended claims.

Claims (10)

1. A method of processing code coverage, the method comprising:
acquiring a second type of file compiled when a second source code of a second version of an application program is tested and a first type of file compiled when a first source code of a first version of the application program is tested, and acquiring a difference code branch which is different in the second type of file relative to the first type of file;
acquiring a second code coverage rate data file generated when the second source code is tested according to the second type of file, and acquiring second subcode coverage rate data and third subcode coverage rate data, wherein the second subcode coverage rate data is code coverage rate data corresponding to the difference code branches in the second code coverage rate data file, and the third subcode coverage rate data is code coverage rate data except the second subcode coverage rate data in the second code coverage rate data file;
acquiring a first code coverage rate data file generated when the first source code is tested according to the first type of file, and screening first sub-code coverage rate data except code coverage rate data of the difference code branch mapped in the first code coverage rate data file from the first code coverage rate data file;
and merging the first subcode coverage rate data and the third subcode coverage rate data to obtain merged fourth subcode coverage rate data, and generating a second-version third code coverage rate data file of the application program according to the second subcode coverage rate data and the fourth subcode coverage rate data.
2. The method of claim 1, further comprising: acquiring code difference information of a second source code of the second version of the application program relative to a first source code of the first version of the application program;
the obtaining of the differential code branch in the second type of file that is different from the first type of file includes: and determining the different code branches in the second type files relative to the first type files according to the code difference information.
3. The method according to claim 2, wherein said determining, according to the code difference information, a difference code branch in the second type of file that is different from the first type of file comprises:
acquiring different method names, different code branch names and/or different code labels which are different from the first type of files in the second type of files according to the code difference information;
if the difference method name exists, acquiring a first difference method which is different in the second type of files relative to the first type of files according to the difference method name, and determining difference code branches which are different in the second type of files relative to the first type of files according to the first difference method;
if the difference code branch name exists, determining a difference code branch which is different in the second type of files relative to the first type of files according to the difference code branch name;
if the label of the difference code exists, acquiring a first difference code which is different in the second type of file relative to the first type of file according to the label of the difference code, and determining a difference code branch which is different in the second type of file relative to the first type of file according to the first difference code.
4. The method of claim 3, further comprising:
if the difference code branch name and the difference method name exist at the same time, a second difference method which is different from the first type file in the second type file is obtained according to the difference method name, a first target code branch which is different from the first type file in the second type file is obtained according to the second difference method, a second target code branch which is different from the first type file in the second type file is obtained according to the difference code branch name, the second target code branch is used as the difference code branch when the first target code branch is matched with the second target code branch, and the second target code branch and the first target code branch are both used as the difference code branch when the first target code branch is matched with the second target code branch;
if the difference code branch name and the label number of the difference code exist at the same time, a second difference code which is different from the first type file in the second type file is obtained according to the label number of the difference code, a third target code branch which is different from the first type file in the second type file is obtained according to the second difference code, a fourth target code branch which is different from the first type file in the second type file is obtained according to the difference code branch name, the fourth target code branch is used as the difference code branch when the third target code branch is matched with the fourth target code branch, and the fourth target code branch and the third target code branch are both used as the difference code branch when the third target code branch is not matched with the fourth target code branch.
5. The method of claim 1, wherein generating a second version of a third code coverage data file for the application from the second subcode coverage data and the fourth subcode coverage data comprises:
determining a first code branch which is covered by a test and a second code branch which is not covered by the test in the second type file according to the fourth subcode coverage rate data;
if the difference code branch is determined to be covered by the test according to the second sub-code coverage data, obtaining the code branch covered by the test and the code branch not covered by the test in the second version according to the determination result of the second sub-code coverage data and the determination result of the fourth sub-code coverage data, counting the code coverage of the code branch corresponding to the second version of the application program according to the code branch covered by the test and the code branch not covered by the test, and generating a third code coverage data file of the second version of the application program according to the code coverage of the code branch;
if the difference code branch is determined not to be covered by the test according to the second subcode coverage rate data, obtaining the code branch covered by the test and the code branch not covered by the test in the second version according to the determination result of the second subcode coverage rate data and the determination result of the fourth subcode coverage rate data, counting the code coverage rate of the code branch corresponding to the second version of the application program according to the code branch covered by the test and the code branch not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the code branch.
6. The method of claim 2, further comprising:
acquiring a code source file of a second version of the application program according to the second type file;
generating a code coverage report for a second version of the application from the third code coverage data file and the code source file.
7. The method of claim 6, wherein generating a code coverage report for the second version of the application from the third code coverage data file and the code source file comprises:
marking codes which are covered by testing and codes which are not covered by testing in the code source file according to the second sub-code coverage rate data and the fourth sub-code coverage rate data, and generating a code coverage rate report of a second version of the application program according to the marked code source file and the third code coverage rate data file;
and/or the presence of a gas in the atmosphere,
and marking the difference codes in the code source file according to the code difference information, and generating a code coverage rate report of the second version of the application program according to the marked code source file and the third code coverage rate data file.
8. An apparatus for processing code coverage, the apparatus comprising:
the first obtaining module is used for obtaining a second type of file obtained by compiling when testing a second source code of a second version of an application program and a first type of file obtained by compiling when testing a first source code of a first version of the application program, and obtaining a difference code branch which is different in the second type of file relative to the first type of file;
a second obtaining module, configured to obtain, according to the second type of file, a second code coverage data file generated when the second source code is tested, and obtain second sub-code coverage data and third sub-code coverage data, where the second sub-code coverage data is code coverage data corresponding to the difference code branch in the second code coverage data file, and the third sub-code coverage data is code coverage data except the second sub-code coverage data in the second code coverage data file;
a third obtaining module, configured to obtain, according to the first type of file, a first code coverage data file generated when the first source code is tested, and screen, from the first code coverage data file, first sub-code coverage data except code coverage data in which the difference code branches are mapped in the first code coverage data file;
and the generating module is used for merging the first sub-code coverage rate data and the third sub-code coverage rate data to obtain merged fourth sub-code coverage rate data, and generating a third code coverage rate data file of a second version of the application program according to the second sub-code coverage rate data and the fourth sub-code coverage rate data.
9. A computer arrangement comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 7 when executing the computer program.
10. 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 7.
CN201911244449.1A 2019-12-06 2019-12-06 Code coverage rate processing method and device and computer equipment Active CN111078549B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911244449.1A CN111078549B (en) 2019-12-06 2019-12-06 Code coverage rate processing method and device and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911244449.1A CN111078549B (en) 2019-12-06 2019-12-06 Code coverage rate processing method and device and computer equipment

Publications (2)

Publication Number Publication Date
CN111078549A CN111078549A (en) 2020-04-28
CN111078549B true CN111078549B (en) 2023-03-17

Family

ID=70313329

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911244449.1A Active CN111078549B (en) 2019-12-06 2019-12-06 Code coverage rate processing method and device and computer equipment

Country Status (1)

Country Link
CN (1) CN111078549B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112463620A (en) * 2020-12-03 2021-03-09 广州品唯软件有限公司 Coverage rate testing method and device in android software integration test

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105404585A (en) * 2015-12-01 2016-03-16 腾讯科技(深圳)有限公司 Method and apparatus for acquiring code coverage rate
CN108519945A (en) * 2018-03-21 2018-09-11 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage device
CN108829580A (en) * 2018-05-07 2018-11-16 百度在线网络技术(北京)有限公司 Multi version test data processing method, device, equipment and storage medium
CN109388566A (en) * 2018-09-27 2019-02-26 北京城市网邻信息技术有限公司 A kind of code coverage rate analysis method, apparatus, equipment and storage medium
CN110209568A (en) * 2018-04-24 2019-09-06 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage equipment

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10289532B2 (en) * 2015-04-08 2019-05-14 Opshub, Inc. Method and system for providing delta code coverage information

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105404585A (en) * 2015-12-01 2016-03-16 腾讯科技(深圳)有限公司 Method and apparatus for acquiring code coverage rate
CN108519945A (en) * 2018-03-21 2018-09-11 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage device
CN110209568A (en) * 2018-04-24 2019-09-06 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage equipment
CN108829580A (en) * 2018-05-07 2018-11-16 百度在线网络技术(北京)有限公司 Multi version test data processing method, device, equipment and storage medium
CN109388566A (en) * 2018-09-27 2019-02-26 北京城市网邻信息技术有限公司 A kind of code coverage rate analysis method, apparatus, equipment and storage medium

Also Published As

Publication number Publication date
CN111078549A (en) 2020-04-28

Similar Documents

Publication Publication Date Title
CN111124894B (en) Code coverage rate processing method and device and computer equipment
CN106874187B (en) Code coverage rate collection method and device
US8397104B2 (en) Creation of test plans
CN108427613B (en) Abnormal interface positioning method and device, computer equipment and storage medium
US20080178047A1 (en) Software Test System, Method, And Computer Readable Recording Medium Having Program Stored Thereon For Executing the Method
CN109408375B (en) Method and device for generating interface document
CN109766261B (en) Coverage test method, coverage test device, computer equipment and storage medium
CN111026647B (en) Method and device for acquiring code coverage rate, computer equipment and storage medium
CN108959059A (en) A kind of test method and test platform
CN108829575B (en) Test case recommendation method, electronic device and readable storage medium
CN111597069B (en) Program processing method, device, electronic equipment and storage medium
CN115292163A (en) Application program detection method and device and computer readable storage medium
CN111078549B (en) Code coverage rate processing method and device and computer equipment
CN112153375A (en) Front-end performance testing method, device, equipment and medium based on video information
CN111625835B (en) Program vulnerability path tracking method, device, computer equipment and storage medium
CN111008138B (en) Method and device for processing code coverage rate and computer equipment
CN115934503A (en) Program testing method, device, equipment and storage medium
CN111090583B (en) Method and device for generating code coverage rate report and computer equipment
CN112486824B (en) Case code generation method, device, computer equipment and storage medium
CN114090455A (en) Software testing method, device, equipment and storage medium
CN113656318A (en) Software version testing method and device and computer equipment
CN112631905A (en) Execution process data management method and device, computer equipment and storage medium
CN112269594A (en) Project code quality evaluation method, device, equipment and storage medium
CN112328504A (en) Buried point data inspection method, buried point data inspection device, buried point data inspection system, computer equipment and storage medium
CN109902488A (en) APP tampering detection processing method, iOS device and 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
GR01 Patent grant
GR01 Patent grant