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

Missing coverage for Kotlin suspend functions calling reactor WebClient.ResponseSpec.awaitBody() #1410

Open
btpnlsl opened this issue Mar 6, 2023 · 1 comment
Labels
type: bug 🐛 Something isn't working

Comments

@btpnlsl
Copy link

btpnlsl commented Mar 6, 2023

Steps to reproduce

Expected behaviour

Full test coverage for Kotlin suspend functions which are calling WebClient.awaitBody()

Actual behaviour

JaCoCo appears to mistakenly mark certain Kotlin suspend functions as not fully covered by tests, but only when they call WebClient.awaitBody(). This sample shows this behaviour. When built and run with mvn verify, the JaCoCo coverage report will show that doLocalWork() is fully covered, but doWebWork() is not. The first line of doWebWork() will show partial coverage.

(In case of exceptions provide FULL STACKTRACE)

@btpnlsl btpnlsl added the type: bug 🐛 Something isn't working label Mar 6, 2023
@wlogan-omnidian
Copy link

wlogan-omnidian commented Mar 7, 2023

I think this has something to do with .awaitBody<T>() being declared as suspend inline fun <reified T : Any>. Replacing the call to .awaitBody<T>() with its reified expansion (in the case of this repro code, .bodyToMono<String>().awaitSingle()) side-steps the issue, and JaCoCo gives accurate coverage results. It looks like the "impossible branch" in the inlined code is being treated as a legitimate branch for coverage purposes.

I've added an additional test case to the repro demonstrating this: .doWebWork2() shows full coverage, while .doWebWork() still shows a missed instruction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants