This message was deleted.
# community-support
s
This message was deleted.
v
If you
Ctrl+Click
on
exclude
, you see that you configure the test task. And if you Ctrl+Click on
jacoco
or look at the type-hint in IntelliJ, you see that you configure the JaCoCo plugin extension, not the JaCoCo task extension. (assuming you use Kotlin DSL, not Groovy DSL where it indeed would be the task extension) What you are after is
Copy code
tasks.test {
    configure<JacocoTaskExtension> {
        excludes = listOf("com.xenoterracide.ai.wh40k.app.Application#main")
    }
}
But be aware that iirc, that means you will not record code paths in that method, but you still report on that method, so the whole method will be shown as uncovered, even if you executed the code in it during the test.
But I might misremember
c
hmm... if I exclude ** it seems to work... but anything more specific, e.g.
Copy code
tasks.test {
  configure<JacocoTaskExtension> {
    exclude("com.xenoterracide.ai.wh40k.app.Application#main(*)")
  }
}
I still get
Copy code
> Rule violated for bundle app: instructions covered ratio is 0.3, but expected minimum is 0.9
would the
addAll
actually be different? usually that's the wrong thing...
exclude
only seems to except file patterns
v
Again, Ctrl+Click and see that you configure the test task, not JaCoCo
The JaCoCo task extension does not have an
exclude
method
👍 1
c
oops, thanks
that's... urgh
needs documenting better
v
I don't agree, but that's just my 2ct, feel free to open a feature request or pull request to improve the docs. 🙂
c
nah still didn't work ``````
v
"didn't work" ... how?
c
Copy code
tasks.test {
  configure<JacocoTaskExtension> {
    excludes = listOf("com.xenoterracide.ai.wh40k.app.Application")
  }
}
same way, not enough coverage
yeah, but there are zero examples 😉
v
Sure, the first of the two links shows the example:
same way, not enough coverage
Check in the
--info
or if not shown
--debug
logs whether the value is now properly given to the JaCoCo agent.
c
oh, I guess now it's saying 0.0 instead of 0.3 instead
which isn't really more helpful
v
And if it does, which I think, then remember what I said above, that iirc this means coverage will not be recorded for that method, but you still get it reported then as uncovered which exactly matches what you just said, as coverage dropped from 0.3 to 0.0.
c
well, if I ignore the whole class
v
You would need to exclude from the report. And on the report iirc you can only exclude whole classes.
c
yeah, but if I ignore the whole class it's no coverage, in either case it's not particularly helpful as I want to only count coverage for things except that method
or if I have to the class
the class is loaded and there is a test for it, just doesn't run main
v
Well, that's a question for JaCoCo, not Gradle. As I said, I think if you just exlude a method it is still reported on but does not have coverage recorded for that method and you cannot exclude a method from reporting iirc. If I do remember correctly, that's a limitation of JaCoCo, not Gradle.
So you could only exclude the whole class
c
right, but if I do
Copy code
tasks.test {
  configure<JacocoTaskExtension> {
    excludes = listOf("com.xenoterracide.ai.wh40k.app.Application")
  }
}
that's when it goes to
Copy code
> Rule violated for bundle app: instructions covered ratio is 0.0, but expected minimum is 0.9
which is the whole class
for just the method (
#main
) it stays at 0.3
v
Again, you configure only to skip the recording. You would need to skip it on the reporting instead.
c
how do you skip the recording? I'm confused
v
Btw. you could abuse a
Generated
annotation. Even though it is discouraged by JaCoCo to use it for manual exclusion of not-generated code, you could apply any annotation with simple name
Generated
to the method as long as it has at least
CLASS
retention, then it will be automatically excluded from the report
how do you skip the recording? I'm confused
Exactly like you did it
c
yeah, I thought about that
oh, sorry, skip it on the reporting
c
headdesk
ah github issues, where bugs go to continue
I suppose I could also change the minimum somehow for this particular subproject... since it really shouldn't have anything other than this class...
hah, won't let me thumb it up either
hmm... is there another, better coverage library these days?
v
hah, won't let me thumb it up either
Why?
hmm... is there another, better coverage library these days?
None I'm aware of
c
seems to have been some kind of transient error on github
works again
👌 1