CN115248776A - Coverage rate statistical method and device suitable for software test and storage medium - Google Patents
Coverage rate statistical method and device suitable for software test and storage medium Download PDFInfo
- Publication number
- CN115248776A CN115248776A CN202111315208.9A CN202111315208A CN115248776A CN 115248776 A CN115248776 A CN 115248776A CN 202111315208 A CN202111315208 A CN 202111315208A CN 115248776 A CN115248776 A CN 115248776A
- Authority
- CN
- China
- Prior art keywords
- coverage rate
- file
- unit
- rate file
- monitoring
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage 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)
- Debugging And Monitoring (AREA)
Abstract
The invention provides a coverage rate statistical method, a coverage rate statistical device and a storage medium suitable for software testing, wherein the coverage rate statistical method comprises the following steps: respectively monitoring the processes of a unit test case and a function test case of the software to be tested to generate a first unit coverage rate file and a first function coverage rate file, wherein the unit test case and the function test case are preset; correcting the first unit coverage rate file and the first function coverage rate file based on a source code information file to generate a second unit coverage rate file and a second interface coverage rate file; and combining the second unit coverage rate file and the second interface coverage rate file to generate a total coverage rate statistical file. The technical scheme provided by the invention can completely monitor the coverage rate of the project, can compare the coverage rate with the source code during coverage rate monitoring, and corrects the monitored coverage rate, thereby improving the monitoring precision of the coverage rate and ensuring the precision of the test effect of the software to be tested.
Description
Technical Field
The invention relates to the technical field of software testing, in particular to a coverage rate statistical method and device suitable for software testing and a storage medium.
Background
In software development, code coverage monitoring is an important means for measuring project quality, in order to further improve software delivery quality and reduce on-line accidents, a new requirement is provided for code coverage monitoring at present, how to accurately measure project code coverage is also a bottleneck encountered by numerous developers, coverage statistics is often inaccurate by relying on the existing coverage statistics tool, for example, LCOV often has the situation that coverage statistics is also carried out by non-branching judgment sentences like branching coverage, and in addition, a third-party library cannot carry out single measurement on openGL and other third-party library interfaces under a unit test frame depending on google etest and the like, so that project coverage statistics cannot be completely carried out. The existing testing method has certain limitations and poor testing effect.
Disclosure of Invention
The embodiment of the invention provides a coverage rate statistical method, a coverage rate statistical device and a storage medium suitable for software testing, which can be used for completely monitoring the coverage rate of a project, comparing the coverage rate with a source code during coverage rate monitoring, correcting the monitored coverage rate, improving the accuracy of coverage rate monitoring and ensuring the accuracy of a testing effect.
In a first aspect of the embodiments of the present invention, a coverage rate statistical method suitable for software testing is provided, including:
respectively monitoring the processes of a unit test case and a function test case of the software to be tested to generate a first unit coverage rate file and a first function coverage rate file, wherein the unit test case and the function test case are preset;
correcting the first unit coverage rate file and the first function coverage rate file based on the source code information file to generate a second unit coverage rate file and a second interface coverage rate file;
and combining the second unit coverage rate file and the second interface coverage rate file to generate a total coverage rate statistical file.
Optionally, in a possible implementation manner of the first aspect, the monitoring the processes of the test case of the running unit of the software to be tested and the functional test case to generate the first unit coverage rate file and the first functional coverage rate file respectively includes:
determining a monitoring dimension based on the configuration information;
monitoring the processes of the test cases and the functional test cases of the running unit of the software to be tested according to the monitoring dimension;
and respectively marking and storing the first unit coverage rate file and the first function coverage rate file when the preset condition corresponding to the monitoring dimension is triggered in the process of judging the test case of the to-be-tested software operation unit and the function test case.
Optionally, in a possible implementation manner of the first aspect, when a preset condition corresponding to a monitoring dimension is triggered in a process of determining a test case of a unit of running software to be tested and a functional test case, respectively performing mark storage in the first unit coverage file and the first functional coverage file includes:
the preset condition is a row trigger condition;
and when the software to be tested runs the unit test case and the functional test case to complete a line of codes, generating a line mark corresponding to the line of codes and storing the line mark into the first unit coverage rate file and the first functional coverage rate file.
Optionally, in a possible implementation manner of the first aspect, when a preset condition corresponding to a monitoring dimension is triggered in a process of determining a test case of a unit of running software to be tested and a functional test case, respectively performing mark storage in the first unit coverage file and the first functional coverage file includes:
the preset condition is an interface triggering condition;
and when judging that the test case of the software operation unit to be tested and the function test case run to trigger one interface, generating an interface mark corresponding to the line of codes and storing the interface mark into the first unit coverage rate file and the first function coverage rate file.
Optionally, in a possible implementation manner of the first aspect, when a preset condition corresponding to a monitoring dimension is triggered in a process of determining a test case of a unit of running software to be tested and a functional test case, respectively performing mark storage in the first unit coverage file and the first functional coverage file includes:
the preset condition is a branch triggering condition;
and when judging that a certain branch is triggered when the test case of the software running unit to be tested and the function test case run, generating a branch mark corresponding to the line of the branch code and storing the branch mark into the first unit coverage rate file and the first function coverage rate file.
Optionally, in a possible implementation manner of the first aspect, the generating a second unit coverage file and a second interface coverage file by rectifying the first unit coverage file and the first function coverage file based on the source code information file includes:
respectively acquiring source code branch structure information in a source code information file and monitoring branch structure information in a first unit coverage rate file and a first function coverage rate file, wherein the monitoring branch structure information comprises branch marks corresponding to all branch codes;
judging that the monitoring branch structure information does not correspond to the source code branch structure information, and rejecting corresponding branch marks in the source code branch structure information to generate corrected monitoring branch structure information based on the monitoring branch structure information;
and generating a second unit coverage rate file and a second interface coverage rate file based on the corrected monitoring branch structure information.
Optionally, in a possible implementation manner of the first aspect, if it is determined that the monitored branch structure information does not correspond to the source code branch structure information, the removing, based on the monitored branch structure information, a corresponding branch marker in the source code branch structure information to generate corrected monitored branch structure information includes:
acquiring a source code mark in the source code branch structure information, wherein the source code mark is used for marking a line in a source code;
judging whether the line corresponding to the branch mark belongs to the line of the source code mark, and judging whether the monitoring branch structure information corresponds to the source code branch structure information;
and deleting branch marks of lines which do not belong to the source code marks from the monitoring branch structure information to generate corrected monitoring branch structure information.
Optionally, in a possible implementation manner of the first aspect, the merging the second unit coverage rate file and the second interface coverage rate file to generate a total coverage rate statistics file includes:
and counting the execution times of the unit test cases and the function test cases in the second unit coverage rate file and the second interface coverage rate file, and generating a total coverage rate counting file based on the execution times of the unit test cases and the function test cases.
In a second aspect of the embodiments of the present invention, a coverage rate statistics apparatus suitable for software testing is provided, including:
the test module is used for respectively monitoring the processes of the unit test case and the function test case of the software to be tested to generate a first unit coverage rate file and a first function coverage rate file, and the unit test case and the function test case are preset;
the correcting module is used for correcting the first unit coverage rate file and the first function coverage rate file based on the source code information file to generate a second unit coverage rate file and a second interface coverage rate file;
and the merging module is used for merging the second unit coverage rate file and the second interface coverage rate file to generate a total coverage rate statistical file.
In a third aspect of the embodiments of the present invention, a readable storage medium is provided, in which a computer program is stored, which, when being executed by a processor, is adapted to carry out the method according to the first aspect of the present invention and various possible designs of the first aspect of the present invention.
The coverage rate statistical method, the coverage rate statistical device and the storage medium suitable for software testing can monitor the process of running a unit test case and a function test case of software to be tested, generate a first unit coverage rate file and a first function coverage rate file, correct the first unit coverage rate file and the first function coverage rate file according to a source code information file to delete error statistics of the first unit coverage rate file and the first function coverage rate file, ensure the accuracy of coverage rate statistics, obtain a total coverage rate statistical file according to corrected coverage rates in a second unit coverage rate file and a second interface coverage rate file, enable the total coverage rate statistical file to have accurate information of coverage rates of unit testing and function testing, and completely monitor the item coverage rate.
Drawings
FIG. 1 is a flow chart of a first embodiment of a coverage statistics method suitable for software testing;
FIG. 2 is a flow chart of a second embodiment of a coverage statistics method suitable for software testing;
FIG. 3 is a flow chart of a third embodiment of a coverage statistics method suitable for software testing;
fig. 4 is a block diagram of a first embodiment of a coverage statistic apparatus suitable for software testing.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein.
It should be understood that, in various embodiments of the present invention, the sequence numbers of the processes do not mean the execution sequence, and the execution sequence of the processes should be determined by the functions and the internal logic of the processes, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
It should be understood that in the present application, "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 understood that, in the present invention, "a plurality" means two or more. "and/or" is merely an association describing an associated object, meaning that three relationships may exist, for example, and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "comprises A, B and C" and "comprises A, B, C" means that A, B, C all comprise, "comprises A, B or C" means that one of three A, B, C is comprised, "comprises A, B and/or C" means that any 1 or any 2 or 3 of three A, B, C are comprised.
It should be understood that in the present invention, "B corresponding to a", "a corresponds to B", or "B corresponds to a" means that B is associated with a, and B can be determined from a. Determining B from a does not mean determining B from a alone, but may be determined from a and/or other information. And the matching of A and B means that the similarity of A and B is greater than or equal to a preset threshold value.
As used herein, if can be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a monitoring", depending on the context.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
The invention provides a coverage rate statistical method suitable for software testing, which specifically comprises the following steps of:
step S110, respectively monitoring the process of running a unit test case and a function test case of the software to be tested to generate a first unit coverage rate file and a first function coverage rate file, wherein the unit test case and the function test case are preset. In the process of testing software, different test cases are generally adopted according to different testing purposes. The technical scheme provided by the invention comprises a unit test case and a function test case respectively. The unit test case can test the relevant codes and functions of the internal units of the software, and the functional test case can test the relevant codes called by the external functions of the software.
In different software testing processes, different unit test cases and function test cases may need to be run, and the unit test cases and the function test cases are preset according to the attributes of software to be tested.
In the technical scheme provided by the invention, the LOCV statistical tool can be used for carrying out statistics on the test cases and the functional test cases of the running unit of the software to be tested to generate a first unit coverage rate file and a first functional coverage rate file.
In the technical solution provided by the present invention, as shown in fig. 3, step S110 specifically includes:
step S1101, determining a monitoring dimension based on the configuration information. The configuration information can be actively input by an administrator and a user, and the monitoring dimension can be selected according to the configuration information. The monitoring dimension includes any one or more of row coverage, interface coverage, and branch coverage. The line coverage rate, the interface coverage rate and the branch coverage rate can be preset, and the invention can monitor any one or more of the coverage rate, the interface coverage rate and the branch coverage rate of the software to be tested according to the requirement.
And step S1102, monitoring the processes of the test cases and the functional test cases of the to-be-tested software operation unit according to the monitoring dimension. After the monitoring dimension of the software to be detected is determined, the software to be detected during running is monitored according to the monitoring dimension, so that the first unit coverage rate file and the first function coverage rate file can have monitoring information with corresponding dimensions.
Step S1103, when a preset condition corresponding to the monitoring dimension is triggered in the process of judging the test case of the software running unit to be tested and the function test case, respectively performing mark storage in the first unit coverage file and the first function coverage file.
In the technical solution provided by the present invention, the first implementation manner of step S1103 specifically includes:
the preset condition is a row trigger condition. When the software to be tested is tested, the number of the lines and the line coverage rate of the software to be tested can be judged, and the condition of line missing test in the process of testing the software to be tested is avoided. Therefore, the invention can set a line triggering condition, and realize one-time triggering when the software to be tested runs to finish a line of codes.
And when the software to be tested runs the unit test case and the functional test case to complete a line of codes, generating a line mark corresponding to the line of codes and storing the line mark into the first unit coverage rate file and the first functional coverage rate file.
In the technical solution provided by the present invention, the second implementation manner of step S1103 specifically includes:
the preset condition is an interface triggering condition. When the software to be tested is tested, the number and the line coverage rate of the interfaces operated by the software can be judged, and the condition that the interface test is missed in the process of testing the software to be tested is avoided. Therefore, the invention can set an interface triggering condition, and once triggering is realized when the software to be tested runs to complete one interface.
And when judging that the test case of the software operation unit to be tested and the function test case run to trigger one interface, generating an interface mark corresponding to the line of codes and storing the interface mark into the first unit coverage rate file and the first function coverage rate file.
In the technical solution provided by the present invention, the third implementation manner of step S1103 specifically includes:
the preset condition is a branch triggering condition. When the software to be tested is tested, the number and the line coverage rate of the branches operated by the software can be judged, and the condition that the branch test is missed in the test process of the software to be tested is avoided. Therefore, the invention can set a branch triggering condition, and once triggering is realized when the software to be tested runs to complete a branch.
The branch trigger condition may be preset by the LOCV statistical tool, for example, a branch statement in the code may be used as the branch trigger condition.
And when judging that a certain branch is triggered when the test case of the software running unit to be tested and the function test case run, generating a branch mark corresponding to the line of the branch code and storing the branch mark into the first unit coverage rate file and the first function coverage rate file.
The LOCV statistical tool generates branch marks in response to branch statements appearing when the software to be tested runs the unit test cases and the functional test cases and stores the branch marks into the first unit coverage rate file and the first functional coverage rate file, wherein the branch marks can be 'info'.
And step S120, correcting the first unit coverage rate file and the first function coverage rate file based on the source code information file to generate a second unit coverage rate file and a second interface coverage rate file. After the first unit coverage rate file and the first function coverage rate file are corrected, a second unit coverage rate file and a second interface coverage rate file which are relatively accurate can be generated.
In an embodiment of the present invention, the generating a second unit coverage file and a second interface coverage file by correcting the first unit coverage file and the first function coverage file based on the source code information file includes:
and respectively acquiring source code branch structure information in the source code information file and monitoring branch structure information in the first unit coverage rate file and the first function coverage rate file, wherein the monitoring branch structure information comprises branch marks corresponding to all branch codes.
In the technical scheme provided by the invention, the [ gcda ] file corresponding to the source code is generated. The code coverage rate statistical tool LCOV carries out code coverage rate statistics, and generates an 'info' file under a unit test item (unit test case) and an interface function test item (function test case), wherein the 'info' file comprises the following structural information:
TN < Test name > represents the Test case name, namely the Test case name named by the-Test-name option in geniinfo, and is empty by default;
SF < File name > represents the source code File name with the full path;
FN < function start line number >, < function name >; < total number of valid rows of function >; < number of executed in total number of effective lines of function >;
FNDA < number of times function is executed >, < function name >; < total number of valid rows of function >; < number of executed lines in the total number of effective lines of function >;
FNF: < function total >;
FNH: < number of executed in total number of functions >;
BRDA, namely a line number where a branch is located >, < a corresponding code block number >, < a branch number >, < execution times >;
BRF < total number of branches >;
BRH < number of executed branches in total >;
DA < code line number >, < number of times the current line was executed >;
LF: < counts > total number of valid lines of code;
LH < counts > the number of executed valid lines in the total number of code valid lines;
end of record an end of record.
Judging that the monitoring branch structure information does not correspond to the source code branch structure information, and rejecting a corresponding branch mark in the source code branch structure information based on the monitoring branch structure information to generate corrected monitoring branch structure information;
and generating a second unit coverage rate file and a second interface coverage rate file based on the corrected monitoring branch structure information.
In one possible embodiment, if it is determined that the monitored branch structure information does not correspond to the source code branch structure information, then rejecting a corresponding branch marker in the source code branch structure information based on the monitored branch structure information to generate corrected monitored branch structure information includes:
and acquiring a source code mark in the source code branch structure information, wherein the source code mark is used for marking a line in the source code. The source code flag in the source code branch structure information may be ". Data".
In a possible implementation manner, the present invention obtains branch structure information inside a source code, and solves the problem of statistical errors of code coverage rate tools due to respective implementation mechanisms by recording line numbers corresponding to multiple code branches as correction references after statistics of the coverage rate tools, and the specific process is as follows: through traversing the source code file under the project, whether the source code line contains ' if ', ' while ', ' | is judged! And key fields for judging types, such as "=," = = ", and the like, and the row number for the pair is recorded and stored as a". Data "file.
And judging that the line corresponding to the branch mark does not belong to the line of the source code mark, and judging that the monitoring branch structure information does not correspond to the source code branch structure information. The method can compare the line marked by the source code with the line corresponding to the branch mark, and when the line corresponding to the branch mark does not belong to the line marked by the source code, the method proves that errors occur in the monitoring branch structure information, the first unit coverage rate file and the first function coverage rate file at the moment, and the errors need to be corrected.
And deleting branch marks of lines which do not belong to the source code marks from the monitoring branch structure information to generate corrected monitoring branch structure information. The branch marks of the lines which do not belong to the source code marks can be regarded as LOCV statistical tool mark errors, and the error marks can be removed in the mode, so that the accuracy of coverage rate statistics of software testing is guaranteed.
The technical scheme provided by the invention can correct the 'info' file generated by the LOCV statistical tool, and the generated 'data' of the source code structure is used as a branch information reference. Traversing the generated 'info' file, extracting a line where a BRDA field in the 'info' file is located, taking out line file information or a line number and the 'data' according to a format for matching, if the corresponding line text information or the line number is not in the 'data' file, judging that the line text information or the line number is abnormal branch statistical information, and deleting line content corresponding to the abnormal branch statistical information in the 'info'.
And step S130, combining the second unit coverage rate file and the second interface coverage rate file to generate a total coverage rate statistical file.
The invention can carry out field counting and merging on the coverage rate statistical file ". Info" of the unit test and the interface function test to generate final code coverage rate information ". Info", generate a coverage rate report and a total coverage rate statistical file on the finally merged ". Info" file through genhtml to obtain a coverage rate monitoring result of a final project, evaluate the coverage rate monitoring result and judge whether the code coverage rate of the current project meets the quality requirement. When the coverage monitoring result is evaluated, the coverage may be compared with a preset threshold, and if the coverage exceeds the threshold, the evaluation result is passed, and if the coverage is lower than the threshold, the evaluation result is not passed.
In the technical solution provided in the embodiment of the present invention, step S130 specifically includes:
and combining the field data of the second unit coverage rate file and the second interface coverage rate to generate a total coverage rate statistical file. Wherein, the total coverage rate statistical file at least comprises a second unit coverage rate file and a second interface coverage rate.
In a possible implementation manner, the execution times of the unit test cases and the function test cases in the second unit coverage rate file and the second interface coverage rate file are counted, and a total coverage rate statistical file is generated based on the execution times of the unit test cases and the function test cases.
When the generated total coverage rate statistics file is obtained, the number of executed functions in two info entries may be added by using the row number as an index, where the information such as the row number function name in the two info entries is the same, and the difference is the difference of the number of executed functions. For example, the unit test case is not executed during the unit test, the execution times of the corresponding line number in the generated info file is 0, the execution times of the functional test case is 10, the execution times in the function coverage rate information of the corresponding line number in the newly merged info file is 10, and the total coverage rate statistical file is generated in the above manner.
In a possible embodiment, the coverage extraction method of the technical solution provided by the present invention is to perform unit test and interface automation test (functional test) on the code of the trunk branch master, and finally count the code coverage information "master.
Line coverage lines:94.0%;
87.3 percent of function coverage functions;
the branches cover 86.2%.
The coverage rate extraction mode of the invention carries out unit test and interface automation test on the code of the development branch, and finally counts the code coverage rate information' branch.
The invention matches the branch coverage rate condition, if the branch coverage rate of the developed branch is less than the branch coverage rate of the master, the branch coverage rate is judged not to meet the requirement.
The invention further provides a coverage rate statistical device suitable for the software test.
An embodiment of the present invention further provides a coverage rate statistics apparatus suitable for software testing, as shown in fig. 4, including:
the test module is used for respectively monitoring the processes of the unit test case and the function test case of the software to be tested to generate a first unit coverage rate file and a first function coverage rate file, and the unit test case and the function test case are preset;
the correcting module is used for correcting the first unit coverage rate file and the first function coverage rate file based on the source code information file to generate a second unit coverage rate file and a second interface coverage rate file;
and the merging module is used for merging the second unit coverage rate file and the second interface coverage rate file to generate a total coverage rate statistical file.
The readable storage medium may be a computer storage medium or a communication medium. Communication media includes any medium that facilitates transfer of a computer program from one place to another. Computer storage media may be any available media that can be accessed by a general purpose or special purpose computer. For example, a readable storage medium is coupled to the processor such that the processor can read information from, and write information to, the readable storage medium. Of course, the readable storage medium may also be an integral part of the processor. The processor and the readable storage medium may reside in an Application Specific Integrated Circuits (ASIC). Additionally, the ASIC may reside in user equipment. Of course, the processor and the readable storage medium may also reside as discrete components in a communication device. The readable storage medium may be a read-only memory (ROM), a random-access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
The present invention also provides a program product comprising executable instructions stored on a readable storage medium. The at least one processor of the device may read the execution instructions from the readable storage medium, and the execution of the execution instructions by the at least one processor causes the device to implement the methods provided by the various embodiments described above.
In the above embodiments of the terminal or the server, it should be understood that the Processor may be a Central Processing Unit (CPU), other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor, or in a combination of the hardware and software modules within the processor.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
Claims (10)
1. A coverage rate statistical method suitable for software testing is characterized by comprising the following steps:
respectively monitoring the processes of a unit test case and a function test case of the software to be tested to generate a first unit coverage rate file and a first function coverage rate file, wherein the unit test case and the function test case are preset;
correcting the first unit coverage rate file and the first function coverage rate file based on a source code information file to generate a second unit coverage rate file and a second interface coverage rate file;
and combining the second unit coverage rate file and the second interface coverage rate file to generate a total coverage rate statistical file.
2. The coverage statistical method suitable for software testing according to claim 1,
the step of respectively monitoring the processes of the test case and the functional test case of the running unit of the software to be tested to generate a first unit coverage rate file and a first functional coverage rate file comprises the following steps:
determining a monitoring dimension based on the configuration information;
monitoring the processes of the test cases and the functional test cases of the running unit of the software to be tested according to the monitoring dimension;
and respectively marking and storing the first unit coverage rate file and the first function coverage rate file when the preset condition corresponding to the monitoring dimension is triggered in the process of judging the test case of the to-be-tested software operation unit and the function test case.
3. The coverage statistical method suitable for software testing according to claim 2,
when the preset conditions corresponding to the monitoring dimensions are triggered in the process of judging the test cases of the running units and the functional test cases of the software to be tested, the marking and storing in the first unit coverage rate file and the first functional coverage rate file respectively comprises the following steps:
the preset condition is a row trigger condition;
and when the software to be tested runs the unit test case and the functional test case to complete a line of codes, generating a line mark corresponding to the line of codes and storing the line mark into the first unit coverage rate file and the first functional coverage rate file.
4. The coverage statistical method suitable for software testing according to claim 2,
when the preset conditions corresponding to the monitoring dimensions are triggered in the process of judging the test cases of the running units and the functional test cases of the software to be tested, the marking and storing in the first unit coverage rate file and the first functional coverage rate file respectively comprises the following steps:
the preset condition is an interface triggering condition;
and when judging that the test case of the software operation unit to be tested and the function test case run to trigger one interface, generating an interface mark corresponding to the line of codes and storing the interface mark into the first unit coverage rate file and the first function coverage rate file.
5. The coverage statistical method suitable for software testing according to claim 2,
when the preset conditions corresponding to the monitoring dimensions are triggered in the process of judging the test cases of the running units and the functional test cases of the software to be tested, the marking and storing in the first unit coverage rate file and the first functional coverage rate file respectively comprises the following steps:
the preset condition is a branch triggering condition;
and when judging that a certain branch is triggered when the test case of the software running unit to be tested and the function test case run, generating a branch mark corresponding to the line of the branch code and storing the branch mark into the first unit coverage rate file and the first function coverage rate file.
6. The coverage statistical method suitable for software testing according to claim 5,
the generating a second unit coverage file and a second interface coverage file by correcting the first unit coverage file and the first function coverage file based on the source code information file comprises:
respectively acquiring source code branch structure information in a source code information file and monitoring branch structure information in a first unit coverage rate file and a first function coverage rate file, wherein the monitoring branch structure information comprises branch marks corresponding to all branch codes;
judging that the monitoring branch structure information does not correspond to the source code branch structure information, and rejecting corresponding branch marks in the source code branch structure information to generate corrected monitoring branch structure information based on the monitoring branch structure information;
and generating a second unit coverage rate file and a second interface coverage rate file based on the corrected monitoring branch structure information.
7. The coverage statistical method suitable for software testing according to claim 6,
judging that the monitoring branch structure information does not correspond to the source code branch structure information, and rejecting a corresponding branch marker in the source code branch structure information based on the monitoring branch structure information to generate corrected monitoring branch structure information comprises:
acquiring a source code mark in the source code branch structure information, wherein the source code mark is used for marking a line in a source code;
judging whether the line corresponding to the branch mark belongs to the line of the source code mark, and judging whether the monitoring branch structure information corresponds to the source code branch structure information;
and deleting branch marks of lines which do not belong to the source code marks from the monitoring branch structure information to generate corrected monitoring branch structure information.
8. The coverage statistical method suitable for software testing according to claim 1,
the step of combining the second unit coverage rate file and the second interface coverage rate file to generate a total coverage rate statistical file comprises the following steps:
and counting the execution times of the unit test cases and the function test cases in the second unit coverage rate file and the second interface coverage rate file, and generating a total coverage rate counting file based on the execution times of the unit test cases and the function test cases.
9. A coverage statistic apparatus suitable for software testing, comprising:
the test module is used for respectively monitoring the processes of the unit test case and the function test case of the software to be tested to generate a first unit coverage rate file and a first function coverage rate file, and the unit test case and the function test case are preset;
the correction module is used for correcting the first unit coverage rate file and the first function coverage rate file based on the source code information file to generate a second unit coverage rate file and a second interface coverage rate file;
and the merging module is used for merging the second unit coverage rate file and the second interface coverage rate file to generate a total coverage rate statistical file.
10. A readable storage medium, in which a computer program is stored which, when being executed by a processor, is adapted to carry out the method of any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111315208.9A CN115248776A (en) | 2021-11-08 | 2021-11-08 | Coverage rate statistical method and device suitable for software test and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111315208.9A CN115248776A (en) | 2021-11-08 | 2021-11-08 | Coverage rate statistical method and device suitable for software test and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115248776A true CN115248776A (en) | 2022-10-28 |
Family
ID=83698621
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111315208.9A Pending CN115248776A (en) | 2021-11-08 | 2021-11-08 | Coverage rate statistical method and device suitable for software test and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115248776A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116991751A (en) * | 2023-09-28 | 2023-11-03 | 英诺达(成都)电子科技有限公司 | Code testing method and device, electronic equipment and storage medium |
-
2021
- 2021-11-08 CN CN202111315208.9A patent/CN115248776A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116991751A (en) * | 2023-09-28 | 2023-11-03 | 英诺达(成都)电子科技有限公司 | Code testing method and device, electronic equipment and storage medium |
CN116991751B (en) * | 2023-09-28 | 2023-12-22 | 英诺达(成都)电子科技有限公司 | Code testing method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TW201941058A (en) | Anomaly detection method and device | |
CN109660533B (en) | Method and device for identifying abnormal flow in real time, computer equipment and storage medium | |
CN109271315B (en) | Script code detection method, script code detection device, computer equipment and storage medium | |
CN107223257B (en) | Test method, test server and test system | |
CN109740457B (en) | Face recognition algorithm evaluation method | |
CN112866800A (en) | Video content similarity detection method, device, equipment and storage medium | |
CN110275878B (en) | Service data detection method and device, computer equipment and storage medium | |
CN107943646B (en) | Program monitoring method and device | |
CN106600303A (en) | Method and device for assessment of advertisement putting rationality | |
CN110046086B (en) | Expected data generation method and device for test and electronic equipment | |
CN115248776A (en) | Coverage rate statistical method and device suitable for software test and storage medium | |
CN110262870B (en) | Method, device, computer equipment and storage medium for locating exception by dump file | |
CN115509797A (en) | Method, device, equipment and medium for determining fault category | |
CN112637888B (en) | Coverage hole area identification method, device, equipment and readable storage medium | |
CN113781460A (en) | Cigarette packet appearance defect online detection method and device, electronic equipment and storage medium | |
CN111767213A (en) | Method and device for testing database check points, electronic equipment and storage medium | |
CN112486841A (en) | Method and device for checking data collected by buried point | |
CN112242929B (en) | Log detection method and device | |
CN111382052A (en) | Code quality evaluation method and device and electronic equipment | |
CN113535458B (en) | Abnormal false alarm processing method and device, storage medium and terminal | |
CN115576831A (en) | Test case recommendation method, device, equipment and storage medium | |
CN113037521B (en) | Method for identifying state of communication equipment, communication system and storage medium | |
CN111368104A (en) | Information processing method, device and equipment | |
CN114024872B (en) | Voice semantic platform abnormality alarm method, device, storage medium and apparatus | |
CN114881112A (en) | System anomaly detection method, device, equipment and 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 |