CN117762813A - Method and device for acquiring coverage rate information of increment codes and electronic equipment - Google Patents

Method and device for acquiring coverage rate information of increment codes and electronic equipment Download PDF

Info

Publication number
CN117762813A
CN117762813A CN202311862898.9A CN202311862898A CN117762813A CN 117762813 A CN117762813 A CN 117762813A CN 202311862898 A CN202311862898 A CN 202311862898A CN 117762813 A CN117762813 A CN 117762813A
Authority
CN
China
Prior art keywords
code
information
coverage rate
function information
tested
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311862898.9A
Other languages
Chinese (zh)
Inventor
唐春鸽
黄俞荣
宋永政
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hillstone Networks Co Ltd
Original Assignee
Hillstone Networks 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 Hillstone Networks Co Ltd filed Critical Hillstone Networks Co Ltd
Priority to CN202311862898.9A priority Critical patent/CN117762813A/en
Publication of CN117762813A publication Critical patent/CN117762813A/en
Pending legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application discloses a method and a device for acquiring coverage rate information of increment codes and electronic equipment. The method comprises the following steps: performing first information verification on the version code to be tested to obtain a first verification result; under the condition that the first check result indicates that a code coverage rate report exists, performing second information check on the code coverage rate report to obtain a second check result; under the condition that the second check result indicates that the code coverage rate report meets the keyword filtering condition, determining target test content with coverage rate smaller than a preset coverage rate threshold value from the code coverage rate report, and determining second increment function information corresponding to the target test content from first increment function information, wherein the first increment function information is increment function information of the version code to be tested compared with the baseline version code; and performing unit test on the target test content based on the second incremental function information to obtain coverage rate information of the second incremental function information, thereby solving the problem of lower acquisition efficiency of the coverage rate information of the incremental codes.

Description

Method and device for acquiring coverage rate information of increment codes and electronic equipment
Technical Field
The present invention relates to the field of computers, and in particular, to a method and an apparatus for acquiring coverage rate information of an incremental code, and an electronic device.
Background
Unit testing is a small piece of code written by a developer to verify that a very small, well-defined function of the code under test is correct. Unit testing is an important means of ensuring software quality.
In the existing unit test, the method for acquiring coverage rate information of related incremental codes does not consider that after a large number of unit test cases are acquired, a developer only repairs the unit test efficiency in a small number of code scenes. For example, a developer only repairs a certain method in a file, but in the existing method for acquiring coverage rate information of incremental codes, all single test cases are operated on the version code to be tested to generate a coverage statistics file, and the version code to be tested and the baseline version code are required to be subjected to incremental comparison again, so that time consumption is increased in both operations, and further the technical problem of low acquisition efficiency of the coverage rate information of the incremental codes is caused.
Disclosure of Invention
The main purpose of the application is to provide a method and a device for acquiring coverage rate information of an incremental code and electronic equipment, so as to solve the problem of low acquisition efficiency of the coverage rate information of the incremental code in the related technology.
In order to achieve the above object, according to one aspect of the present application, there is provided a method of acquiring coverage information of an incremental code. The method comprises the following steps: performing first information verification on the version code to be tested to obtain a first verification result, wherein the first information verification is used for judging whether the version code to be tested has a generated code coverage rate report or not; under the condition that the first check result indicates that a code coverage rate report exists, performing second information check on the code coverage rate report to obtain a second check result, wherein the second information check is used for judging whether the code coverage rate report meets the keyword filtering condition, and when the coverage rate smaller than a preset coverage rate threshold exists in the code coverage rate report, the code coverage rate report meets the keyword filtering condition; under the condition that the code coverage rate report meets the keyword filtering condition, determining target test content with coverage rate smaller than a preset coverage rate threshold value from the code coverage rate report, and determining second incremental function information corresponding to the target test content from first incremental function information, wherein the first incremental function information is the incremental function information of the version code to be tested compared with the baseline version code; and performing unit test on the target test content based on the second increment function information to obtain coverage rate information of the second increment function information, wherein the version code to be tested comprises the target test content.
In order to achieve the above object, according to another aspect of the present application, there is provided an acquisition apparatus of coverage information of an incremental code. The device comprises: the first verification unit is used for carrying out first information verification on the version code to be tested to obtain a first verification result, wherein the first information verification is used for judging whether the version code to be tested has a generated code coverage rate report or not; the second verification unit is used for carrying out second information verification on the code coverage rate report to obtain a second verification result when the first verification result indicates that the code coverage rate report exists, wherein the second information verification is used for judging whether the code coverage rate report meets the keyword filtering condition, and when the code coverage rate report exists, the code coverage rate report meets the keyword filtering condition; the determining unit is used for determining target test contents with coverage rate smaller than a preset coverage rate threshold value from the code coverage rate report under the condition that the code coverage rate report is indicated by the second test result to meet the keyword filtering condition, and determining second increment function information corresponding to the target test contents from the first increment function information, wherein the first increment function information is increment function information of a version code to be tested compared with a baseline version code; and the test unit is used for carrying out unit test on the target test content based on the second increment function information to obtain coverage rate information of the second increment function information, wherein the version code to be tested comprises the target test content.
In order to achieve the above object, according to another aspect of the present application, there is provided a computer-readable storage medium having stored thereon a program which, when executed by a processor, implements the above-described method of acquiring coverage information of an incremental code.
In order to achieve the above object, according to another aspect of the present application, there is provided an electronic device for acquiring coverage information of an incremental code, where the electronic device includes a processor, a memory, and a program stored in the memory and executable on the processor, and the processor executes the program to implement the method for acquiring coverage information of the incremental code.
According to the embodiment provided by the application, through setting whether the generated first information checksum of the code coverage rate report and the second information checksum of the keyword filtering condition exist, the result of the last report is effectively utilized, the coverage statistics file is only generated for the code content which does not meet the requirement of the last unit test through the keyword filtering module, and the increment function information can be directly obtained from the increment function information of the last time, so that the time for generating the increment coverage information is greatly shortened, and the technical effect of improving the acquisition efficiency of the coverage rate information of the increment code is realized.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application, illustrate and explain the application and are not to be construed as limiting the application. In the drawings:
FIG. 1 is a flowchart of a method for obtaining coverage information of incremental codes provided according to an embodiment of the present application;
fig. 2 is a schematic diagram of a method for acquiring coverage information of an incremental code according to an embodiment of the present application;
fig. 3 is a schematic diagram of a method for acquiring coverage information of an incremental code according to an embodiment of the present application;
fig. 4 is a schematic diagram of a method for acquiring coverage information of an incremental code according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a method for obtaining coverage information of incremental codes provided according to an embodiment of the present application;
FIG. 6 is a schematic diagram of an apparatus for obtaining coverage information of incremental codes provided in accordance with an embodiment of the present application;
fig. 7 is a schematic diagram of an electronic device for acquiring coverage information of an incremental code according to an embodiment of the present application.
Detailed Description
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
In order to make the present application solution better understood by those skilled in the art, the following description will be made in detail and with reference to the accompanying drawings in the embodiments of the present application, it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe the embodiments of the present application described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that, related information (including, but not limited to, user equipment information, user personal information, etc.) and data (including, but not limited to, data for presentation, analyzed data, etc.) related to the present disclosure are information and data authorized by a user or sufficiently authorized by each party. For example, an interface is provided between the system and the relevant user or institution, before acquiring the relevant information, the system needs to send an acquisition request to the user or institution through the interface, and acquire the relevant information after receiving the consent information fed back by the user or institution.
The present invention will be described with reference to preferred implementation steps, and fig. 1 is a flowchart of a method for obtaining coverage information of incremental codes according to an embodiment of the present application, as shown in fig. 1, where the method includes the following steps:
step S101, performing first information verification on a version code to be tested to obtain a first verification result, wherein the first information verification is used for judging whether the version code to be tested has a generated code coverage rate report;
step S102, under the condition that the first check result indicates that a code coverage rate report exists, performing second information check on the code coverage rate report to obtain a second check result, wherein the second information check is used for judging whether the code coverage rate report meets the keyword filtering condition, and when the code coverage rate report has coverage rate smaller than a preset coverage rate threshold, the code coverage rate report meets the keyword filtering condition;
Step S103, under the condition that the second check result indicates that the code coverage report meets the keyword filtering condition, determining target test content with coverage smaller than a preset coverage threshold value from the code coverage report, and determining second increment function information corresponding to the target test content from first increment function information, wherein the first increment function information is increment function information of a version code to be tested compared with a baseline version code;
and step S104, performing unit test on the target test content based on the second increment function information to obtain coverage rate information of the second increment function information, wherein the version code to be tested comprises the target test content.
Alternatively, in the present embodiment, the method for acquiring coverage information of the increment code may be applied to a unit test scenario, but is not limited to the method. Unit testing is a small piece of code written by a developer to verify that a very small, well-defined function of the code under test is correct. Unit testing is an important means of ensuring software quality. The implementation of the unit test comprises the following steps: manual static checks, such as coderevelew, static code scans; dynamically performing tracking: and writing a test script to call the service code for testing. Each language has its own unit testing tools, such as Java: JUnit, testNG, python: unitTest, pyTest PHP PHP Unit. The unit test can enable the bug to be found as early as possible, so that the cost is reduced; the unit test case is the guarantee of the quality of the subsequent codes; unit testing can help develop quick detection and quick positioning problems. An important measure of unit testing is code coverage, which is to make the full coverage of the code as much as possible. Of greater concern to developers and testers is the coverage data of the incremental code.
In the existing unit test, although there is a method and a device for coverage rate information of relevant incremental codes, the method and the device do not consider that after a large number of unit test cases are acquired, a developer only repairs the unit test efficiency in a small number of code scenes. For example, a developer only repairs a certain method in a file, but in the existing method and device for coverage rate information of incremental codes, all single test cases are operated on the version code to be tested to generate a coverage statistics file, and the incremental comparison is required to be carried out on the version code to be tested and the baseline version code again, so that time consumption is increased in both operations.
Optionally, in this embodiment, before the first information verification is performed on the version code to be tested, the version code to be tested and the baseline version code are obtained.
Alternatively, in this embodiment, the baseline version code may be, but not limited to, a base of modification, addition, and deletion of the version code to be tested, and may be a previous version code of the version code to be tested, or may be a version code specified by a user.
Optionally, in this embodiment, the version code to be tested and the baseline version code corresponding to the version code to be tested are obtained, including all files and log files of the program code in the version.
Optionally, in this embodiment, before the first information verification is performed on the version code to be tested, the method further includes: judging whether to execute the reset operation or not for the version code to be tested, wherein the subsequent first information verification is further executed under the condition that the reset operation is not required to be executed; in case a reset operation needs to be performed, all irrelevant information is emptied and returned to the initial state.
Optionally, in this embodiment, the first information check is used to determine whether the version code to be tested has a generated code coverage report. It can be appreciated that the first information check is used to query whether there is a code coverage report corresponding to the version code to be tested already.
Alternatively, in this embodiment, the code coverage report may include, but is not limited to, information including line coverage information, function coverage information, delta line coverage information, delta function coverage information, and the like, where the line coverage is equal to a ratio of the number of code lines executed at least once to the total number of executable code lines, the function coverage is equal to a ratio of the number of functions already covered to the total number of functions, the delta line coverage is equal to a ratio of the number of delta function code lines executed at least once to the total number of delta function lines, and the delta function coverage is equal to a ratio of the number of delta function codes already covered to the total number of delta function lines, where the number of delta function code lines executed at least once and the number of delta function codes already covered may be obtained from the total code coverage information.
Optionally, in this embodiment, if the first check result indicates that there is a code coverage report, determining that the unit test is performed before the version code to be tested is determined, then further determining whether the keyword filtering condition is satisfied.
Optionally, in this embodiment, when there is no coverage smaller than a preset coverage threshold in the code coverage report, the code coverage report does not satisfy the keyword filtering condition.
It should be noted that, in the result indicated by the code coverage report obtained by the previous unit test, if the coverage of the code of the version to be tested is smaller than the preset coverage threshold, determining that the specified code content/target code content corresponding to the coverage of the code of the version to be tested is smaller than the preset coverage threshold is the target test content meeting the keyword filtering condition, and then performing the unit test on the target test content alone.
When the second check result indicates that the keyword filtering condition is met, determining second increment function information corresponding to the keyword filtering condition and determining target test content corresponding to the keyword filtering condition based on the code coverage rate report, and performing unit test on the target test content based on the second increment function information to obtain coverage rate information of the second increment function information.
It should be noted that, when the second checking result indicates that the code content corresponding to the coverage rate smaller than the preset coverage rate threshold exists, the test is executed, if the code content of the code to be tested is modified, the second information check is executed after the modification to determine whether the code content corresponding to the coverage rate smaller than the preset coverage rate threshold exists, and the loop execution is performed until the coverage rate of all the code content is smaller than the preset coverage rate threshold.
Through the embodiment provided by the application, the last reported result is effectively utilized, the coverage statistical file is only generated on the code content which does not meet the last unit test requirement through the keyword module, and the increment function information can be directly obtained from the last increment function information, so that the time for generating the increment coverage information is greatly shortened, and the development and test efficiency is improved.
As an alternative, determining second delta function information corresponding to the target test content from the first delta function information includes:
s11, acquiring a first change file of the version code to be tested relative to the baseline version code according to the code coverage rate report;
s12, determining a second change file corresponding to the keyword filtering condition from the first change file, wherein the second change file comprises a second newly added file, a second modified file and/or a second deleted file which meet the keyword filtering condition;
S13, obtaining second increment function information based on the second newly added file and the second modified file.
Alternatively, in this embodiment, the first modification file may include, but is not limited to, a first new file in which the version code to be tested is newly added with respect to the baseline version code, a modified first modification file, and a deleted first deletion file.
Optionally, in this embodiment, the second change file corresponding to the keyword filtering condition is a change file of a content corresponding to the target test content in the version code to be tested. Further, for example, the version code to be tested is set { a, B, C }, the corresponding first change file is set { a, B, C } (assuming that a corresponds to a, B corresponds to B, C corresponds to C), and the corresponding second change file is set { B }, if the target test content is set { a }.
Optionally, in this embodiment, the second incremental function information corresponding to the target test content is obtained by merging based on the second newly added file and the second modified file in the second change file.
It should be noted that, the unit test is performed on the target test content to obtain the code coverage rate information corresponding to the target test content, and the coverage rate information (i.e. the coverage rate information) of the increment code corresponding to the target test content is obtained by combining the second increment function information.
According to the embodiment provided by the application, the first change file of the version code to be detected relative to the baseline version code is obtained from the code coverage rate report, the second change file corresponding to the keyword filtering condition is determined from the first change file, and the second increment function information is obtained based on the second newly added file and the second modified file.
As an alternative, performing unit testing on the target test content based on the second incremental function information to obtain coverage rate information of the second incremental function information, including:
s21, determining code coverage rate information corresponding to target test content based on the code coverage rate report;
s22, utilizing the code coverage rate information and the second increment function information to determine the coverage rate information of the second increment function information.
Alternatively, in this embodiment, code coverage information corresponding to the target test content is determined from the information recorded in the code coverage report.
Optionally, in this embodiment, on the basis of obtaining the code coverage rate information, the coverage rate information of the increment code corresponding to the target test content (that is, the coverage rate information of the second increment function information) is obtained by combining the second increment function information.
According to the embodiment provided by the application, code coverage rate information corresponding to target test content is determined based on the code coverage rate report; and determining coverage information of the second increment function information by using the code coverage information and the second increment function information.
As an alternative, before the first change file of the version code to be tested with respect to the baseline version code is obtained from the code coverage report, the method further includes:
s31, a first change file of the version code to be detected relative to the baseline version code is obtained, wherein the first change file comprises a first new file, a first modification file and a first deletion file;
s32, combining the first information by utilizing the newly added function information indicated by the first newly added file and the modified function information indicated by the first modified file to obtain initial increment function information of the code to be tested;
s33, based on the incremental function information, performing initial unit test on the version code to be tested to obtain initial coverage information corresponding to the initial incremental function information, and obtaining a code coverage report based on the initial coverage information.
Optionally, in this embodiment, when the unit test is performed on the version code to be tested for the first time to obtain the code coverage report corresponding to the version code to be tested, a change file of the version code to be tested relative to the baseline version code is obtained and is divided into 3 types of processing: newly adding a file, modifying a file and deleting a file.
Note that, regarding whether the change state of the file is new, modified or deleted, there is a clear distinction between svn information.
Optionally, in this embodiment, the initial delta function information of the version code to be tested is obtained by merging based on the first new file and the first modified file in the first change file.
It should be noted that, the initial unit test is performed on the version code to be tested to obtain code coverage rate information corresponding to the version code to be tested, and the initial coverage rate information corresponding to the version code to be tested is obtained by combining the initial increment function information, wherein the code coverage rate report includes the initial coverage rate information.
According to the embodiment provided by the application, the first change file of the version code to be tested relative to the baseline version code is obtained, the first information is combined by utilizing the newly added function information indicated by the first newly added file and the modified function information indicated by the first modified file to obtain the initial increment function information of the version code to be tested, the initial unit test is carried out on the version code to be tested based on the increment function information to obtain the initial coverage rate information corresponding to the initial increment function information, and the code coverage rate report is obtained based on the initial coverage rate information.
As an alternative, after obtaining the first change file of the version code to be tested relative to the baseline version code, the method further includes:
s41, combining the second information by using the first deleting function information indicated by the first modified file and the second deleting function information indicated by the first deleted file to obtain initial deleting function information of the code to be tested;
s42, deleting the unit test cases corresponding to the initial deletion function information in the initial unit test.
Optionally, in this embodiment, the first delete function information in the first modification file and the second delete function information in the second delete file are combined to obtain initial delta function information of the version code to be tested.
Alternatively, in the present embodiment, for the initial deletion function information, the developer is notified to delete the unit test cases that are not in use.
As an alternative, before the first information verification is performed on the version code to be tested, the method further includes:
s51, acquiring a baseline version code associated with the version code to be tested;
s52, performing third information verification on the baseline version code to obtain a third verification result, wherein the third information verification is used for judging whether the baseline version code changes or not;
S53, when the third verification result indicates that the baseline version code is changed, the testing environment of the version code to be tested is adjusted to an initial state;
and S54, performing first information verification on the version code to be tested under the condition that the third verification result indicates that the baseline version code is unchanged.
Optionally, in this embodiment, before the first information verification is performed on the version code to be tested, the method further includes: and checking whether to execute the third information of the reset operation or not according to the base line version code related to the version code to be tested, wherein under the condition that the base line version code is changed, determining that the reset operation needs to be executed, clearing all irrelevant information, and returning to an initial state. Under the condition that the base line version code is unchanged, determining that the reset operation is not required to be executed, and further executing the subsequent first information verification; in case a reset operation needs to be performed, all irrelevant information is emptied and returned to the initial state.
As an alternative, after performing the second information verification on the code coverage report to obtain the second verification result, the method further includes at least one of the following steps:
s61, carrying out unit test on the version code to be tested based on the first increment function information under the condition that the first check result indicates that the code coverage rate report does not exist, so as to obtain coverage rate information of the first increment function information;
S62, under the condition that the second checking result indicates that the keyword filtering condition does not exist, the code coverage rate report is cleared, and unit testing is conducted on the to-be-tested version code based on the first increment function information corresponding to the to-be-tested version code, so that coverage rate information of the first increment function information is obtained.
Optionally, in this embodiment, if the first check result indicates that the code coverage rate report does not exist, unit testing is performed on the version code to be tested according to the first incremental function information, so as to obtain coverage rate information of the first incremental function information.
Optionally, in this embodiment, if the keyword filtering condition is not set, the code coverage rate report is cleared, all unit test cases are run on the version code to be tested, and then the incremental function information is combined to obtain the coverage rate information of the final incremental code.
If the keyword filtering condition is input, the corresponding unit test is executed only for the keyword filtering condition, and then the coverage rate information of the increment code containing the keyword is obtained according to the increment function information of the keyword filtering condition.
In the embodiments of the present disclosure, some or all of the steps and alternative implementations thereof may be arbitrarily combined with some or all of the steps in other embodiments, and may also be arbitrarily combined with alternative implementations of other embodiments.
As an alternative scheme, the method for acquiring coverage rate information of the incremental code is applied to a method and a device for generating an incremental PHP (Hypertext Preprocessor, hypertext preprocessor, which is an open-source general-purpose computer script language) code coverage rate report, and the method is divided into two parts: and one part is to acquire coverage rate information of the increment codes, and the other part is to test coverage rate codes which do not meet the conditions through a keyword filtering module, and whether the modified result meets the corresponding conditions or not.
The structural diagram of the two parts is shown in fig. 2. Specifically, the coverage information of the acquired incremental code is processed as follows:
performing unit test on the version code to be tested to obtain code coverage rate information of all functions wanted in the version code to be tested, obtaining incremental function information according to a change file of the version code to be tested relative to the baseline version code, and obtaining coverage rate information of the incremental code according to the whole code coverage rate information and the incremental function information.
Wherein reset module and filter module are used, reset module is used for clearing all the various conditions that set up in the device: such as a filtering module and a keyword filtering module, and the generated code coverage information. Instead of performing the reset process, the secondary process is generally performed by using a previously configured filtering module or keyword module or generated code coverage information, thereby improving efficiency.
After the resetting process is performed, files which do not want to perform coverage rate, for example, files which cannot perform unit test, such as files for which the unit test case is not completed, or unit test can be performed after the unit test case is really required to be reconstructed, or unit test is not performed temporarily, and then unit test is supported, and other files which are not php files are not required to perform php unit test, and the like, in the version to be tested can be designated in the filtering module.
And after the filtering module, carrying out unit test on the version code to be tested to obtain code coverage rate information of all functions wanted in the version code to be tested, obtaining a change file of the version code to be tested relative to the base line version code, and dividing the change file into 3 types for processing to obtain incremental function information and deletion function information. And obtaining coverage rate information of the increment codes by using the code coverage rate information of all the functions and the increment function information. The deleting function information is used for a developer to self-check whether the unused unit test cases are deleted or not, the consistency of the test functions of the unit test cases is maintained, meanwhile, the accumulation of invalid codes is prevented, corresponding space is occupied, and the subsequent updating and maintenance are facilitated.
And testing coverage rate codes which do not meet the conditions through a keyword filtering module, and judging whether the modified result meets the corresponding conditions or not, wherein the processing is as follows:
The method comprises the steps that a file and the like which are required to be subjected to unit test can be appointed through a keyword filtering module, unit test is only performed on appointed content, when a change file of a version code to be tested relative to a base line version code is obtained, the change file of the keyword filtering module is also obtained, incremental function information of keyword filtering conditions is obtained, and then incremental code coverage rate information based on keywords is obtained according to code coverage rate of the keyword functions and the keyword incremental function information.
The keyword filtering module can improve the efficiency of unit test, and especially greatly improves the efficiency of unit test under the condition that developers repair a small amount of codes.
With respect to the delta function information and the delete function information, a specific acquisition process is shown in fig. 3 below. Acquiring a change file of a version code to be tested relative to a baseline version code, and dividing the change file into 3 types of processing: newly adding a file, modifying a file and deleting a file. Regarding whether the change state of the file is new, modified or deleted, there is a clear distinction in svn information.
And counting newly added function information of the newly added file, and counting a newly added function list in the format of: addelementsARr= [ '/brands/aa/bb/cc/a.php' = > [ 'func1' = > range (2, 10), 'func2' = > range (12, 15), … funcn= > range (20, 30) ].
Considering that only filename is used for recording, filenames under different directories may be repeated, so that the filename is used as a key value, and the value can be used for recording function increment related information.
Comparing the code to be tested with the baseline code for the modification file, respectively counting modified function information and deleted function information, and counting the modified functions into a modified function list in the following format: modified elementsARr= [ '/brands/aa/bb/dd/d php' = > [ 'func1' = > range (2, 3), 'func2' = > range (7, 10), … funcn= > range (15, 20) ].
The deleted function is counted in a deleted function list in the format: deleteelementsARr= [ '/brandees/aa/bb/ff/f php' = > [ 'func1' = > range (2, 3), … funcn= > range (30, 35) ].
For deleted files, the deleted function information is counted into a deleted function list in the format of $deleteelementsARR= [ '/brandches/aa/bb/gg/g.php' = > [ 'func1' = > range (2, 4), … funcn= > range (15, 18) ].
And combining the newly added function list obtained by counting the newly added file with the modified function list obtained by modifying the file to obtain the incremental function information.
And merging the deleting function list obtained by modifying the file statistics and the deleting function list obtained by deleting the file to obtain deleting function information.
For the new function and the modified function, the blank line and the comment line need to be further processed, and the blank line and the comment line are not counted in the increment function, because the blank line and the comment line are not counted when the code coverage rate is calculated.
There are three annotation methods for PHP: /(sum/#).
For example: this is a single line of notes, # this is also a single line of notes,
/*
this is a multi-line comment block
It spans across
Multiple rows
*/。
Neither does the single row sum be counted into the number of code rows in the php unit test.
The empty rows and the row where the annotation is located are counted using regular expressions, counted in an array uneffectelementsARR, for example:
suppose that in the newly added file a, only the function testA is newly added as follows:
assuming public function testA ($param) is the first row, considering that only filename records are used, filenames under different directories may be repeated, so that filenames are used as key values, and an array can be used in the value values to record file names and function increment related information. Then $ uneffectelementsARr= [ '/brandles/aa/bb/cc/a php' = > [ 'testA' = > [2,3,7,9,10] ]; the new function array is added in the format of:
$addElementsArr=['/branches/aa/bb/cc/a.php'=>['testA'=>range(2,10)]]。
obtaining a final newly added result array according to the newly added function array addElementsARR and the recorded blank line and annotation array uneffectElementsARR: tempadd elementsARr= [ '/brandees/aa/bb/cc/a.php' = > [ 'testA' = > [4,5,6,8] ] ].
If there are multiple newly added functions in a.php, each is processed in the manner of testA, then it is expressed as:
$tempAddElementsArr=['/branches/aa/bb/cc/a.php'=>['func1'=>[4,5,6,8],'func2'=>[10,11,13],…,'funcn'=>range(50,64)]]。
modifying the function and the same theory, and finally obtaining:
$tempModifyElementsArr=['/branches/aa/bb/dd/d.php'=>['func1'=>[4,5],'func2'=>[7,8,9,10,11,13],…,'funcn'=>range(30,31,32)]];
and then combining the newly added function and the modified function to obtain final incremental function information: finalModifentsARr = [ '/brands/aa/bb/cc/a.php = > [' func1 '= > [4,5,6,8],' func2 '= > [10,11,13], …,' funcn '= > -range (50, 64) ],'/brands/aa/bb/dd/d.php '= > [' func1 '= > [4,5],' func2 '= > [7,8,9,10,11,13], …,' funcn '= > -range (30, 31, 32) ], …'/brands/aa/bb/ff/f.php '= > [ -func1' = -range (2, 8), 'func2' = > [9,10,11], …, 'funcn' = -range (40, 41) ].
And carrying out unit test on the version code to be tested to obtain the whole code coverage rate information, and then obtaining the coverage rate information of the increment code together with the increment function information.
According to the overall code coverage rate information and the incremental function information, the coverage rate information of the incremental code is obtained, and the calculation mode is as follows:
line coverage = number of lines of code executed at least once/total number of lines of code executable;
function coverage = number of functions covered/total number of functions;
increment line coverage = increment function code line number/total increment code line number executed at least once;
Delta function coverage = number of delta functions that have been covered/sum of all delta functions;
here, the number of increment function code lines executed at least once and the number of increment functions that have been covered may be obtained from the overall code coverage information.
The total number of rows of all increment codes and the total sum of all increment functions can be directly obtained from the final increment function information $ finalModifyElementsARr. For example: [ '/fungi/aa/bb/cc/a.php' = > [ 'func1' = > [4,5,6,8], 'func2' = > [10,11,13], …, 'funcn' = > -range (50, 64) ].
Calculating the total number of lines of all increment codes in the a.php, and calculating the number of lines of the newly added codes of the lower func 1: count ([ 4,5,6,8 ])=4; calculating the number of new code lines of the lower func 2: count ([ 10,11,13 ])=3; calculating the number of new added code lines of the following funcn: count (range (50, 64))=15; all the sums are added up.
And calculating how many funcn are in each file according to the sum of all the increment functions, and adding up the funcn sum in all the files according to all the increment functions.
And for the deleting function information, notifying a developer of deleting the unused unit test cases.
Regarding the keyword filtering module: the delta function information part of the key filter term, see fig. 4 below, can be obtained directly from $ finalmodifeelementsarr without re-performing the secondary calculation. For example:
$finalModifyElementsArr=['/branches/aa/bb/cc/a.php'=>['func1'=>[4,5,6,8],'func2'=>[10,11,13],…,'funcn'=>range(50,64)],'/branches/aa/bb/dd/d.php'=>['func1'=>[4,5],'func2'=>[7,8,9,10,11,13],…,'funcn'=>range(30,31,32)],…'/branches/aa/bb/ff/f.php'=>['func1'=>range(2,8),'func2'=>[9,10,11],…,'funcn'=>range(40,41)]]。
If the entered keyword filtering information is a complete path, such as: '/brandies/aa/bb/cc/a.php', the delta function information is: [ 'func1' = > [4,5,6,8], 'func2' = > [10,11,13], …, 'funcn' = > range (50, 64) ].
If the input keyword filtering information is partial content, such as a.php, traversing all $finalModifyElementsARs, and acquiring all the increment information meeting the a.php, wherein the final increment code coverage information also comprises all the increment code coverage information meeting the keyword condition.
Details of the processing as shown in fig. 5 are included with respect to the key module and the reset module. And executing the reset operation, clearing all irrelevant information, and returning to the initial state. If the code of the version to be tested is switched at this time, if the clearing processing is not performed on the coverage report existing before, the correct result of the code coverage is affected, so that the corresponding clearing processing is considered to be added.
If the reset operation is not executed, checking whether a code coverage rate report is generated, if the code coverage rate report is not generated, running all unit test cases for the version code to be tested, and then combining the increment function information to obtain the coverage rate information of the final increment code.
If the code coverage rate report has been generated, checking whether a keyword filtering condition is input (note that the keyword filtering condition is cleared correspondingly when the version code to be tested is switched every time), if the keyword filtering condition is input, executing corresponding unit test on the keyword filtering condition only, and then obtaining coverage rate information of the increment code containing the keyword according to the increment function information of the keyword filtering condition.
And if the keyword filtering condition is not set, clearing the code coverage rate report, running all unit test cases of the code to be tested, and then combining the increment function information to obtain the coverage rate information of the final increment code.
It should be noted that, when the incremental coverage information obtained through the version code to be tested and the baseline version code assumes that only one file a.php in the incremental coverage information does not meet the requirement, after development and modification, when the incremental PHP code coverage reporting device is reused, all single test cases need to be operated on the version code to be tested again to generate the coverage statistics file, and the incremental function information needs to be recalculated, especially when the code quantity is large, the consumed time is long.
By using the generating method, the last reported result can be effectively utilized, the coverage statistical file is only generated for the a.php through the keyword module, and the increment function information can be directly obtained from the last increment function information, so that the time for generating the increment coverage information is greatly shortened, and the development and test efficiency is improved.
By the embodiment provided by the application, the generation method and the device for the incremental PHP code coverage rate report are provided, the function of clearing historical data is improved, the last reported result can be effectively utilized, and the unit test efficiency of a developer in a small number of code repairing scenes can be greatly improved. Meanwhile, development and clearing of redundant unit test cases can be informed, the one-to-one correspondence between the test cases and codes is maintained, and the unit test cases can be favorably handed over and maintained. And a keyword processing module and a resetting module are added, so that when a developer repairs a small number of code scenes, unit test can be directly carried out through specified keywords, and development efficiency is improved. The function of clearing historical data is improved, the result of the last coverage report can be effectively utilized on the basis of not carrying out reset processing, the time of running all single test cases for the code to be tested each time is greatly shortened, and the unit test efficiency is improved. The deletion function or the file is added, but the file and the unit test case are consistent under the condition that the corresponding unit test case is not synchronously processed, so that convenience in later maintenance is facilitated. To clean the garbage in time, the codes are kept clean and tidy.
In the embodiments of the present disclosure, some or all of the steps and alternative implementations thereof may be arbitrarily combined with some or all of the steps in other embodiments, and may also be arbitrarily combined with alternative implementations of other embodiments.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
The embodiment of the application also provides a coverage rate information acquisition device of the increment code, and it is to be noted that the coverage rate information acquisition device of the increment code of the embodiment of the application can be used for executing the coverage rate information acquisition method for the increment code provided by the embodiment of the application. The following describes an apparatus for acquiring coverage information of an incremental code provided in the embodiment of the present application.
Fig. 6 is a schematic diagram of an acquisition apparatus of coverage information of an incremental code according to an embodiment of the present application. As shown in fig. 6, the apparatus includes:
the first verification unit 602 is configured to perform a first information verification on the version code to be tested to obtain a first verification result, where the first information verification is used to determine whether the version code to be tested has a generated code coverage report;
A second checking unit 604, configured to perform a second information check on the code coverage report to obtain a second checking result when the first checking result indicates that the code coverage report exists, where the second information check is used to determine whether the code coverage report meets a keyword filtering condition, and when there is coverage less than a preset coverage threshold in the code coverage report, the code coverage report meets the keyword filtering condition;
a determining unit 606, configured to determine, when the second test result indicates that the code coverage report meets the keyword filtering condition, target test content with coverage smaller than a preset coverage threshold from the code coverage report, and determine second delta function information corresponding to the target test content from the first delta function information, where the first delta function information is delta function information of a version code to be tested compared with a baseline version code;
and the test unit 608 is configured to perform a unit test on the target test content based on the second incremental function information to obtain coverage information of the second incremental function information, where the version code to be tested includes the target test content.
Alternatively, in the present embodiment, the above-described acquisition device of coverage information of the incremental code may be applied to, but not limited to, a unit test scenario. Unit testing is a small piece of code written by a developer to verify that a very small, well-defined function of the code under test is correct. Unit testing is an important means of ensuring software quality. The implementation of the unit test comprises the following steps: manual static checks, such as coderevelew, static code scans; dynamically performing tracking: and writing a test script to call the service code for testing. Each language has its own unit testing tools, such as Java: JUnit, testNG, python: unitTest, pyTest PHP PHP Unit. The unit test can enable the bug to be found as early as possible, so that the cost is reduced; the unit test case is the guarantee of the quality of the subsequent codes; unit testing can help develop quick detection and quick positioning problems. An important measure of unit testing is code coverage, which is to make the full coverage of the code as much as possible. Of greater concern to developers and testers is the coverage data of the incremental code.
In the existing unit test, although there is a method and a device for coverage rate information of relevant incremental codes, the method and the device do not consider that after a large number of unit test cases are acquired, a developer only repairs the unit test efficiency in a small number of code scenes. For example, a developer only repairs a certain method in a file, but in the existing method and device for coverage rate information of incremental codes, all single test cases are operated on the version code to be tested to generate a coverage statistics file, and the incremental comparison is required to be carried out on the version code to be tested and the baseline version code again, so that time consumption is increased in both operations.
Optionally, in this embodiment, before the first information verification is performed on the version code to be tested, the version code to be tested and the baseline version code are obtained.
Alternatively, in this embodiment, the baseline version code may be, but not limited to, a base of modification, addition, and deletion of the version code to be tested, and may be a previous version code of the version code to be tested, or may be a version code specified by a user.
Optionally, in this embodiment, the version code to be tested and the baseline version code corresponding to the version code to be tested are obtained, including all files and log files of the program code in the version.
Optionally, in this embodiment, before the first information verification is performed on the version code to be tested, the method further includes: judging whether to execute the reset operation or not for the version code to be tested, wherein the subsequent first information verification is further executed under the condition that the reset operation is not required to be executed; in case a reset operation needs to be performed, all irrelevant information is emptied and returned to the initial state.
Optionally, in this embodiment, the first information check is used to determine whether the version code to be tested has a generated code coverage report. It can be appreciated that the first information check is used to query whether there is a code coverage report corresponding to the version code to be tested already.
Alternatively, in this embodiment, the code coverage report may include, but is not limited to, information including line coverage information, function coverage information, delta line coverage information, delta function coverage information, and the like, where line coverage is equal to at least one time of the number of code lines/total number of executable code lines, function coverage is equal to at least one time of the number of functions covered/total number of functions, delta line coverage is equal to at least one time of the number of delta function codes/total number of delta function lines, delta function coverage is equal to at least one time of the number of delta function lines covered/total number of delta function, delta function code lines executed at least one time and the number of delta function lines covered are obtained from the total code coverage information.
Optionally, in this embodiment, if the first check result indicates that there is a code coverage report, determining that the unit test is performed before the version code to be tested is determined, then further determining whether the keyword filtering condition is satisfied.
It should be noted that, in the result indicated by the code coverage report obtained by the previous unit test, if the coverage of the code of the version to be tested is smaller than the preset coverage threshold, determining that the specified code content or the target code content corresponding to the coverage of the code of the version to be tested is smaller than the preset coverage threshold is the target test content meeting the keyword filtering condition, and then performing the unit test on the target test content alone.
When the second check result indicates that the keyword filtering condition is met, determining second increment function information corresponding to the keyword filtering condition and determining target test content corresponding to the keyword filtering condition based on the code coverage rate report, and performing unit test on the target test content based on the second increment function information to obtain coverage rate information of the second increment function information.
Through the embodiment provided by the application, the last reported result is effectively utilized, the coverage statistical file is only generated on the code content which does not meet the last unit test requirement through the keyword module, and the increment function information can be directly obtained from the last increment function information, so that the time for generating the increment coverage information is greatly shortened, and the development and test efficiency is improved.
As an alternative, the determining unit 606 includes:
the first acquisition module is used for acquiring a first change file of the version code to be detected relative to the baseline version code from the code coverage rate report;
the first determining module is used for determining a second change file corresponding to the keyword filtering condition from the first change file, wherein the second change file comprises a second newly added file, a second modified file and/or a second deleted file which meet the keyword filtering condition;
and the second determining module is used for obtaining second increment function information based on the second newly added file and the second modified file.
As an alternative, the test unit 608 includes:
the third determining module is used for determining code coverage rate information corresponding to the target test content based on the code coverage rate report;
and the fourth determining module is used for determining coverage rate information of the second increment function information by utilizing the code coverage rate information and the second increment function information.
As an alternative, the apparatus further includes:
the second acquisition module is used for acquiring a first change file of the version code to be tested relative to the baseline version code before acquiring the first change file of the version code to be tested relative to the baseline version code from the code coverage rate report, wherein the first change file comprises a first new file, a first modification file and a first deletion file;
The first merging module is used for merging first information by utilizing the newly added function information indicated by the first newly added file and the modified function information indicated by the first modified file before acquiring a first change file of the version code to be tested relative to the baseline version code from the code coverage rate report, so as to obtain initial increment function information of the version code to be tested;
the first test module is used for carrying out initial unit test on the version code to be tested based on the incremental function information before a first change file of the version code to be tested relative to the baseline version code is obtained from the code coverage rate report, obtaining initial coverage rate information corresponding to the initial incremental function information, and obtaining the code coverage rate report based on the initial coverage rate information.
As an alternative, the apparatus further includes:
the second merging module is used for merging second information by utilizing first deleting function information indicated by the first modified file and second deleting function information indicated by the first deleted file after acquiring a first changed file of the version code to be tested relative to the baseline version code, so as to obtain initial deleting function information of the version code to be tested;
And the deleting module is used for deleting the unit test cases corresponding to the initial deleting function information in the initial unit test after the first change file of the version code to be detected relative to the baseline version code is acquired.
As an alternative, the apparatus further includes:
the third acquisition module is used for acquiring a baseline version code associated with the version code to be tested before the first information verification is carried out on the version code to be tested;
the first verification module is used for carrying out third information verification on the base line version code before carrying out first information verification on the version code to be tested to obtain a third verification result, wherein the third information verification is used for judging whether the base line version code changes or not;
the adjustment module is used for adjusting the testing environment of the version code to be tested to an initial state under the condition that the third checking result indicates that the baseline version code is changed before the first information checking is carried out on the version code to be tested;
the second checking module is used for checking the first information of the version code to be tested under the condition that the third checking result indicates that the baseline version code is unchanged before checking the first information of the version code to be tested.
As an alternative, the apparatus further includes:
the second test module is used for carrying out unit test on the version code to be tested based on the first increment function information to obtain coverage rate information of the first increment function information under the condition that the first check result indicates that the code coverage rate report does not exist;
and the third test module is used for clearing the code coverage rate report under the condition that the second test result indicates that the keyword filtering condition does not exist, and carrying out unit test on the version code to be tested based on the first increment function information corresponding to the version code to be tested to obtain coverage rate information of the first increment function information.
The embodiment of the invention provides a computer readable storage medium, on which a program is stored, which when executed by a processor, implements the method for acquiring coverage information of an increment code.
The embodiment of the invention provides a processor for running a program, wherein the program runs to execute the method for acquiring coverage rate information of an increment code.
As shown in fig. 7, an embodiment of the present invention provides an electronic device, where the device includes a processor, a memory, and a program stored in the memory and capable of running on the processor, and the processor implements a method for acquiring coverage information of the incremental code when executing the program.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one, and the kernel parameters are adjusted to train or optimize the target model, so that the data loading efficiency is improved.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (10)

1. The method for acquiring the coverage rate information of the increment code is characterized by comprising the following steps of:
performing first information verification on the version code to be tested to obtain a first verification result, wherein the first information verification is used for judging whether the version code to be tested has a generated code coverage rate report or not;
If the first check result indicates that the code coverage rate report exists, performing second information check on the code coverage rate report to obtain a second check result, wherein the second information check is used for judging whether the code coverage rate report meets a keyword filtering condition, and if so, the code coverage rate report meets the keyword filtering condition;
under the condition that the second check result indicates that the code coverage rate report meets the keyword filtering condition, determining target test content with the coverage rate smaller than the preset coverage rate threshold value from the code coverage rate report, and determining second increment function information corresponding to the target test content from first increment function information, wherein the first increment function information is increment function information of the version code to be tested compared with a baseline version code;
and performing unit test on the target test content based on the second increment function information to obtain coverage rate information of the second increment function information, wherein the version code to be tested comprises the target test content.
2. The method of claim 1, wherein determining second delta function information corresponding to the target test content from the first delta function information comprises:
acquiring a first change file of the version code to be tested relative to a baseline version code according to the code coverage report;
determining a second change file corresponding to the keyword filtering condition from the first change file, wherein the second change file comprises a second newly added file, a second modified file and/or a second deleted file which meet the keyword filtering condition;
and obtaining the second increment function information based on the second newly added file and the second modified file.
3. The method according to claim 2, wherein performing the unit test on the target test content based on the second delta function information to obtain coverage information of the second delta function information includes:
determining code coverage rate information corresponding to the target test content based on the code coverage rate report;
and determining coverage rate information of the second increment function information by utilizing the code coverage rate information and the second increment function information.
4. The method of claim 2, wherein prior to the obtaining the first change file of the version code under test relative to a baseline version code from the code coverage report, the method further comprises:
acquiring the first change file of the version code to be tested relative to the baseline version code, wherein the first change file comprises the first new file, the first modification file and the first deletion file;
combining first information by utilizing the newly added function information indicated by the first newly added file and the modified function information indicated by the first modified file to obtain initial increment function information of the code to be tested;
and carrying out initial unit test on the version code to be tested based on the incremental function information to obtain initial coverage rate information corresponding to the initial incremental function information, and obtaining the code coverage rate report based on the initial coverage rate information.
5. The method of claim 4, wherein after the obtaining the first change file for the version code under test relative to the baseline version code, the method further comprises:
Combining second information by using first deleting function information indicated by the first modified file and second deleting function information indicated by the first deleted file to obtain initial deleting function information of the version code to be detected;
and deleting the unit test cases corresponding to the initial deletion function information in the initial unit test.
6. The method according to any one of claims 1 to 5, wherein prior to said first information verification of the version code under test, the method further comprises:
acquiring a baseline version code associated with the version code to be tested;
third information verification is carried out on the baseline version code to obtain a third verification result, wherein the third information verification is used for judging whether the baseline version code changes or not;
when the third verification result indicates that the baseline version code is changed, adjusting the testing environment of the version code to be tested to an initial state;
and under the condition that the third checking result indicates that the baseline version code is unchanged, checking the first information of the version code to be checked.
7. The method according to any one of claims 1 to 5, further comprising:
performing unit test on the version code to be tested based on the first increment function information under the condition that the first check result indicates that the code coverage rate report does not exist, so as to obtain coverage rate information of the first increment function information; and/or the number of the groups of groups,
and under the condition that the second checking result indicates that the keyword filtering condition does not exist, clearing the code coverage rate report, and performing unit testing on the version code to be tested based on the first increment function information corresponding to the version code to be tested to obtain coverage rate information of the first increment function information.
8. An apparatus for acquiring coverage information of an incremental code, comprising:
the first verification unit is used for carrying out first information verification on the version code to be tested to obtain a first verification result, wherein the first information verification is used for judging whether the version code to be tested has a generated code coverage rate report or not;
the second verification unit is used for carrying out second information verification on the code coverage rate report to obtain a second verification result when the first verification result indicates that the code coverage rate report exists, wherein the second information verification is used for judging whether the code coverage rate report meets the keyword filtering condition, and when the coverage rate smaller than a preset coverage rate threshold exists in the code coverage rate report, the code coverage rate report meets the keyword filtering condition;
The determining unit is used for determining target test content with coverage rate smaller than the preset coverage rate threshold value from the code coverage rate report and determining second increment function information corresponding to the target test content from first increment function information under the condition that the second check result indicates that the code coverage rate report meets the keyword filtering condition, wherein the first increment function information is increment function information of the version code to be tested compared with a baseline version code;
and the testing unit is used for carrying out unit testing on the target testing content based on the second increment function information to obtain coverage rate information of the second increment function information, wherein the version code to be tested comprises the target testing content.
9. A computer readable storage medium, characterized in that a program is stored thereon, which program, when being executed by a processor, implements the method of any of claims 1 to 7.
10. An electronic device comprising one or more processors and memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1-7.
CN202311862898.9A 2023-12-29 2023-12-29 Method and device for acquiring coverage rate information of increment codes and electronic equipment Pending CN117762813A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311862898.9A CN117762813A (en) 2023-12-29 2023-12-29 Method and device for acquiring coverage rate information of increment codes and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311862898.9A CN117762813A (en) 2023-12-29 2023-12-29 Method and device for acquiring coverage rate information of increment codes and electronic equipment

Publications (1)

Publication Number Publication Date
CN117762813A true CN117762813A (en) 2024-03-26

Family

ID=90318253

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311862898.9A Pending CN117762813A (en) 2023-12-29 2023-12-29 Method and device for acquiring coverage rate information of increment codes and electronic equipment

Country Status (1)

Country Link
CN (1) CN117762813A (en)

Similar Documents

Publication Publication Date Title
JP5933762B2 (en) Code coverage rate determination method and system
CN108459962B (en) Code normalization detection method and device, terminal equipment and storage medium
US9898387B2 (en) Development tools for logging and analyzing software bugs
US8938729B2 (en) Two pass automated application instrumentation
US8352921B2 (en) Static analysis defect detection in the presence of virtual function calls
US8832125B2 (en) Extensible event-driven log analysis framework
US20090287729A1 (en) Source code coverage testing
US20120260240A1 (en) Software build optimization
US7712087B2 (en) Methods and systems for identifying intermittent errors in a distributed code development environment
US9740595B2 (en) Method and apparatus for producing a benchmark application for performance testing
US9959199B2 (en) Diagnosis of test failures in software programs
US9442717B2 (en) Techniques for automatically identifying input files used to generate output files in a software build process
CN107451058B (en) Software development method and device
CN110879781A (en) Program debugging method and device, electronic equipment and computer readable storage medium
US20140336986A1 (en) Automatic correlation accelerator
CN113742200B (en) Database version upgrade test method, equipment and computer readable medium
US11151020B1 (en) Method and system for managing deployment of software application components in a continuous development pipeline
CN112416417A (en) Code amount statistical method and device, electronic equipment and storage medium
CN117687920A (en) Interface testing method and device, storage medium and electronic equipment
Möller et al. EvoBench–a framework for benchmarking schema evolution in NoSQL
CN111435327B (en) Log record processing method, device and system
CN117762813A (en) Method and device for acquiring coverage rate information of increment codes and electronic equipment
CN110471829B (en) Method and device for checking software code test coverage rate
US10437710B2 (en) Code coverage testing utilizing test-to-file maps
Merenstein et al. Balancing Costs and Durability for Serverless Data

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