CN111124894A - 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
CN111124894A
CN111124894A CN201911242850.1A CN201911242850A CN111124894A CN 111124894 A CN111124894 A CN 111124894A CN 201911242850 A CN201911242850 A CN 201911242850A CN 111124894 A CN111124894 A CN 111124894A
Authority
CN
China
Prior art keywords
code
difference
file
coverage
coverage rate
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.)
Granted
Application number
CN201911242850.1A
Other languages
Chinese (zh)
Other versions
CN111124894B (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 CN201911242850.1A priority Critical patent/CN111124894B/en
Publication of CN111124894A publication Critical patent/CN111124894A/en
Application granted granted Critical
Publication of CN111124894B publication Critical patent/CN111124894B/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/368Test management for test version control, e.g. updating test cases to a new software version
    • 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: code difference information of a second source code of a second version of the application program and a first source code of a first version of the application program is obtained; acquiring a second type file of a second source code and a first type file of a first source code; acquiring second subcode coverage data of the code difference information and third subcode coverage data except the second subcode coverage data from a code coverage data file of the second source code; obtaining first subcode coverage data, excluding code difference information corresponding code coverage data, from a code coverage data file of the first source code; 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 repeated tests.

Description

Code coverage rate processing method and device 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 during testing. 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 for coverage in the previous version but has not been tested for coverage in the current small version, and the code needs to be retested with reference to the code coverage data of the current small version, thereby resulting in repeated testing of the code.
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: 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 second type of file obtained by compiling when testing the second source code and acquiring a first type of file obtained by compiling when testing the first source code; 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 is code coverage rate data corresponding to code difference information 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 which code difference information is 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 method for processing code coverage further includes: determining a difference line code which is different in the second type of file relative to the first type of file according to the code difference information; the second subcode coverage rate data is code coverage rate data corresponding to the difference line codes in the second code coverage rate data file; screening out first sub-code coverage data from the first code coverage data file except for the code coverage data with the code difference information mapped in the first code coverage data file, comprising: first subcode coverage data is screened from the first code coverage data file except for code coverage data in which the difference line codes are mapped in the first code coverage data file.
In one embodiment, determining the difference line code 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, obtaining a difference method of the difference method name, and obtaining a difference line code existing in the difference method; if the difference code branch name exists, obtaining the difference code branch of the difference code branch name, and obtaining the difference line code existing in the difference code branch; and if the label of the difference code exists, acquiring the difference code corresponding to the label of the difference code, and acquiring the difference line code according to the difference code.
In one embodiment, the method for processing code coverage further includes: if the difference method name and the difference code branch name exist at the same time, a difference method of the difference method name and a difference code branch of the difference code branch name are obtained, a first target line code which is different from the first type of file in a second type of file is obtained according to the difference method, a second target line code which is different from the first type of file in the second type of file is obtained according to the difference code branch, the first target line code or the second target line code is used as a difference line code when the first target line code is matched with the second target line code, and the first target line code and the second target line code are both used as the difference line code when the first target line code is not matched with the second target line code; if the difference method name and the label of the difference code exist at the same time, a difference method of the difference method name and a difference code corresponding to the label of the difference code are obtained, a third target line code which is different from the first type file in the second type file is obtained according to the difference method, a fourth target line code which is different from the first type file in the second type file is obtained according to the difference code, the third target line code or the fourth target line code is used as the difference line code when the third target line code is matched with the fourth target line code, and the third target line code and the fourth target line code are both used as the difference line code when the third target line code is not matched with the fourth target line code; if the difference code branch name and the label number of the difference code exist at the same time, the difference code of the label number of the difference code and the difference code branch of the difference code branch name are obtained, a fifth target line code which is different from the first type file in the second type file is obtained according to the difference code, a sixth target line code which is different from the first type file in the second type file is obtained according to the difference code branch, the fifth target line code or the sixth target line code is used as the difference line code when the fifth target line code is matched with the sixth target line code, and the fifth target line code and the sixth target line code are both used as the difference line code when the fifth target line code is not matched with the sixth target line code.
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 line of codes which are covered by the test and a second line of codes which are not covered by the test in the second type file according to the fourth subcode coverage rate data; if the difference line code is determined to be covered by the test according to the second subcode coverage rate data, obtaining the line code covered by the test and the line code 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 line code corresponding to the second version of the application program according to the line code covered by the test and the line code 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 line code; if the difference line code is determined to be covered by the test according to the second subcode coverage rate data, obtaining the line code covered by the test and the line code 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 line code corresponding to the second version of the application program according to the line code covered by the test and the line code 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 line code.
In one embodiment, the method for processing 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 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 the difference code in the code source file according to the code difference information, and generating a 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.
An apparatus for processing code coverage, the apparatus comprising: the first acquisition module is used for 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 second obtaining module is used for obtaining a second type file obtained by compiling when testing the second source code and obtaining a first type file obtained by compiling when testing the first source code; a third 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 code difference information 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 fourth 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 which the code difference information is 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.
The server obtains code difference information of a second source code of a second version of the application program relative to a first source code of a first version of the application program, obtains a second type of file obtained by compiling when testing the second source code and a first type of file obtained by compiling when testing the first source code, further obtains a second code coverage data file generated when testing the second source code according to the second type of file, and obtains second subcode coverage data corresponding to the code difference information from the second code coverage data file, so that the code coverage data condition of the difference code of the second version of the application program relative to the first version can be determined. Meanwhile, the server acquires a first code coverage rate data file generated when testing the first source code according to the first type of file, screens first sub-code coverage rate data except code coverage rate data of which the code difference information is 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 codes is realized. And finally, generating a third code coverage rate data file of a second version of the application program according to the fourth subcode coverage rate data obtained after the merging processing and the second subcode coverage rate data corresponding to the difference code. 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 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 versions of the difference codes.
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 illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The 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 product submitted by terminal 18 in database 14. When executing a code coverage processing method of the present application, the server 12 obtains, from the database 14, code difference information of a second source code of a second version of the application program with respect to a first source code of a first version of the application program, obtains a second type of file compiled when the second source code is tested, and obtains a first type of file compiled when the first source code is tested. The server 12 obtains a second code coverage rate data file generated when testing the second source code according to the second type file, and obtains 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 code difference information 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 which code difference information is 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. 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, 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.
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 difference line codes, difference methods, difference branches and the like which are different in the second type of files relative to the first type of 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, each small version corresponding to an identification number. The identification number of the current version A comprises a plurality of identification numbers a1, a2, a3, … …, an and the like, the server obtains the identification number B of the last submitted version of the last version B and a plurality of identification numbers a1, a2, a3, … … and an of the current version A, and generates an identification list. The list of identifications may be denoted as commissions [ b1, a1, a2, a3 … … an ]. The commit 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.
S104, acquiring a second type file obtained by compiling when testing the second source code and acquiring a first type file obtained by compiling when testing the first source code.
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 class file, which is the first type of 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 submission. The first version of the application may be any version previously submitted, such as the last version relative to the current version.
S106, 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 code difference information 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 code difference information 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 code difference information, and the other part of data is data except the second subcode coverage data.
S108, 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 which the code difference information is mapped in the first code coverage rate data file from the first code coverage rate data file.
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 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 in which the code difference information is mapped 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. And a part of data is code coverage data of the code difference information corresponding to the first source code mapped to the first code coverage data file. For example, the code difference information is information containing a second version of code that is increased relative to the first version, where the code coverage data mapped into the first code coverage data file is zero. If the code difference information is information including the modified code of the second version 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 before the modification of the first version. Another portion of the data is data other than the code coverage data mapped in the first code coverage data file.
And S110, 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 other than the code coverage data corresponding to the code difference information between the second version and the first version. 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. And when the same code shows that both the first subcode coverage rate data and the third subcode coverage rate data correspond to the data which are not tested to be covered, the code shows that the code is not tested to be covered in the combined fourth subcode coverage rate data. For example, the first version and the second version each include a code a in addition to a difference code corresponding to the code difference information. And if the code a is displayed as untested coverage in the data corresponding to the first subcode coverage data and the third subcode coverage data, the code a is displayed as untested coverage in the merged fourth subcode coverage data. The code 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 the code a displays tested coverage in the merged fourth subcode coverage data. Therefore, the fourth subcode coverage rate data obtained after combination can accurately reflect the test conditions of other source codes except the test conditions of the source codes corresponding to the code difference information, 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 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 subcode coverage data corresponding to the code difference information and the fourth subcode coverage data obtained by merging the other data between the second version and the first version except the code coverage data corresponding to the code difference information. 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.
According to the code coverage rate processing method, the server obtains 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, obtains the second type of file obtained by compiling when testing the second source code and obtains the first type of file obtained by compiling when testing the first source code, further obtains the second code coverage rate data file generated when testing the second source code according to the second type of file, and obtains the second subcode coverage rate data corresponding to the code difference information from the second code coverage rate data file, so that the code coverage rate data condition of the difference code of the second version of the application program relative to the first version can be determined. Meanwhile, the server acquires a first code coverage rate data file generated when testing the first source code according to the first type of file, screens first sub-code coverage rate data except code coverage rate data of which the code difference information is 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 codes is realized. And finally, generating a third code coverage rate data file of a second version of the application program according to the fourth subcode coverage rate data obtained after the merging processing and the second subcode coverage rate data corresponding to the difference code. 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 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 versions of the difference codes.
In one embodiment, after step S102, the method further includes: and determining the difference line codes which are different in the second type of file relative to the first type of file according to the code difference information. At this time, the second subcode coverage data is the code coverage data corresponding to the difference line code in the second code coverage data file. In step S106, screening out first sub-code coverage data from the first code coverage data file, except for the code coverage data in which the code difference information is mapped in the first code coverage data file, includes: first subcode coverage data is screened from the first code coverage data file except for code coverage data in which the difference line codes are mapped in the first code coverage data file.
In this embodiment, the code difference information includes difference line code information. And the server determines the difference line codes which are different in the second type of file relative to the first type of file according to the code difference information. In a specific implementation process, the server reads the difference codes existing in the second type of files relative to the first type of files according to the code difference information, and obtains the difference line codes existing in the second type of files relative to the first type of files according to the difference codes existing between the difference codes and the first type of files. For example, assume that all codes in the second type file include code m, code n, and code s, and all codes in the first type file include code m, code n, code s, and code l. At this time, the distinguishing code existing in the second type file with respect to the first type file is code l. The code line where the code l is located is the difference line code.
In one embodiment, determining the difference line code in the second type of file which 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, obtaining a difference method of the difference method name, and obtaining a difference line code existing in the difference method; if the difference code branch name exists, obtaining the difference code branch of the difference code branch name, and obtaining the difference line code existing in the difference code branch; and if the label of the difference code exists, acquiring the difference code corresponding to the label of the difference code, and acquiring the difference line code according to the difference code.
In this embodiment, the server can obtain the difference method name, the difference code branch name, and the label of the difference code that are different in the second type file from the first type file according to the code difference information. The difference method corresponding to the difference method name may include a difference line code, and the difference code branch of the difference code branch name may also include a difference line code. The difference line code can also be obtained after the difference code determined according to the label of the difference code. Therefore, the server can obtain the difference line code according to any one of the difference method name, the difference code branch name and the label number of the difference code, and the efficiency of obtaining the difference line code is improved.
In an embodiment, determining, according to the code difference information, a difference line code in the second type file that is different from the first type file further includes: if the difference method name and the difference code branch name exist at the same time, a difference method of the difference method name and a difference code branch of the difference code branch name are obtained, a first target line code which is different from the first type of file in a second type of file is obtained according to the difference method, a second target line code which is different from the first type of file in the second type of file is obtained according to the difference code branch, the first target line code or the second target line code is used as a difference line code when the first target line code is matched with the second target line code, and the first target line code and the second target line code are both used as the difference line code when the first target line code is not matched with the second target line code; if the difference method name and the label of the difference code exist at the same time, a difference method of the difference method name and a difference code corresponding to the label of the difference code are obtained, a third target line code which is different from the first type file in the second type file is obtained according to the difference method, a fourth target line code which is different from the first type file in the second type file is obtained according to the difference code, the third target line code or the fourth target line code is used as the difference line code when the third target line code is matched with the fourth target line code, and the third target line code and the fourth target line code are both used as the difference line code when the third target line code is not matched with the fourth target line code; if the difference code branch name and the label number of the difference code exist at the same time, the difference code of the label number of the difference code and the difference code branch of the difference code branch name are obtained, a fifth target line code which is different from the first type file in the second type file is obtained according to the difference code, a sixth target line code which is different from the first type file in the second type file is obtained according to the difference code branch, the fifth target line code or the sixth target line code is used as the difference line code when the fifth target line code is matched with the sixth target line code, and the fifth target line code and the sixth target line code are both used as the difference line code when the fifth target line code is not matched with the sixth target line code.
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 S110 includes: determining a first line of codes which are covered by the test and a second line of codes which are not covered by the test in the second type file according to the fourth subcode coverage rate data; if the difference line code is determined to be covered by the test according to the second subcode coverage rate data, obtaining the line code covered by the test and the line code 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 line code corresponding to the second version of the application program according to the line code covered by the test and the line code 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 line code; if the difference line code is determined to be covered by the test according to the second subcode coverage rate data, obtaining the line code covered by the test and the line code 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 line code corresponding to the second version of the application program according to the line code covered by the test and the line code 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 line code.
In this embodiment, the second subcode coverage rate data corresponding to the difference line code in the second type file may determine that the difference line code has been covered by the test, or the second subcode coverage rate data corresponding to the difference line code in the second type file may determine that the difference line code has not been covered by the test. The fourth subcode coverage data may determine a first line of code in the second type of file that has been covered by the test and a second line of code that has not been covered by the test. That is, no matter the condition that the differential line code is covered by the test or the condition that the differential line code is not covered by the test is judged according to the second subcode coverage rate data corresponding to the differential line code in the second type file, the tested line code and the untested line code in the second version of the application program can be determined according to the second subcode coverage rate data and according to the fourth subcode coverage rate data, so that the code coverage rate of the line code corresponding to the second version of the application program is counted according to the tested covered line code and the untested covered line code in the second version of the application program, and then the third code coverage rate data file of the second version of the application program is generated according to the code coverage rate of the line code corresponding to the second version. Therefore, the third code coverage data file can truly reflect the code coverage condition of the second version of the application program in the code test process.
In one embodiment, after step S110, 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. Therefore, the server obtains the code source file of the second version of the application program according to the second type file, and generates 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. 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 line code, 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 performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. 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 performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn 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:
a first obtaining module 10, configured to obtain code difference information of a second source code of a second version of the application program relative to a first source code of a first version of the application program;
a second obtaining module 20, configured to obtain a second type of file compiled when the second source code is tested and obtain a first type of file compiled when the first source code is tested;
a third obtaining module 30, 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 code difference information 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;
a fourth obtaining module 40, 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 in which the code difference information is mapped in the first code coverage data file;
and a generating module 50, 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 determining module is used for determining the difference line codes which are different in the second type of files relative to the first type of files according to the code difference information; the second subcode coverage rate data is code coverage rate data corresponding to the difference line codes in the second code coverage rate data file;
the fourth obtaining module 40 includes a first obtaining unit configured to screen out, from the first code coverage data file, first sub-code coverage data other than the code coverage data in which the difference line codes are mapped in the first code coverage data file.
In one embodiment, the determining module includes (not shown in FIG. 3): :
the second acquisition unit is used for acquiring the difference method name, the difference code branch name and/or the label of the difference code which is different from the first type of file in the second type of file according to the code difference information;
the third acquisition unit is used for acquiring a difference method of the difference method name and acquiring a difference line code existing in the difference method if the difference method name exists;
the fourth obtaining unit is used for obtaining a difference code branch of the difference code branch name and obtaining a difference line code in the difference code branch if the difference code branch name exists;
and the fifth acquiring unit is used for acquiring the difference code corresponding to the label of the difference code if the label of the difference code exists, and acquiring the difference line code according to the difference code.
In one embodiment, the determining module further comprises (not shown in fig. 3): :
a sixth obtaining unit, configured to, if a difference method name and a difference code branch name exist at the same time, obtain a difference method for the difference method name and obtain a difference code branch for the difference code branch name, obtain a first target line code that is distinguished in a second type of file with respect to a first type of file according to the difference method, obtain a second target line code that is distinguished in the second type of file with respect to the first type of file according to the difference code branch, use the first target line code or the second target line code as the difference line code when the first target line code and the second target line code match, and use both the first target line code and the second target line code as the difference line code when the first target line code and the second target line code do not match;
a seventh obtaining unit, configured to, if a difference method name and a label of a difference code exist at the same time, obtain a difference method for the difference method name and obtain a difference code corresponding to the label of the difference code, obtain, according to the difference method, a third target line code that is different in a second type of file from the first type of file, obtain, according to the difference code, a fourth target line code that is different in the second type of file from the first type of file, use, when the third target line code matches the fourth target line code, the third target line code or the fourth target line code as the difference line code, and when the third target line code does not match the fourth target line code, use, as the difference line code, both the third target line code and the fourth target line code;
the eighth obtaining unit is configured to, if a branch name of the difference code and a label of the difference code exist at the same time, obtain the difference code of the label of the difference code and obtain a branch of the difference code of the branch name of the difference code, obtain a fifth target line code that is different from the first type file in the second type file according to the difference code, obtain a sixth target line code that is different from the first type file in the second type file according to the branch of the difference code, use the fifth target line code or the sixth target line code as the difference line code when the fifth target line code matches the sixth target line code, and use both the fifth target line code and the sixth target line code as the difference line code when the fifth target line code does not match the sixth target line code.
In one embodiment, the generation module comprises (not shown in FIG. 3):
a first determining unit, configured to determine, according to the fourth subcode coverage data, a first line of codes that have been covered by the test and a second line of codes that are not covered by the test in the second class file;
a first generating unit, configured to, if it is determined that the difference line code is covered by the test 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 line code that has been covered by the test and a line code that is not covered by the test in the second version, count, according to the line code that has been covered by the test and the line code that is not covered by the test, a code coverage of a line code corresponding to the second version of the application program, and generate, according to the code coverage of the line code, a third code coverage data file of the second version of the application program;
and the second generating unit is used for acquiring the line codes which are already tested and covered and the line codes which are not tested and covered 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 if the difference line codes are determined to be tested and covered according to the second subcode coverage rate data, counting the code coverage rate of the line codes corresponding to the second version of the application program according to the line codes which are already tested and covered and the line codes which are not tested and covered, 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 line codes.
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 gas,
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.
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, which is not described herein again. 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.
Those skilled in the art will appreciate that the architecture shown in fig. 4 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory, 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:
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 second type of file obtained by compiling when testing the second source code and acquiring a first type of file obtained by compiling when testing the first source code; 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 is code coverage rate data corresponding to code difference information 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 which code difference information is 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 processor, when executing the computer program, performs the steps of: determining a difference line code which is different in the second type of file relative to the first type of file according to the code difference information; the second subcode coverage rate data is code coverage rate data corresponding to the difference line codes in the second code coverage rate data file; when the processor executes the computer program to realize the step of screening out the first sub-code coverage rate data except the code coverage rate data of which the code difference information is mapped in the first code coverage rate data file from the first code coverage rate data file, the following steps are specifically realized: first subcode coverage data is screened from the first code coverage data file except for code coverage data in which the difference line codes are mapped in the first code coverage data file.
In one embodiment, when the processor executes the computer program to implement the step of determining the difference line code that is different in the second type of file relative to the first type of file according to the code difference information, 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, obtaining a difference method of the difference method name, and obtaining a difference line code existing in the difference method; if the difference code branch name exists, obtaining the difference code branch of the difference code branch name, and obtaining the difference line code existing in the difference code branch; and if the label of the difference code exists, acquiring the difference code corresponding to the label of the difference code, and acquiring the difference line code according to the difference code.
In one embodiment, the processor, when executing the computer program, performs the steps of: if the difference method name and the difference code branch name exist at the same time, a difference method of the difference method name and a difference code branch of the difference code branch name are obtained, a first target line code which is different from the first type of file in a second type of file is obtained according to the difference method, a second target line code which is different from the first type of file in the second type of file is obtained according to the difference code branch, the first target line code or the second target line code is used as a difference line code when the first target line code is matched with the second target line code, and the first target line code and the second target line code are both used as the difference line code when the first target line code is not matched with the second target line code; if the difference method name and the label of the difference code exist at the same time, a difference method of the difference method name and a difference code corresponding to the label of the difference code are obtained, a third target line code which is different from the first type file in the second type file is obtained according to the difference method, a fourth target line code which is different from the first type file in the second type file is obtained according to the difference code, the third target line code or the fourth target line code is used as the difference line code when the third target line code is matched with the fourth target line code, and the third target line code and the fourth target line code are both used as the difference line code when the third target line code is not matched with the fourth target line code; if the difference code branch name and the label number of the difference code exist at the same time, the difference code of the label number of the difference code and the difference code branch of the difference code branch name are obtained, a fifth target line code which is different from the first type file in the second type file is obtained according to the difference code, a sixth target line code which is different from the first type file in the second type file is obtained according to the difference code branch, the fifth target line code or the sixth target line code is used as the difference line code when the fifth target line code is matched with the sixth target line code, and the fifth target line code and the sixth target line code are both used as the difference line code when the fifth target line code is not matched with the sixth target line code.
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 line of codes which are covered by the test and a second line of codes which are not covered by the test in the second type file according to the fourth subcode coverage rate data; if the difference line code is determined to be covered by the test according to the second subcode coverage rate data, obtaining the line code covered by the test and the line code 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 line code corresponding to the second version of the application program according to the line code covered by the test and the line code 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 line code; if the difference line code is determined to be covered by the test according to the second subcode coverage rate data, obtaining the line code covered by the test and the line code 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 line code corresponding to the second version of the application program according to the line code covered by the test and the line code 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 line code.
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 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 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 the difference code in the code source file according to the code difference information, and generating a 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.
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:
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 second type of file obtained by compiling when testing the second source code and acquiring a first type of file obtained by compiling when testing the first source code; 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 is code coverage rate data corresponding to code difference information 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 which code difference information is 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 the processor performs the steps of: determining a difference line code which is different in the second type of file relative to the first type of file according to the code difference information; the second subcode coverage rate data is code coverage rate data corresponding to the difference line codes in the second code coverage rate data file; when the computer program is executed by the processor to realize the step of screening out the first subcode coverage data except the code coverage data of which the code difference information is mapped in the first code coverage data file from the first code coverage data file, the following steps are specifically realized: first subcode coverage data is screened from the first code coverage data file except for code coverage data in which the difference line codes are mapped in the first code coverage data file.
In one embodiment, when the computer program is executed by the processor to implement the step of determining, according to the code difference information, a difference line code that is different in the second type of file with respect to 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, obtaining a difference method of the difference method name, and obtaining a difference line code existing in the difference method; if the difference code branch name exists, obtaining the difference code branch of the difference code branch name, and obtaining the difference line code existing in the difference code branch; and if the label of the difference code exists, acquiring the difference code corresponding to the label of the difference code, and acquiring the difference line code according to the difference code.
In one embodiment, the computer program when executed by the processor performs the steps of: if the difference method name and the difference code branch name exist at the same time, a difference method of the difference method name and a difference code branch of the difference code branch name are obtained, a first target line code which is different from the first type of file in a second type of file is obtained according to the difference method, a second target line code which is different from the first type of file in the second type of file is obtained according to the difference code branch, the first target line code or the second target line code is used as a difference line code when the first target line code is matched with the second target line code, and the first target line code and the second target line code are both used as the difference line code when the first target line code is not matched with the second target line code; if the difference method name and the label of the difference code exist at the same time, a difference method of the difference method name and a difference code corresponding to the label of the difference code are obtained, a third target line code which is different from the first type file in the second type file is obtained according to the difference method, a fourth target line code which is different from the first type file in the second type file is obtained according to the difference code, the third target line code or the fourth target line code is used as the difference line code when the third target line code is matched with the fourth target line code, and the third target line code and the fourth target line code are both used as the difference line code when the third target line code is not matched with the fourth target line code; if the difference code branch name and the label number of the difference code exist at the same time, the difference code of the label number of the difference code and the difference code branch of the difference code branch name are obtained, a fifth target line code which is different from the first type file in the second type file is obtained according to the difference code, a sixth target line code which is different from the first type file in the second type file is obtained according to the difference code branch, the fifth target line code or the sixth target line code is used as the difference line code when the fifth target line code is matched with the sixth target line code, and the fifth target line code and the sixth target line code are both used as the difference line code when the fifth target line code is not matched with the sixth target line code.
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 line of codes which are covered by the test and a second line of codes which are not covered by the test in the second type file according to the fourth subcode coverage rate data; if the difference line code is determined to be covered by the test according to the second subcode coverage rate data, obtaining the line code covered by the test and the line code 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 line code corresponding to the second version of the application program according to the line code covered by the test and the line code 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 line code; if the difference line code is determined to be covered by the test according to the second subcode coverage rate data, obtaining the line code covered by the test and the line code 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 line code corresponding to the second version of the application program according to the line code covered by the test and the line code 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 line code.
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 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 the difference code in the code source file according to the code difference information, and generating a 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.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, 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 Direct RAM (RDRAM), direct 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 shall be subject to the appended claims.

Claims (10)

1. A method of code coverage processing, the method comprising:
acquiring code difference information of a second source code of a second version of an application program relative to a first source code of a first version of the application program;
acquiring a second type of file compiled when the second source code is tested and a first type of file compiled when the first source code is tested;
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 code difference information 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 the code coverage rate data of the code difference information 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: determining a difference line code which is different in the second type of file relative to the first type of file according to the code difference information; the second subcode coverage data is code coverage data corresponding to the difference line codes in the second code coverage data file;
the screening out first sub-code coverage data from the first code coverage data file except for the code coverage data of which the code difference information is mapped in the first code coverage data file comprises: screening out first subcode coverage data from the first code coverage data file other than the code coverage data for which the difference line codes are mapped in the first code coverage data file.
3. The method according to claim 2, wherein said determining the difference line code in the second type of file that is different from the first type of file according to the code difference information comprises:
acquiring a difference method name, a difference code branch name and/or a difference code label which are different from the first type of file in the second type of file according to the code difference information;
if the difference method name exists, obtaining a difference method of the difference method name, and obtaining the difference line code existing in the difference method;
if the difference code branch name exists, obtaining the difference code branch of the difference code branch name, and obtaining the difference line code existing in the difference code branch;
and if the label of the difference code exists, acquiring the difference code corresponding to the label of the difference code, and acquiring the difference line code according to the difference code.
4. The method of claim 3, further comprising:
if the difference method name and the difference code branch name exist at the same time, acquiring a difference method of the difference method name and a difference code branch of the difference code branch name, acquiring a first target line code which is different from the first type of file in the second type of file according to the difference method, acquiring a second target line code which is different from the first type of file in the second type of file according to the difference code branch, taking the first target line code or the second target line code as the difference line code when the first target line code and the second target line code are matched, and taking the first target line code and the second target line code as the difference line code when the first target line code and the second target line code are not matched;
if the difference method name and the label of the difference code exist at the same time, obtaining a difference method of the difference method name and obtaining a difference code corresponding to the label of the difference code, obtaining a third target line code which is different in the second type of file relative to the first type of file according to the difference method, obtaining a fourth target line code which is different in the second type of file relative to the first type of file according to the difference code, taking the third target line code or the fourth target line code as the difference line code when the third target line code and the fourth target line code are matched, and taking the third target line code and the fourth target line code as the difference line code when the third target line code and the fourth target line code are not matched;
if the difference code branch name and the label number of the difference code exist at the same time, obtaining the difference code of the label number of the difference code and obtaining the difference code branch of the difference code branch name, obtaining a fifth target line code which is different from the first type file in the second type file according to the difference code, obtaining a sixth target line code which is different from the first type file in the second type file according to the difference code branch, taking the fifth target line code or the sixth target line code as the difference line code when the fifth target line code is matched with the sixth target line code, and taking the fifth target line code and the sixth target line code as the difference line code when the fifth target line code is not matched with the sixth target line code.
5. The method of claim 2, 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 line of codes which are covered by the test and a second line of codes which are not covered by the test in the second type file according to the fourth subcode coverage rate data;
if the difference line code is determined to be covered by the test according to the second subcode coverage rate data, obtaining the line code covered by the test and the line code 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 line code corresponding to the second version of the application program according to the line code covered by the test and the line code 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 line code;
if the difference line code is determined to be covered by the test according to the second subcode coverage rate data, obtaining the line code covered by the test and the line code 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 line code corresponding to the second version of the application program according to the line code covered by the test and the line code 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 line code.
6. The method of claim 1, further comprising:
acquiring a code source file of a second version of the application program according to the second type file;
and 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.
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 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 the presence of a gas in the gas,
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 acquisition module is used for acquiring code difference information of a second source code of a second version of the application program relative to a first source code of a first version of the application program;
the second obtaining module is used for obtaining a second type of file obtained by compiling when testing the second source code and obtaining a first type of file obtained by compiling when testing the first source code;
a third 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 the code difference information in the second code coverage data file, and the third subcode coverage data is code coverage data, excluding the second subcode coverage data, in the second code coverage data file;
a fourth 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 code difference information is mapped in the first code coverage 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 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.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 7 are implemented when the computer program is executed by the processor.
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.
CN201911242850.1A 2019-12-06 2019-12-06 Code coverage rate processing method and device and computer equipment Active CN111124894B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911242850.1A CN111124894B (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
CN201911242850.1A CN111124894B (en) 2019-12-06 2019-12-06 Code coverage rate processing method and device and computer equipment

Publications (2)

Publication Number Publication Date
CN111124894A true CN111124894A (en) 2020-05-08
CN111124894B CN111124894B (en) 2023-04-28

Family

ID=70497789

Family Applications (1)

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

Country Status (1)

Country Link
CN (1) CN111124894B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112148590A (en) * 2020-08-27 2020-12-29 浙江大搜车融资租赁有限公司 Method, device and equipment for determining code coverage rate
CN112463620A (en) * 2020-12-03 2021-03-09 广州品唯软件有限公司 Coverage rate testing method and device in android software integration test
CN117349150A (en) * 2023-09-22 2024-01-05 乾升利信息技术(上海)有限公司 Coverage rate data processing method and device, electronic equipment and storage medium

Citations (6)

* 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
US20160299835A1 (en) * 2015-04-08 2016-10-13 Opshub, Inc. Method and system for providing delta code coverage information
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

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160299835A1 (en) * 2015-04-08 2016-10-13 Opshub, Inc. Method and system for providing delta code coverage information
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

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112148590A (en) * 2020-08-27 2020-12-29 浙江大搜车融资租赁有限公司 Method, device and equipment for determining code coverage rate
CN112148590B (en) * 2020-08-27 2022-11-04 浙江大搜车融资租赁有限公司 Method, device and equipment for determining code coverage rate
CN112463620A (en) * 2020-12-03 2021-03-09 广州品唯软件有限公司 Coverage rate testing method and device in android software integration test
CN117349150A (en) * 2023-09-22 2024-01-05 乾升利信息技术(上海)有限公司 Coverage rate data processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN111124894B (en) 2023-04-28

Similar Documents

Publication Publication Date Title
US10372594B2 (en) Method and device for retrieving test case based on code coverage
US9152731B2 (en) Detecting a broken point in a web application automatic test case
CN111124894A (en) Code coverage rate processing method and device and computer equipment
EP1130518A1 (en) Software analysis system having an apparatus for selectively collecting analysis data from a target system executing software instrumented with tag statements and method for use thereof
US20100274520A1 (en) Creation of test plans
US20180060224A1 (en) Distinguishing Public and Private Code in Testing Environments
CN109766261B (en) Coverage test method, coverage test device, computer equipment and storage medium
CN110231937B (en) Script defect scanning method, script defect scanning device, computer equipment and storage medium
CN111026647B (en) Method and device for acquiring code coverage rate, computer equipment and storage medium
CN109189405A (en) A kind of method and system of proving program Flash data consistency
CN110851351A (en) Deployment environment testing method and device, computer equipment and storage medium
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
CN115934503A (en) Program testing method, device, equipment and storage medium
CN112153375A (en) Front-end performance testing method, device, equipment and medium based on video information
CN111078549B (en) Code coverage rate processing method and device and computer equipment
CN112463620B (en) Coverage rate test method and device in android software integration test
CN111008138B (en) Method and device for processing code coverage rate and computer equipment
CN115080426A (en) Program file detection method and device, storage medium and electronic equipment
CN111090583B (en) Method and device for generating code coverage rate report and computer equipment
CN113656318A (en) Software version testing method and device and computer equipment
CN109902488A (en) APP tampering detection processing method, iOS device and storage medium
CN112363870B (en) Application program development processing method and device, computer equipment and storage medium
CN115828329A (en) Method, device, equipment and medium for monitoring and recovering version of automobile deployment package

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