We want to add tests to increase coverage to 80% and gain certainty over our code. Currently we are between 60-70%. Use your judgment regarding which tests to add.
Please breakup PRs by package
Ordered in prioritiy:
Focusing on code coverage metrics doesn't actually mean you're testing what should be tested. You could have one function and one test which tests that function, now you have 100% test coverage but if you happen to pass a string instead of int (just silly example), the function is broken.
Rather, try to focus testing the areas where testing is actually needed. You have a function that adds two numbers? Not really high-impact (nor effort) to test it. But for the functions that validates a transaction needs to have more than 100% of test coverage to be properly tested.
Might not be in my power to affect filecoin development / testing, but I've seen too many times a misdirected focus on code coverage metrics rather than covering high-impact logic.
Thanks @VictorBjelkholm, we have been thinking about testing for some time, and I agree with you that 100% coverage does not protect you from logic issues. If you want to see more details on discussions around testing take glimpse at #33.
This issue is here to make sure that the code we have is in good order and requiring a baseline of coverage is especially valuable to ensure that not only happy paths are tested from the get go.
I think coverage is a useful metric, but obviously not something to be obsessed about. I find both overall metrics and metrics for PRs to be useful signals.
You have a function that adds two numbers? Not really
high-impact (nor effort) to test it.
On the other hand if it potentially affects billions of dollars of value the 30 seconds it takes to write a test is probably worth the peace of mind. I've definitely seen functions "too simple to test" be the source of real bugs.
If we are interested in increasing the certainty we have over our code through automated testing, I can think of a few different tools/approaches which might help us out:
go-filecoin.Questions for the group:
testing/quick?go-mutesting?Caveats:
testing/quick package, but I have used a similar property-based testing library for Haskell, QuickCheck.zimmski/go-mutesting package, but I have used a similar mutation testing tool for Java, PIT.I think both property based tests and mutation tests are great approaches to ensure quality. They also should make it a lot easier to add meaningful tests that can survive refactors that don't change the api surface.
To move forward with this issue I would suggest to use table-drive tests in combination with exploring testing/quick.
Doing mutation testing is great, but I would punt setting that up to a later point when the code is a bit more stable and we are adding the next layer of security.
We should make sure our code coverage excludes test helpers, which are generally (but not always) untested. They generally go in testing.go files. Edit: this is done
Probably useful to see where our coverage has dropped, for example here:
we can see this change seems to have dropped it significantly: https://codecov.io/gh/filecoin-project/go-filecoin/commit/034c8b5e09b880905a59d2f65bf826da49488dcc
Turn this into an epic, with 1 story per package.
Closing this out, no longer a goal.
Most helpful comment
Closing this out, no longer a goal.