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

Ignore specific lines, for example require #250

Open
soywiz opened this issue Oct 4, 2022 · 6 comments
Open

Ignore specific lines, for example require #250

soywiz opened this issue Oct 4, 2022 · 6 comments
Assignees
Labels
Feature Feature request issue type Implement in KGP

Comments

@soywiz
Copy link
Contributor

soywiz commented Oct 4, 2022

Require method calls that are a safeguard for implementations never will be able to be fully executed if the implementation works fine.

Screenshot 2022-10-04 at 17 55 08

So I would like to mark somehow specific lines to be ignored for the coverage. Is it possible right now?

@shanshin
Copy link
Collaborator

shanshin commented Oct 4, 2022

Hi,
at the moment there is no way to exclude a specific line from the report.

Using an annotation filter, you can exclude lambdas, but this will not work in the case of inline functions.

@soywiz
Copy link
Contributor Author

soywiz commented Oct 4, 2022

Thanks @shanshin ! So maybe this could be a feature request. Not sure if a comment or something in the line above the partial line could be easily be consumed by the plugin having the source.

And thanks you guys for all the hard work! With 0.6.1, I was able to finally get it working and upload the reports to codecov!

@shanshin
Copy link
Collaborator

shanshin commented Oct 4, 2022

Not sure if a comment or something in the line above the partial line could be easily be consumed by the plugin having the source.

Ignoring the line by comment (or compile-only annotations) is a planned feature, but at this stage its implementation is difficult.

@qwwdfsad
Copy link
Contributor

qwwdfsad commented Oct 5, 2022

Nevertheless, the overall recommendation is to test every meaningful code path and exclude only really obscure lines (the classic example of which is Java's catch (check exception) when it's statically known that the try` block never throws it)

@soywiz
Copy link
Contributor Author

soywiz commented Oct 5, 2022

Yeah, thats the case here. That require for example tests the correctness of the private state. Public constructors and methofs dont allow to violate that contract, so it is not possible to test that branch without mocking or reflectively change stuff. And since those are in the commonTest branch it wont be reasonably possible.
As you said I don't want to test those kind of branches for the reasons you put, but would want to skip them if possible to approach to the 100% coverage without those affecting to it.
Not a super huge deal for me, since I have lot of untested code yet, but will be appreciated if this feature is supported at some point in the future.

@shanshin shanshin added Feature Feature request issue type S: postponed Status: work on the issue is not in the short term plans labels Oct 17, 2022
@shanshin shanshin added this to the After stabilization milestone Oct 27, 2022
@shanshin shanshin self-assigned this Oct 27, 2022
@shanshin shanshin added Implement in KGP and removed S: postponed Status: work on the issue is not in the short term plans labels Jan 3, 2025
@shanshin
Copy link
Collaborator

shanshin commented Jan 3, 2025

This task will be taken into account when migrating to Kotlin Gradle Plugin.

In the future, it will be moved to the Kotlin task tracker, or closed if it loses relevance.

@shanshin shanshin removed this from the After stabilization milestone Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Feature request issue type Implement in KGP
Projects
None yet
Development

No branches or pull requests

3 participants