-
Notifications
You must be signed in to change notification settings - Fork 34
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
feat: improve code coverage #438
Conversation
✅ Deploy Preview for contracts-stylus canceled.
|
…ov-great-again # Conflicts: # contracts/src/token/erc721/extensions/consecutive.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactoring party 😄 Nice work, added a couple of comments
#( #contract_declarations )* | ||
let res = #fn_block; | ||
let test = | #( #contract_arg_defs ),* | #fn_block; | ||
let res = test( #( #contract_args ),* ); | ||
::motsu::prelude::Context::current().reset_storage(); | ||
res | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the PR description you mention that you added missing tests to code coverage, but there aren't any here.
Maybe you forgot to push?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a very good question:D
Actually these few lines of code (where you commented) did main job..
Each test case body, even marked with #[motsu::test]
is included into code coverage now.
By the end we've received more covered code lines, that inflated total code coverage by 11-12%.
A bit scammy, but I feel there is more value in test cases and test functions included into coverage. Considering that, we can increase our target for a higher percentage of coverage by the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "missing tests" I was referring to both here and in my findings are tests for non-covered paths in our contracts (points 4-7 in findings) 😅 Many of our code paths are not covered, even the ones that are not dependent on interacting with other contracts. If you don't plan on adding those now (I wouldn't blame you, we should add them as we go along), could you then update the description as per #438 (comment)?
I really don't see the benefit of including tests in code coverage. The primary concern of code coverage metrics is ensuring the reliability and correctness of the production code, or in our case the contracts.
This is why cargo-llvm-cov
, our coverage tool, excludes test files by default.
Making sure that test lines are covered serves no practical purpose other than inflating the coverage percentage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.. and I was referring to an actual test body:D
This pr has frequent conflicts with a new code added. Make sense to merge it sooner.
There are many uncovered places in the code base (mostly covered by e2e, but not motsu
). So there is a work left to be done.
We can think about centralized approach of excluding all test cases. But not as it was before: some tests are included, other randomly excluded. Coverage of missing lines has bigger priority at the moment:D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @qalisander !
@qalisander you also need to change in antora docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 🔥
3a7bc3b
to
b52baa6
Compare
I've updated antora docs, examples and readme's. Now all of them should use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @qalisander! Go go go 🚀
Disable code coverage for
sol!
andsol_interface!
macros.Enforce
#[storage]
macro instead ofsol_storage!
. (#[storage]
struct is recognized by codecov)Add missing tests to code coverage.
Towards #426