Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gxchenqiang opened this issue Aug 9, 2023 · 6 comments

Comments

@gxchenqiang
Copy link

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

@CarlJi
Copy link
Collaborator

CarlJi commented Oct 6, 2023

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

@gxchenqiang
Copy link
Author

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?

@CarlJi
Copy link
Collaborator

CarlJi commented Oct 18, 2023

@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
Copy link
Author

@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? :- )

@CarlJi
Copy link
Collaborator

CarlJi commented Oct 20, 2023

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.

@gxchenqiang
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants