qiniu / goc

A Comprehensive Coverage Testing System for The Go Programming Language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

/v1/cover/coverage这个接口建议添加一下说明,获取的是语句块的覆盖率

gxchenqiang opened this issue · comments

/v1/cover/coverage这个接口是获取的语句块的覆盖率,而不是代码行的覆盖率。是不是在接口那里添加个注释说明一下,比较好

Hi @gxchenqiang , what do you mean by this request? Are you experiencing any specific issues or challenges related to your idea?

Hi @gxchenqiang , what do you mean by this request? Are you experiencing any specific issues or challenges related to your idea?

The calculation formula for code coverage in this API (/v1/cover/coverage) is "have_cover_count_code_block / all_code_block," not "have_cover_count_line / all_code_line." I believe that what people need more is code coverage based on lines of code. So, to prevent misuse of this API, should we annotate it to clarify that it calculates code coverage based on code blocks, not lines of code?

@gxchenqiang To clarify, the algorithm for code coverage in the Go language primarily focuses on statement coverage, which is closely related to line coverage.

In Go, the addition of counters around code blocks serves the purpose of effectively identifying the logic of statements. By placing counters within individual code blocks, it becomes apparent whether a statement within that block has been covered or executed during testing. This approach helps track the coverage of statements more accurately.

@gxchenqiang To clarify, the algorithm for code coverage in the Go language primarily focuses on statement coverage, which is closely related to line coverage.

In Go, the addition of counters around code blocks serves the purpose of effectively identifying the logic of statements. By placing counters within individual code blocks, it becomes apparent whether a statement within that block has been covered or executed during testing. This approach helps track the coverage of statements more accurately.

I see, but this API calculates code coverage based on code blocks, not statements. So, should we make a note of it? :- )

A code block consists of statements, and they are not mutually exclusive. Strictly speaking, in Go language, code coverage is calculated based on statement coverage, which has no direct relationship with code blocks. Code blocks only represent the internal logical understanding of the statements being measured.

A code block consists of statements, and they are not mutually exclusive. Strictly speaking, in Go language, code coverage is calculated based on statement coverage, which has no direct relationship with code blocks. Code blocks only represent the internal logical understanding of the statements being measured.

The method of calculating coverage in this API is based on the number of code blocks: have_ cover_ count_ code_ block / all_ code_ block , this calculation result is different from using code lines to calculate: have_ cover_ count_ line / all_ ode_ line
image