Method and equipment for obtaining code coverage rate

A code coverage, equipment technology, applied in software testing/debugging, etc., can solve the problem of not being able to accurately indicate that the code has not been tested

Active Publication Date: 2013-10-23
ALIBABA GRP HLDG LTD
View PDF4 Cites 23 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0011] Existing tools such as gcov / lcov, the calculation method of the line code coverage rate is: line code coverage rate = the number of code lines passed after the test activity / the number of all code lines of the code file passed after the test activity*100%; When using this line of code coverage calculation method, it is impossible to accurately indicate which code is not tested

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method and equipment for obtaining code coverage rate
  • Method and equipment for obtaining code coverage rate
  • Method and equipment for obtaining code coverage rate

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0025] Embodiment 1 of the present application provides a method for obtaining code coverage, which is used to calculate code coverage (Code Coverage). It can be subdivided into line code coverage, function coverage, branch coverage, condition coverage, etc. In the embodiment of this application, the method for obtaining line code coverage is as follows: figure 1 As shown, the method may at least include the following steps:

[0026] Step 101, when performing a code coverage test on multiple source code files of a test object, obtain the number of executed code lines and the number of all compiled code lines during the test.

[0027] Step 102, calculating the line code coverage of the test object: the number of executed code lines / the number of all compiled code lines.

[0028] In the embodiment of the present application, code coverage testing can be performed on multiple source code files of the test object through code coverage testing tools (such as gcov, lcov, etc.), and...

Embodiment 2

[0055] Based on the same application idea as the above method, an embodiment of the present application also provides a device for obtaining code coverage, such as figure 2 As shown, the equipment includes:

[0056] The obtaining module 11 is used to obtain the number of lines of code executed during the test and the number of all lines of code compiled when performing code coverage testing on multiple source code files of the test object;

[0057] The calculation module 12 is configured to calculate the line code coverage ratio of the test object: the number of executed code lines / the number of all compiled code lines.

[0058] The obtaining module 11 specifically includes:

[0059] Generate sub-module 111, for generating the corresponding code coverage intermediate result file of source code file when carrying out code coverage rate test to each source code file;

[0060] The code coverage intermediate result file corresponding to the source code file records the number o...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention discloses a method and equipment for obtaining a code coverage rate. The method comprises the steps of testing code coverage rates of a plurality of source code files of a test object, obtaining an executed code line number and a total compiled code line number during testing, and calculating the line code coverage rate of the test object by dividing the executed code line number by the total compiled code line number. According to the method and the equipment, the line code coverage rate is calculated by the executed code line number and the total compiled code line number, so that the test activity extent can be fed back more clearly, and which codes not tested can be shown precisely.

Description

technical field [0001] The present application relates to the field of computer technology, in particular to a method and device for obtaining code coverage. Background technique [0002] gcov / lcov (code coverage testing tool, which can be used to view the coverage of code execution during testing) is a component in the gnu / gcc tool library, and it works with the gcc compiler to implement statement coverage testing and branch coverage for C / C++ files test etc. Taking gcov as an example, the execution of gcov depends on the .gcda file and .gcno file, and gcov can generate the corresponding .c.gcov or .cpp.gcov according to the .gcda file and .gcno file, and .c.gcov or . Code coverage information is recorded in cpp.gcov. [0003] Specifically, the analysis process of gcov includes the following steps: [0004] (1) gcov reads the program flow diagram information in the .gcno file, and establishes the program flow diagram of each function in the tested source file; [0005] ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F11/36
Inventor 黄利桂锡兰
Owner ALIBABA GRP HLDG LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products