CN111124894B - 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
CN111124894B
CN111124894B CN201911242850.1A CN201911242850A CN111124894B CN 111124894 B CN111124894 B CN 111124894B CN 201911242850 A CN201911242850 A CN 201911242850A CN 111124894 B CN111124894 B CN 111124894B
Authority
CN
China
Prior art keywords
code
difference
coverage rate
rate data
subcode
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911242850.1A
Other languages
Chinese (zh)
Other versions
CN111124894A (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 method, a device, a computer device and a storage medium for processing code coverage rate, wherein the method comprises the following steps: acquiring code difference information of a second source code of a second version of an application program and a first source code of a first version of the application program; 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 except code coverage data corresponding to code difference information from a code coverage data file of the first source code; and merging the first subcode coverage rate data with the third subcode coverage rate data to obtain fourth subcode coverage rate data, and generating a third subcode coverage rate data file according to the second subcode coverage rate data and the fourth subcode coverage rate data. The method can reduce code repetition test.

Description

Code coverage rate processing method and device and computer equipment
Technical Field
The present invention relates to the field of software testing technologies, and in particular, to a method and apparatus for processing code coverage, a computer device, and a storage medium.
Background
In software testing, statistics of code coverage are typically required for the software testing process. Code coverage characterizes how much code can be covered in a test. Typically, a software tester decides whether or not to repeatedly perform a software test by the level of code coverage.
In the current software test, the release version of an application consists of N measureable small versions. That is, for each version that is released outside of the pair, the developer will submit multiple small versions of the software development kit to the server. However, the code coverage rate data obtained in the test process between each small version cannot be directly combined because the identification codes of the compiled products of each submitted small version are different after the software test. If coverage rate data among all small versions cannot be combined, repeated tests are easily caused by directly referring to code coverage rate data of the current small version. For example, both the current small version and the last small version contain a certain code, which has been tested for coverage in the last version and not in the current small version, at which point the code needs to be retested with reference to the code coverage data of the current small version, thus resulting in retesting of the code.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a processing method, apparatus, computer device, and storage medium that can properly combine code coverage data of multiple versions of an application program to reduce code coverage for code retesting.
A method of processing code coverage, the method comprising: 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; acquiring a second type file compiled during testing of the second source code and acquiring a first type file compiled during testing of the first source code; acquiring a second code coverage rate data file generated when testing a second source code according to a second class 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 testing a first source code according to the first type file, and screening first subcode coverage rate data except code coverage rate data of code difference information mapped in the first code coverage rate data file from the first code coverage rate data file; and combining the first subcode coverage rate data with the third subcode coverage rate data to obtain combined fourth subcode coverage rate data, and generating a third subcode 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 rate further includes: determining a difference line code which is different from the first type file in the second type file according to the code difference information; the second subcode coverage rate data is code coverage rate data corresponding to the difference line code in the second code coverage rate data file; screening the first subcode coverage data except the code coverage data of the code difference information mapped in the first code coverage data file from the first code coverage data file, comprising the following steps: and screening the first subcode coverage data except the code coverage data of the difference line code mapping in the first code coverage data file from the first code coverage data file.
In one embodiment, determining a difference line code in the second type file, which is different from the first type file, according to the code difference information includes: acquiring a difference method name, a difference code branch name and/or a difference code label which are different from the first type file in the second type file according to the code difference information; if the difference method name exists, a difference method of the difference method name is obtained, and a difference line code existing in the difference method is obtained; if the difference code branch name exists, a difference code branch of the difference code branch name is obtained, and a difference line code existing in the difference code branch is obtained; if the marks of the difference codes exist, the difference codes corresponding to the marks of the difference codes are obtained, and the difference line codes are obtained according to the difference codes.
In one embodiment, the method for processing code coverage rate further includes: if the difference method name and the difference code branch name exist simultaneously, a difference method of the difference method name and a difference code branch of the difference code branch name are acquired, a first target line code which is different relative to the first type file in the second type file is acquired according to the difference method, a second target line code which is different relative to the first type file in the second type file is acquired according to the difference code branch, when the first target line code and the second target line code are matched, the first target line code or the second target line code is used as the difference line code, and when the first target line code and the second target line code are not matched, the first target line code and the second target line code are used as the difference 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 the difference code corresponding to the label of the difference code are acquired, a third target line code which is different from the first type file in the second type file is acquired according to the difference method, a fourth target line code which is different from the first type file in the second type file is acquired 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 and the fourth target line code are matched, and the third target line code and the fourth target line code are used 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 names and the marks of the difference codes exist at the same time, the difference codes of the marks of the difference codes and the difference code branches of the difference code branch names 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 codes, 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 branches, when the fifth target line code and the sixth target line code are matched, the fifth target line code or the sixth target line code is used as the difference line code, and when the fifth target line code and the sixth target line code are not matched, the fifth target line code and the sixth target line code are used as the difference line code.
In one embodiment, generating a third code coverage data file for a second version of the application from the second and 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 class file according to the coverage rate data of the fourth subcode; if the difference line codes are determined to be covered by the test according to the second subcode coverage rate data, obtaining line codes which are covered by the test and line codes which are 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 codes corresponding to the second version of the application program according to the line codes which are covered by the test and the line codes which are 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 codes; and if the differential line code is determined to be covered by the test according to the second subcode coverage rate data, acquiring the line code which is covered by the test and the line code which is 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 which is covered by the test and the line code which is not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the line code.
In one embodiment, the method for processing code coverage rate further includes: 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.
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 includes: marking the tested covered codes and the non-tested covered codes in the code source file according to the second subcode coverage data and the fourth subcode coverage data, and generating a code coverage report of a second version of the application program according to the marked code source file and the third subcode coverage data file; and/or marking out the difference codes 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.
A processing apparatus for code coverage, the apparatus comprising: a first acquisition module 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 acquisition module is used for acquiring a second type file obtained by compiling when testing the second source code and a first type file obtained by compiling when testing the first source code; the third acquisition module is used for acquiring a second code coverage rate data file generated when the second source code is tested according to the second type file, 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; 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 file, and screening first subcode coverage rate data except code coverage rate data of code difference information mapped in the first code coverage rate data file from the first code coverage rate data file; the generation module is used for combining the first subcode coverage rate data with the third subcode coverage rate data to obtain combined fourth subcode coverage rate data, and generating a third subcode 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.
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 any of the methods of the embodiments described above when the computer program is executed by the processor.
A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the method of any of the embodiments described above.
According to the processing method, the processing device, the computer equipment and the storage medium for the code coverage rate, the server acquires 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, acquires the second type file obtained by compiling when the second source code is tested and the first type file obtained by compiling when the first source code is tested, further acquires the second code coverage rate data file generated when the second source code is tested according to the second type file, and acquires 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 change of 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 file, screens out first subcode coverage rate data except code coverage rate data of code difference information mapped in the first code coverage rate data file from the first code coverage rate data file, and performs combination processing on the first subcode coverage rate data and third subcode coverage rate data, so that combination of the code coverage rate data except non-difference codes is realized. And finally, generating a third code coverage rate data file of the second version of the application program according to the fourth code coverage rate data obtained after the merging process and the second code coverage rate data corresponding to the difference code. Therefore, the server can acquire the code coverage rate data of the two versions respectively according to the class files in the compiling products of the two versions of the application program to carry out corresponding data combination, and meanwhile, a third code coverage rate data file of a second version is generated according to the code coverage rate data corresponding to the difference codes of the different versions of the combined data.
Drawings
FIG. 1 is an application environment diagram of a method of processing code coverage in one embodiment;
FIG. 2 is a flow chart of a method for processing code coverage in one embodiment;
FIG. 3 is a block diagram of a processing device for code coverage in one embodiment;
fig. 4 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
The processing method of the code coverage rate is applied to an application environment shown in fig. 1. The terminal 16 uploads a development kit of each version of the application program to the server 12 via a network connection, and the development kit includes a source code of the application program. The development packets of the versions uploaded by the terminal 16 include a plurality of development packets 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 the development kit of the application program through the network connection to perform a software test on the development kit. Meanwhile, after the terminal 18 performs the software test, a test product obtained by the test application is sent back to the server 12. The test product includes compiled products, such as class files, etc., obtained from each test. Server 12 stores the test products submitted by terminals 18 in database 14. When executing a code coverage processing method of the present application, the server 12 obtains 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 from the database 14, obtains a second type file obtained by compiling when testing the second source code, and obtains a first type file obtained by compiling when testing the first source code. 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 testing a first source code according to the first type file, and screening first subcode coverage rate data except code coverage rate data of code difference information mapped in the first code coverage rate data file from the first code coverage rate data file; and combining the first subcode coverage rate data with the third subcode coverage rate data to obtain combined fourth subcode coverage rate data, and generating a third subcode 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 notebook computers, desktop computers, or other computer devices. The server 12 may also be implemented as a server cluster made up 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 shown in fig. 2, the processing method of the code coverage rate includes the following steps:
s102, acquiring code difference information of second source codes of the second version of the application program relative to first source codes of the first version of the application program.
Each time a test terminal for executing a software test submits a test product to a server, the test terminal contains identification information for identifying the test product submitted at the time. The development terminal for developing the application program contains identification information for identifying the development kit submitted at the time each time the development kit is submitted to the server. And the server generates an identification list according to the identification information submitted by the test terminal and the development terminal and is used for recording the submitted records of all 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 of the second source code of the second version relative to the first source code of the first version of the application. The code difference information may include a code that differs from the first source code. The distinguished code may be a newly added code, a code modified on the basis of the first source code. And determining a difference line code, a difference method, a difference branch and the like which are different relative to the first type file in the second type file according to the difference code.
In a specific implementation process, a gitdiff command may be used to obtain diff logs (difference logs) of the second source code and the first source code, and code difference information is determined from the diff logs. Specifically, the server obtains the identification numbers of all the commit records of the current version a relative to the last version B, and generates an identification list. For example, the test terminal submits multiple 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 of a1, a2, a3, … …, an and the like, the server acquires the identification number B of the last submitted version of the last version B and the plurality of identification numbers a1, a2, a3, … …, an of the current version A, and an identification list is generated. The list of identifications may be expressed as completions [ b1, a2, a3 … … an ]. The completions identify the list name. At this time, the server obtains the second source code and the first source code according to the identification numbers of the second version and the first version in the communities. Wherein the identification number corresponding to each submitted small version can be identified with a hash value 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) mark file which can be identified by a script is generated, and code difference information between the first source code and the second source code is recorded by adopting the diff mark file. Furthermore, the first source code and the second source code may be source codes corresponding to any two versions. In a specific implementation, the first source code and the second source code are source code between the front and back versions. The diff mark file may record code difference information between the front and rear versions.
S104, obtaining the second type file obtained by compiling when testing the second source code and obtaining the 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 file obtained after compiling in the test process, that is, the class file, is uploaded to the server. And when the test terminal tests the first source code of the first version of the application program, uploading the first type file obtained after compiling in the test process, namely the class file, 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 submitted. The first version of the application may be any version previously submitted, such as the last version relative to the current version.
S106, acquiring a second code coverage rate data file generated when the second source code is tested according to the second type file, and acquiring second subcode coverage rate data and third subcode coverage rate data, wherein the second subcode coverage rate data is code coverage rate data corresponding to 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.
In this embodiment, when the test terminal tests the second source code, the second code coverage rate data file generated in the test process, that is, the ec file, 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 class file corresponding to the second source code, that is, the class file. The corresponding ec file can be read out through the class file. The server acquires second subcode coverage rate data corresponding to the code difference information from the second code coverage rate data file, acquires data except the second subcode coverage rate data in the second code coverage rate data file, and takes the data except the second subcode coverage rate data as third subcode coverage rate data. That is, the server divides the second code coverage data file corresponding to the second source code into two pieces of data, one piece of data is second subcode coverage data corresponding to the code difference information, and the other piece of data is data other than the second subcode coverage data.
S108, acquiring a first code coverage rate data file generated when testing the first source code according to the first type file, and screening first subcode 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 rate data file generated in the test process, that is, the ec file, is uploaded to the server. At this time, in the server, the ec file corresponding to the first source code is associated with the first type file corresponding to the first source code, that is, the class file. The corresponding ec file can be read out through the class file. The server screens the first subcode coverage data except the code coverage data of the code difference information mapped in the first code coverage data file from 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 rate data of the code difference information corresponding to the first source code mapped to the first code coverage rate data file. For example, the code differential information is information containing code that increases in the second version 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 containing the code modified by the second version relative to the first version, the code coverage data mapped into the first code coverage data file is code coverage data corresponding to the code before the modification of the first version. The other portion of the data is data other than the code coverage data mapped in the first code coverage data file.
S110, combining the first subcode coverage rate data with the third subcode coverage rate data to obtain combined fourth subcode coverage rate data, and generating a third subcode 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 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 performs the merging processing of the data between the second version and the first version except the code coverage data corresponding to the code difference information. The merging mode may be that when the same code is displayed as the test coverage in any data corresponding to the first subcode coverage data and the third subcode coverage data, the code is displayed as the test coverage in the merged fourth subcode coverage data. When the same code is displayed as untested coverage in the data corresponding to the first subcode coverage data and the third subcode coverage data, the code is displayed as untested coverage in the combined fourth subcode coverage data. For example, the code a is included in both the first version and the second version except for the difference code corresponding to the code difference information. And the code a is displayed as untested coverage in the data corresponding to the first subcode coverage data and the third subcode coverage data, and the code a is displayed as untested coverage in the combined fourth subcode coverage data. The code a is displayed as a tested coverage in any one of the data corresponding to the first subcode coverage data and the third subcode coverage data, which may be the tested coverage in the data of the first subcode coverage data or the tested coverage in the data of the third subcode coverage data, and then the code a is displayed as the tested coverage in the combined fourth subcode coverage data. Therefore, the coverage rate data of the fourth subcodes obtained after combination can accurately reflect the testing conditions of other source codes except the testing conditions of the source codes corresponding to the code difference information, and repeated testing of other source codes is avoided.
Further, the server generates a third code coverage data file for the second version of the application based on the second and fourth subcode coverage data. That is, the server generates a third code coverage data file of the second version of the application program according to the second code coverage data corresponding to the code difference information and the fourth code coverage data obtained by merging 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 processing method of the code coverage rate, the server acquires 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, acquires the second type file obtained by compiling when testing the second source code and the first type file obtained by compiling when testing the first source code, further acquires the second code coverage rate data file generated when testing the second source code according to the second type file, and acquires 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 change of 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 file, screens out first subcode coverage rate data except code coverage rate data of code difference information mapped in the first code coverage rate data file from the first code coverage rate data file, and performs combination processing on the first subcode coverage rate data and third subcode coverage rate data, so that combination of the code coverage rate data except non-difference codes is realized. And finally, generating a third code coverage rate data file of the second version of the application program according to the fourth code coverage rate data obtained after the merging process and the second code coverage rate data corresponding to the difference code. Therefore, the server can acquire the code coverage rate data of the two versions respectively according to the class files in the compiling products of the two versions of the application program to carry out corresponding data combination, and meanwhile, a third code coverage rate data file of a second version is generated according to the code coverage rate data corresponding to the difference codes of the different versions of the combined data.
In one embodiment, after step S102, further includes: and determining the differential line codes which are different from the first type files in the second type files according to the code differential information. At this time, the second subcode coverage data is code coverage data corresponding to the difference line code in the second code coverage data file. In step S106, screening the first subcode coverage data except the code coverage data of the code difference information mapped in the first code coverage data file from the first code coverage data file includes: and screening the first subcode coverage data except the code coverage data of the difference line code mapping in the first code coverage data file from the first code coverage data file.
In this embodiment, the code difference information includes difference line code information. And the server determines a difference line code which is different from the first type file in the second type file according to the code difference information. In the specific implementation process, the server reads the distinguishing codes existing in the second type of files relative to the first type of files according to the code difference information, and obtains the distinguishing line codes existing in the second type of files relative to the first type of files according to the distinguishing codes existing between the server and the second type of files. For example, assume that all codes in the second class file include code m, code n, and code s, and all codes in the first class 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 row where the code l is located is the difference row code.
In one embodiment, determining a difference line code in the second type of file that differs from the first type of file based on the code difference information includes: acquiring a difference method name, a difference code branch name and/or a difference code label which are different from the first type file in the second type file according to the code difference information; if the difference method name exists, a difference method of the difference method name is obtained, and a difference line code existing in the difference method is obtained; if the difference code branch name exists, a difference code branch of the difference code branch name is obtained, and a difference line code existing in the difference code branch is obtained; if the marks of the difference codes exist, the difference codes corresponding to the marks of the difference codes are obtained, and the difference line codes are obtained according to the difference codes.
In this embodiment, the server can acquire, from the code difference information, a difference method name, a difference code branch name, and a reference number of a difference code, which are different from those of the first-type file, in the second-type file. The difference method corresponding to the difference method name can contain a difference line code, and the difference code branch of the difference code branch name can also contain a difference line code. The difference line code may also be derived after the difference code determined from the labels of the difference codes. 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 difference code label, thereby improving the efficiency of obtaining the difference line code.
In an embodiment, determining, according to the code difference information, a difference line code in the second type file, which is different from the first type file, further includes: if the difference method name and the difference code branch name exist simultaneously, a difference method of the difference method name and a difference code branch of the difference code branch name are acquired, a first target line code which is different relative to the first type file in the second type file is acquired according to the difference method, a second target line code which is different relative to the first type file in the second type file is acquired according to the difference code branch, when the first target line code and the second target line code are matched, the first target line code or the second target line code is used as the difference line code, and when the first target line code and the second target line code are not matched, the first target line code and the second target line code are used as the difference 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 the difference code corresponding to the label of the difference code are acquired, a third target line code which is different from the first type file in the second type file is acquired according to the difference method, a fourth target line code which is different from the first type file in the second type file is acquired 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 and the fourth target line code are matched, and the third target line code and the fourth target line code are used 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 names and the marks of the difference codes exist at the same time, the difference codes of the marks of the difference codes and the difference code branches of the difference code branch names 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 codes, 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 branches, when the fifth target line code and the sixth target line code are matched, the fifth target line code or the sixth target line code is used as the difference line code, and when the fifth target line code and the sixth target line code are not matched, the fifth target line code and the sixth target line code are used as the difference line code.
In one embodiment, in step S110, a third code coverage data file for a second version of the application is generated from the second code coverage data and the fourth code coverage data, comprising: 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 class file according to the coverage rate data of the fourth subcode; if the difference line codes are determined to be covered by the test according to the second subcode coverage rate data, obtaining line codes which are covered by the test and line codes which are 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 codes corresponding to the second version of the application program according to the line codes which are covered by the test and the line codes which are 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 codes; and if the differential line code is determined to be covered by the test according to the second subcode coverage rate data, acquiring the line code which is covered by the test and the line code which is 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 which is covered by the test and the line code which is not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the line code.
In this embodiment, the second subcode coverage data corresponding to the difference line code in the second type file may determine that the difference line code is covered by the test, or the second subcode coverage data corresponding to the difference line code in the second type file may determine that the difference line code is not covered by the test. The fourth subcode coverage data may determine the first row of codes that have been covered by the test and the second row of codes that have not been covered by the test in the second class file. That is, whether the differential line code is tested and covered or not according to the second subcode coverage data corresponding to the differential line code in the second type file, the tested line code and the non-tested line code in the second version of the application program can be determined according to the second subcode coverage data and according to the fourth subcode coverage data, so that the code coverage of the line code corresponding to the second version of the application program is counted according to the tested line code and the non-tested line code in the second version of the application program, and then a third code coverage data file of the second version of the application program is generated according to the code coverage of the line code corresponding to the second version. Therefore, the third code coverage rate data file can truly reflect the code coverage rate of the second version of the application program in executing the code test process method.
In one embodiment, after step S110, further includes: 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.
In this embodiment, the code coverage data file of the application depends on a class file (class file). At the same time, the code source files of the application also depend on the class files. Corresponding code source files may be associated by class files. Thus, the server obtains a code source file of the second version of the application from the second class file and generates a code coverage report of the second version of the application from the third code coverage data file and the code source file. Therefore, besides the test condition of the source code corresponding to the second version of the application program can be displayed through the code coverage rate report, the code written by the corresponding research personnel can be displayed through the code source file, 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 includes: marking the tested covered codes and the non-tested covered codes in the code source file according to the second subcode coverage data and the fourth subcode coverage data; 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 this embodiment, the server marks the code which is covered by the test and/or the code which is not covered by the test in the code source file according to the second subcode coverage data corresponding to the differential line code, and marks the code which is covered by the test and/or the code which is not covered by the test in the code source file according to the fourth subcode coverage data, and finally the generated code coverage report contains the marked code information, so that the visibility of the code coverage report is further 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 includes: marking a difference code in a 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 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 rate report contains the marked code information, so that the visibility of the code coverage rate report is further improved.
It should be understood that, although the steps in the flowchart are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor does the order in which the sub-steps or stages are performed necessarily performed in sequence, but may be performed alternately or alternately with at least a portion of other steps or other steps.
The application also provides a processing device of code coverage rate, 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 an application program relative to a first source code of a first version of the application program;
the second obtaining module 20 is configured to obtain a second type file obtained by compiling when testing the second source code and obtain a first type file obtained by compiling when testing the first source code;
The third obtaining module 30 is configured to obtain, according to the second type file, a second code coverage data file generated when the second source code is tested, and obtain second subcode coverage data and third subcode coverage data, where the second subcode coverage data is code coverage data corresponding to 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 rate data file generated when the first source code is tested, and screen first subcode coverage rate data except 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;
the generating module 50 is configured to combine the first subcode coverage data with the third subcode coverage data to obtain combined fourth subcode coverage data, and generate a third subcode coverage data file of the second version of the application according to the second subcode coverage data and the fourth subcode coverage data.
In one embodiment, the processing device of code coverage further includes (not shown in fig. 3):
the determining module is used for determining a difference line code which is different from the first type file in the second type file according to the code difference information; the second subcode coverage rate data is code coverage rate data corresponding to the difference line code in the second code coverage rate data file;
the fourth acquisition module 40 includes a first acquisition unit for screening the first subcode coverage data except the code coverage data of the difference line code mapped in the first code coverage data file from the first code coverage data file.
In one embodiment, the determination module includes (not shown in FIG. 3): :
the second acquisition unit is used for acquiring a difference method name, a difference code branch name and/or a difference code label which are different from the first type file in the second type file according to the code difference information;
the third acquisition unit is used for acquiring a difference method of the difference method name if the difference method name exists, and acquiring a difference line code existing in the difference method;
a fourth obtaining unit, configured to obtain a difference code branch of the difference code branch name if the difference code branch name exists, and obtain a difference line code existing in the difference code branch;
And a fifth acquisition unit, configured to acquire, if there is a label of the difference code, a difference code corresponding to the label of the difference code, and acquire a difference line code according to the difference code.
In one embodiment, the determination module further comprises (not shown in fig. 3): :
a sixth obtaining unit, configured to obtain, if there are a difference method name and a difference code branch name at the same time, a difference method of the difference method name and a difference code branch of the difference code branch name, obtain, according to the difference method, a first object line code in the second type file that differs from the first type file, obtain, according to the difference code branch, a second object line code in the second type file that differs from the first type file, use, when the first object line code and the second object line code match, the first object line code or the second object line code as a difference line code, and use, when the first object line code and the second object line code do not match, both the first object line code and the second object line code as a difference line code;
a seventh obtaining unit, configured to obtain, if there are a difference method name and a label of the difference code at the same time, a difference method of the difference method name and a difference code corresponding to the label of the difference code, obtain, according to the difference method, a third target line code in the second type file that differs from the first type file, obtain, according to the difference code, a fourth target line code in the second type file that differs from the first type file, use 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 match, and use both 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 do not match;
An eighth obtaining unit, configured to obtain, if there are a branch name of the difference code and a label of the difference code at the same time, the difference code of the label of the difference code and a branch of the difference code of the branch name of the difference code, obtain, according to the difference code, a fifth target line code in the second type file that differs from the first type file, obtain, according to the branch of the difference code, a sixth target line code in the second type file that differs from the first type file, and when the fifth target line code and the sixth target line code match, use the fifth target line code or the sixth target line code as the difference line code, and when the fifth target line code and the sixth target line code do not match, use both the fifth target line code and the sixth target line code as the difference line code.
In one embodiment, the generation module includes (not shown in fig. 3):
a first determining unit, configured to determine, according to the fourth subcode coverage data, a first line code that has been covered by the test and a second line code that has not been covered by the test in the second class file;
the first generation unit is used for acquiring the line codes which are covered by the test and the line codes which are not covered by the test in the second version according to the determination result of the second subcode coverage data and the determination result of the fourth subcode coverage data when the difference line codes are determined to be covered by the test according to the second subcode coverage data, counting the code coverage of the line codes corresponding to the second version of the application program according to the line codes which are covered by the test and the line codes which are not covered by the test, and generating a third code coverage data file of the second version of the application program according to the code coverage of the line codes;
And the second generating unit is used for acquiring the line codes which are covered by the test and the line codes which are not covered by the test in the second version according to the determination result of the second subcode coverage data and the determination result of the fourth subcode coverage data when the difference line codes are determined to be covered by the test according to the second subcode coverage data, counting the code coverage of the line codes corresponding to the second version of the application program according to the line codes which are covered by the test and the line codes which are not covered by the test, and generating a third code coverage data file of the second version of the application program according to the code coverage of the line codes.
In one embodiment, the processing device of code coverage further includes (not shown in fig. 3):
a fifth obtaining module, configured to obtain a code source file of a second version of the application program according to the second type file;
and the first report generation 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) includes:
the first report generating unit is used for marking the codes which are tested and covered and the codes which are not tested and covered in the code source file according to the second subcode coverage data and the fourth subcode coverage data, and generating a code coverage report of a second version of the application program according to the marked code source file and the third subcode coverage data file; and/or the number of the groups of groups,
And marking out a difference code in the code source file according to the code difference information, and generating a code coverage report of a second version of the application program according to the marked code source file and the third code coverage data file.
The specific definition of the processing means for code coverage may be referred to as the definition of the processing method for code coverage hereinabove, and will not be described herein. The respective modules in the processing apparatus of the code coverage described above may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which 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 includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is used for being connected with an external terminal so as to interact data with the external terminal. The computer program is executed by a processor to implement a method of processing code coverage in any of the above embodiments.
Those skilled in the art will appreciate that the structures shown in FIG. 4 are block diagrams only and do not constitute a limitation of the computer device on which the present aspects apply, and that a particular computer device may include more or less components than those shown, or may combine some of the 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 steps of when executing the computer program:
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; acquiring a second type file compiled during testing of the second source code and acquiring a first type file compiled during testing of the first source code; acquiring a second code coverage rate data file generated when testing a second source code according to a second class 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 testing a first source code according to the first type file, and screening first subcode coverage rate data except code coverage rate data of code difference information mapped in the first code coverage rate data file from the first code coverage rate data file; and combining the first subcode coverage rate data with the third subcode coverage rate data to obtain combined fourth subcode coverage rate data, and generating a third subcode 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 from the first type file in the second type file according to the code difference information; the second subcode coverage rate data is code coverage rate data corresponding to the difference line code in the second code coverage rate data file; when the processor executes the computer program to realize the step of screening the first subcode 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, the following steps are specifically realized: and screening the first subcode coverage data except the code coverage data of the difference line code mapping in the first code coverage data file from the first code coverage data file.
In one embodiment, when the processor executes the computer program to implement the above step of determining, according to the code difference information, a difference line code in the second type file, which is different from the first type file, the following steps are specifically implemented: acquiring a difference method name, a difference code branch name and/or a difference code label which are different from the first type file in the second type file according to the code difference information; if the difference method name exists, a difference method of the difference method name is obtained, and a difference line code existing in the difference method is obtained; if the difference code branch name exists, a difference code branch of the difference code branch name is obtained, and a difference line code existing in the difference code branch is obtained; if the marks of the difference codes exist, the difference codes corresponding to the marks of the difference codes are obtained, and the difference line codes are obtained according to the difference codes.
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 simultaneously, a difference method of the difference method name and a difference code branch of the difference code branch name are acquired, a first target line code which is different relative to the first type file in the second type file is acquired according to the difference method, a second target line code which is different relative to the first type file in the second type file is acquired according to the difference code branch, when the first target line code and the second target line code are matched, the first target line code or the second target line code is used as the difference line code, and when the first target line code and the second target line code are not matched, the first target line code and the second target line code are used as the difference 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 the difference code corresponding to the label of the difference code are acquired, a third target line code which is different from the first type file in the second type file is acquired according to the difference method, a fourth target line code which is different from the first type file in the second type file is acquired 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 and the fourth target line code are matched, and the third target line code and the fourth target line code are used 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 names and the marks of the difference codes exist at the same time, the difference codes of the marks of the difference codes and the difference code branches of the difference code branch names 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 codes, 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 branches, when the fifth target line code and the sixth target line code are matched, the fifth target line code or the sixth target line code is used as the difference line code, and when the fifth target line code and the sixth target line code are not matched, the fifth target line code and the sixth target line code are used as the difference 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 code coverage data and the fourth code 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 class file according to the coverage rate data of the fourth subcode; if the difference line codes are determined to be covered by the test according to the second subcode coverage rate data, obtaining line codes which are covered by the test and line codes which are 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 codes corresponding to the second version of the application program according to the line codes which are covered by the test and the line codes which are 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 codes; and if the differential line code is determined to be covered by the test according to the second subcode coverage rate data, acquiring the line code which is covered by the test and the line code which is 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 which is covered by the test and the line code which is not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the 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; 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.
In one embodiment, when the processor executes the computer program to implement the code coverage reporting step of generating 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 the tested covered codes and the non-tested covered codes in the code source file according to the second subcode coverage data and the fourth subcode coverage data, and generating a code coverage report of a second version of the application program according to the marked code source file and the third subcode coverage data file; and/or marking out the difference codes 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:
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; acquiring a second type file compiled during testing of the second source code and acquiring a first type file compiled during testing of the first source code; acquiring a second code coverage rate data file generated when testing a second source code according to a second class 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 testing a first source code according to the first type file, and screening first subcode coverage rate data except code coverage rate data of code difference information mapped in the first code coverage rate data file from the first code coverage rate data file; and combining the first subcode coverage rate data with the third subcode coverage rate data to obtain combined fourth subcode coverage rate data, and generating a third subcode coverage rate data file of a second version of the application program according to the second subcode coverage rate data and the fourth subcode coverage rate data.
In one embodiment, the computer program when executed by a processor performs the steps of: determining a difference line code which is different from the first type file in the second type file according to the code difference information; the second subcode coverage rate data is code coverage rate data corresponding to the difference line code in the second code coverage rate data file; when the computer program is executed by the processor to realize the step of screening the first subcode coverage rate data except the code coverage rate data of the code difference information mapped in the first code coverage rate data file, the following steps are specifically realized: and screening the first subcode coverage data except the code coverage data of the difference line code mapping in the first code coverage data file from the first code coverage data file.
In one embodiment, when the computer program is executed by the processor to implement the above-mentioned step of determining, according to the code difference information, a difference line code in the second type file, which is different from the first type file, the following steps are specifically implemented: acquiring a difference method name, a difference code branch name and/or a difference code label which are different from the first type file in the second type file according to the code difference information; if the difference method name exists, a difference method of the difference method name is obtained, and a difference line code existing in the difference method is obtained; if the difference code branch name exists, a difference code branch of the difference code branch name is obtained, and a difference line code existing in the difference code branch is obtained; if the marks of the difference codes exist, the difference codes corresponding to the marks of the difference codes are obtained, and the difference line codes are obtained according to the difference codes.
In one embodiment, the computer program when executed by a processor performs the steps of: if the difference method name and the difference code branch name exist simultaneously, a difference method of the difference method name and a difference code branch of the difference code branch name are acquired, a first target line code which is different relative to the first type file in the second type file is acquired according to the difference method, a second target line code which is different relative to the first type file in the second type file is acquired according to the difference code branch, when the first target line code and the second target line code are matched, the first target line code or the second target line code is used as the difference line code, and when the first target line code and the second target line code are not matched, the first target line code and the second target line code are used as the difference 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 the difference code corresponding to the label of the difference code are acquired, a third target line code which is different from the first type file in the second type file is acquired according to the difference method, a fourth target line code which is different from the first type file in the second type file is acquired 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 and the fourth target line code are matched, and the third target line code and the fourth target line code are used 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 names and the marks of the difference codes exist at the same time, the difference codes of the marks of the difference codes and the difference code branches of the difference code branch names 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 codes, 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 branches, when the fifth target line code and the sixth target line code are matched, the fifth target line code or the sixth target line code is used as the difference line code, and when the fifth target line code and the sixth target line code are not matched, the fifth target line code and the sixth target line code are used as the difference 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 for the second version of the application program according to the second code coverage data and the fourth code 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 class file according to the coverage rate data of the fourth subcode; if the difference line codes are determined to be covered by the test according to the second subcode coverage rate data, obtaining line codes which are covered by the test and line codes which are 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 codes corresponding to the second version of the application program according to the line codes which are covered by the test and the line codes which are 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 codes; and if the differential line code is determined to be covered by the test according to the second subcode coverage rate data, acquiring the line code which is covered by the test and the line code which is 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 which is covered by the test and the line code which is not covered by the test, and generating a third code coverage rate data file of the second version of the application program according to the code coverage rate of the line code.
In one embodiment, the computer program when executed by a processor performs the steps of: 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.
In one embodiment, when the computer program is executed by the processor to implement the code coverage reporting step of generating the second version of the application program from the third code coverage data file and the code source file, the following steps are specifically implemented: marking the tested covered codes and the non-tested covered codes in the code source file according to the second subcode coverage data and the fourth subcode coverage data, and generating a code coverage report of a second version of the application program according to the marked code source file and the third subcode coverage data file; and/or marking out the difference codes 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.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the various embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile 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), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples merely represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the invention. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application is to be determined by the claims appended hereto.

Claims (9)

1. A method of processing code coverage, 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 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;
Determining a difference line code which is different from the first type file in the second type file according to the code difference information;
acquiring a second code coverage rate data file generated when the second source code is tested according to the second type file, and acquiring second subcode coverage rate data and third subcode coverage rate data, wherein the second subcode coverage rate data is code coverage rate data corresponding to the difference line code 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 testing the first source code according to the first type file, and screening first subcode coverage rate data except code coverage rate data of the difference line code mapped in the first code coverage rate data file from the first code coverage rate data file;
and combining the first subcode coverage rate data with the third subcode coverage rate data to obtain combined fourth subcode coverage rate data, and generating a third subcode coverage rate data file of the second version 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, wherein the determining, based on the code difference information, a difference row code in the second type of file that is different from the first type of file comprises:
acquiring a difference method name, a difference code branch name and/or a difference code label which are different from the first type file in the second type file according to the code difference information;
if the difference method name exists, a difference method of the difference method name is obtained, and the difference line code existing in the difference method is obtained;
if the difference code branch name exists, acquiring a difference code branch of the difference code branch name, and acquiring the difference line code existing in the difference code branch;
if the marks of the difference codes exist, obtaining the difference codes corresponding to the marks of the difference codes, and obtaining the difference line codes according to the difference codes.
3. The method according to claim 2, wherein the method further comprises:
if the difference method name and the difference code branch name exist simultaneously, 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 file in the second type file is obtained according to the difference method, a second target line code which is different from the first type file in the second type file is obtained according to the difference code branch, when the first target line code and the second target line code are matched, the first target line code or the second target line code is used as the difference line code, and when the first target line code and the second target line code are not matched, the first target line code and the second target line code are used as the difference 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 and the fourth target line code are matched, and the third target line code and the fourth target line code are used 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 of the difference code exist at the same time, obtaining the difference code of the label of the difference code and obtaining a 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 and the sixth target line code are matched, and taking the fifth target line code and the sixth target line code as the difference line code when the fifth target line code and the sixth target line code are not matched.
4. The method of claim 1, wherein the generating a third code coverage data file for the second version of the application from the second code coverage data and the fourth code 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 of files according to the coverage rate data of the fourth subcode;
if the difference line code is determined to be covered by the test according to the second subcode coverage data, acquiring the line code which is covered by the test and the line code which is not covered by the test in the second version according to the determination result of the second subcode coverage data and the determination result of the fourth subcode coverage data, counting the code coverage of the line code corresponding to the second version of the application program according to the line code which is covered by the test and the line code which is not covered by the test, and generating a third code coverage data file of the second version of the application program according to the code coverage of the line code;
and if the difference line codes are determined to be covered by the test according to the second subcode coverage rate data, acquiring the line codes which are covered by the test and the line codes which are 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 codes corresponding to the second version of the application program according to the line codes which are covered by the test and the line codes which are 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 codes.
5. The method according to claim 1, wherein the method further comprises:
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.
6. The method of claim 5, 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 the codes which are tested and covered and the codes which are not tested and covered in the code source file according to the second subcode coverage data and the fourth subcode coverage data, and generating a code coverage report of a second version of the application program according to the marked code source file and the third subcode coverage data file;
and/or the number of the groups of groups,
marking out a difference code in the code source file according to the code difference information, and generating a code coverage report of a second version of the application program according to the marked code source file and the third code coverage data file.
7. A processing apparatus for code coverage, the apparatus comprising:
a first acquisition module, configured to acquire 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;
the second acquisition module is used for acquiring a second type file compiled during testing of the second source code and a first type file compiled during testing of the first source code, and determining a difference line code which is different from the first type file in the second type file according to the code difference information;
the third acquisition module is used for acquiring a second code coverage rate data file generated when the second source code is tested according to the second type file, and acquiring second subcode coverage rate data and third subcode coverage rate data, wherein the second subcode coverage rate data is code coverage rate data corresponding to the difference line code 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;
A fourth obtaining module, configured to obtain, according to the first type file, a first code coverage rate data file generated when the first source code is tested, and screen first subcode coverage rate data excluding code coverage rate data of the difference line code mapped in the first code coverage rate data file from the first code coverage rate data file;
the generation module is used for combining the first subcode coverage rate data with the third subcode coverage rate data to obtain combined fourth subcode coverage rate data, and generating a third subcode coverage rate data file of the second version of the application program according to the second subcode coverage rate data and the fourth subcode coverage rate data.
8. 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 processor implements the steps of the method according to any one of claims 1 to 6 when the computer program is executed by the processor.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
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 CN111124894A (en) 2020-05-08
CN111124894B true 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)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108829580A (en) * 2018-05-07 2018-11-16 百度在线网络技术(北京)有限公司 Multi version test data processing method, device, equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10289532B2 (en) * 2015-04-08 2019-05-14 Opshub, Inc. Method and system for providing delta code coverage information
CN105404585B (en) * 2015-12-01 2018-09-04 腾讯科技(深圳)有限公司 Obtain the method and device of code coverage
CN108519945A (en) * 2018-03-21 2018-09-11 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage device
CN110209568B (en) * 2018-04-24 2022-07-01 腾讯科技(深圳)有限公司 Coverage rate test method and device and storage equipment
CN109388566B (en) * 2018-09-27 2022-07-29 北京城市网邻信息技术有限公司 Code coverage rate analysis method, device, equipment and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108829580A (en) * 2018-05-07 2018-11-16 百度在线网络技术(北京)有限公司 Multi version test data processing method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN111124894A (en) 2020-05-08

