-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
testing: support subtests in fuzzer #47413
Comments
This comment has been minimized.
This comment has been minimized.
cc @golang/fuzzing Sorry, I'm still not sure I understand this.
I'd expect this to be written as:
|
I tried to explain that in the text: "
I guess that's the core of it – I don't want a separate unit test. The real package I'm working on is a data marshaller / unmarshaller. The unit tests for correct data looked almost identical to fuzz tests (unmarshal bytes into an object, re-marshal this object, compare bytes), so I merged them, as this example tried to show. Fuzzing draft proposal says talks about it: "In the long term, this design could start to replace existing table tests, seamlessly integrating into the existing Go testing ecosystem." Maybe I'm just living in the future.
If you think about that part as a unit test, then parallelism advantage is clear.
Note that your example:
My proposal allows one to write a single test function that both tests happy cases and feeds them to the fuzzer. Then the only tests that should be written separately are tests for returned error values. |
Thanks for explaining, I think I understand better what you're getting at. This would be a pretty big design change, so I'd like to make sure @katiehockman and @rolandshoemaker have a voice in this, too. Katie's on vacation for a few more weeks, so we won't be able to make a decision right away. My API design intuition is that it's better to keep |
Consider the following test using
testing.F
:It fails with an unhelpful error message:
It may be made better by adding additional context into
f.Error
line. But there is another way for that available totesting.T
, but nottesting.F
- subtests:This includes subtest name in the error message automatically, which is very helpful:
In the end, I want to be able to do something like that:
Note that
f.Run
accepts a function acceptingtesting.T
instead oftesting.F
. That allows one to run subtests in parallel and also removes ambiguity about the fuzz corpus - this way, there is only one for the wholeFuzzAtoi
function.f.Add
could be called in both places - inside and outside of a subtest. So it should be made thread-safe.This issue is different from #46780 as it requests subtests support for
testing.F
instead of more complicated subfuzz targets.The text was updated successfully, but these errors were encountered: