clarinet icon indicating copy to clipboard operation
clarinet copied to clipboard

Code coverage missing covered lines

Open whoabuddy opened this issue 7 months ago • 2 comments

Describe the bug

Our AIBTC contracts have a lot of unit tests covering the code, and our preferred pattern is to test every error path then a few success paths depending on the functionality.

We have GitHub CI configured to run clarinet check then run the tests and upload the resulting coverage file to codecov.

Codecov has some trouble with complex printed tuples and sometimes reports a line as uncovered right in the middle of a covered path. e.g. https://app.codecov.io/gh/aibtcdev/aibtcdev-daos/blob/main/contracts%2Fdao%2Fextensions%2Faibtc-action-proposal-voting.clar#L193 https://app.codecov.io/gh/aibtcdev/aibtcdev-daos/blob/main/contracts%2Fdao%2Fextensions%2Faibtc-dao-users.clar#L69 https://app.codecov.io/gh/aibtcdev/aibtcdev-daos/blob/main/contracts%2Fdao%2Fextensions%2Faibtc-rewards-account.clar#L59 https://app.codecov.io/gh/aibtcdev/aibtcdev-daos/tree/main/contracts%2Fdao%2Fextensions

Expected behavior

"I could've used a little more coverage."

Screenshots

Image

whoabuddy avatar May 19 '25 17:05 whoabuddy

Thanks for reporting @whoabuddy

Regarding the asserts! line, I assume you don't have a test that triggers ERR_INSUFFICIENT_BALANCE. Can you confirm?

Note for assignee: If so, we should report report partial coverage (branching), the condition is always evaluated, but the thrown value (2nd arg) isn't necessary. It seems to be working with genhtml on my end, so maybe our branching format isn't compatible with codecov.

hugoclrd avatar May 20 '25 10:05 hugoclrd

Yes, that is correct, the printed tuple pattern is reused across a few contracts and all have the same issue. The asserts line is not covered by tests but will note any future mismatches here if they come up.

whoabuddy avatar May 20 '25 10:05 whoabuddy