Similar Documents

Publication Publication Date Title
CN107665171B (en) Automatic regression testing method and device
US9317400B2 (en) Code coverage rate determination method and system
CN106874187B (en) Code coverage rate collection method and device
CN108959059B (en) Test method and test platform
CN108491321B (en) Method and device for determining test case range and storage medium
CN111290956B (en) Brain graph-based test method and device, electronic equipment and storage medium
CN111026647B (en) Method and device for acquiring code coverage rate, computer equipment and storage medium
CN108459850B (en) Method, device and system for generating test script
CN108549606A (en) interface test method and device
CN111124894B (en) Code coverage rate processing method and device and computer equipment
CN112363937B (en) Differential coverage rate testing method, differential coverage rate testing device, computer equipment and storage medium
CN111597069B (en) Program processing method, device, electronic equipment and storage medium
CN111078549B (en) Code coverage rate processing method and device and computer equipment
US10481969B2 (en) Configurable system wide tests
CN111008138B (en) Method and device for processing code coverage rate and computer equipment
CN115563008A (en) Code coverage rate detection system, method, device and storage medium
CN115934503A (en) Program testing method, device, equipment and storage medium
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
CN112631905A (en) Execution process data management method and device, computer equipment and storage medium
CN112486824B (en) Case code generation method, device, computer equipment and storage medium
CN115129355B (en) Page repair method, system and computer equipment thereof
CN117033203A (en) Method and device for determining association influence of change codes and electronic equipment
CN115545679A (en) Experimental data matching method and device, computer equipment and storage medium
CN113791980A (en) Test case conversion analysis method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant