use-ink / ink

Polkadot's ink! to write smart contracts.
https://use.ink
Apache License 2.0
1.35k stars 426 forks source link

Code coverage for unit tests #730

Open mmagician opened 3 years ago

mmagician commented 3 years ago

I wonder if there are any existing tools to check the unit test coverage for ink! contracts? I tried using tarpaulin once on ink!, but didn't get satisfactory results - perhaps that's not the best tool for the job or else I was using it incorrectly.

I'm asking because after reviewing a number of grant deliveries for the Open Grants Program I figured that a report proving (high) test coverage should be an extra criterion for accepting such grants.

Perhaps implementing a code coverage tool could be a potential grant in itself, and one that would hugely benefit the ink! developers IMO. Ideally, the task would be contained to tweaking tarpaulin or similar tool to fit ink! needs, without necessarily touching the codebase here. Please share your thoughts on this and if this makes any sense at all. If so, I would be happy to write an RFP for this.

HCastano commented 3 years ago

@mmagician I don't see why normal Rust tooling wouldn't work here. Maybe there are some intricacies I'm not aware of though (cc @cmichi @Robbepop ?).

Robbepop commented 3 years ago

I'm asking because after reviewing a number of grant deliveries for the Open Grants Program I figured that a report proving (high) test coverage should be an extra criterion for accepting such grants.

I agree!

Perhaps implementing a code coverage tool could be a potential grant in itself, and one that would hugely benefit the ink! developers IMO.

I think it was better to improve existing code coverage tools to better handle macro heavy code. In Rust there currently is mainly tarpaulin and grcov. Both of which have their problems from what I can tell. Our coverage reporting CI isn't very stable either unfortunately.

alxs commented 3 years ago

@Robbepop there's an item in https://github.com/xd009642/tarpaulin/issues/351 implying that tarpaulin currently misses lines originating from macros in function bodies. Could the current problems boil down to this?

@cmichi @xgreenx @themarkian @WiktorStarczewski @VadneyK @KaiserKarel and anyone else reading: have you tried using tarpaulin with ink! contracts? What issues did you run into?

0xMarkian commented 3 years ago

hey @alxs! neither I nor green had experience with it. We will let you know if we will stumble upon something useful

SkymanOne commented 1 year ago

@0xMarkian have there been any updates on the issue on your front?