Go tests and benchmarks are so easy to write and run: just add TestFoo and BenchmarkFoo functions to a bar_test.go file, and "go test" does the rest. It's currently doable, but it requires a 3rd party library (go-fuzz) and a bit of fluffing around. This will make fuzz testing an equally first-class citizen with standard Go tooling (just add FuzzFoo), and as such we'll probably see a lot more people testing with fuzzing.<p>I used go-fuzz in GoAWK and it found several bugs (see <a href="https://benhoyt.com/writings/goawk/#fuzz-testing" rel="nofollow">https://benhoyt.com/writings/goawk/#fuzz-testing</a>), and almost everyone who's done fuzz testing has similar reports. Certainly go-fuzz has found many, many bugs in Go itself: <a href="https://github.com/dvyukov/go-fuzz#trophies" rel="nofollow">https://github.com/dvyukov/go-fuzz#trophies</a><p>For what it's worth, I wrote an article for LWN about the upcoming support for built-in fuzzing in Go: <a href="https://lwn.net/Articles/829242/" rel="nofollow">https://lwn.net/Articles/829242/</a> (of course, if you want full details, read the full proposal).
I really hope this is a trend and randomized testing just becomes part of standard testing tools. I used jqwik extensively at my last job and it was very useful for finding issues with null on objects with lots of fields.<p>It's much easier to just describe how to construct data rather than coming up with test data and edge cases yourself. Sure you might have test cases for every nullable field, but do you have tests for every pair of nullable fields?<p>I also found some interesting behavior this way. StringUtils.trimToNull(str) == null is actually not the same as checking if a string is blank due to weird unicode peculiarities.
Is there a clear dividing line between fuzzing tests and property based testing? They seem to use different words, but do similar things, like generate interesting input and making sure things still work when that interesting input is applied.<p>Is the difference instrumentation vs hand written generators and hand written invariants?
While completely unrelated to the new fuzz feature, one library I'd love to see added to the standard library is one for more standard units besides time, such as a distance library. It would be awesome to be able to do something like `foo := 100 * distance.Meters` which returns a distance.Distance type.<p>At the company I work at we do a lot of stuff with distances and time and with the time library it's a lot easy to have strong time typing throughout the codebase, but without a standard distance library, I've seen things in meters, kilometers, miles, etc.<p>With every new version they can introduce new unit libraries until there are ones for velocity, acceleration, area, volume, mass, temperature, etc. This would make golang a great option for many business uses and scientific uses.<p>The other thing golang should standardize in it's stdlib that is testing related is a clock libary like facebookgo/clock library for time control. It's already standard practice to have the rand library be injected with a seed so you can have determinism for tests. The same is need for controlling time for many use cases if you want determinism in tests involving time. Making this part of the stdlib and making it best practice to always dependency inject a clock instead of using a global like time.Now() would go a long way to improving more complex unit/integration testing where time is involved.<p><a href="https://pkg.go.dev/github.com/facebookgo/clock" rel="nofollow">https://pkg.go.dev/github.com/facebookgo/clock</a>
Does anyone have experience with Gopter, a Golang Property Based testing library? <a href="https://github.com/leanovate/gopter" rel="nofollow">https://github.com/leanovate/gopter</a>
I like this idea a lot and I think I support adding it directly to the testing library. Fuzz testing has been pretty valuable to me in my time using it with Go and I would love to see it have more widespread support.
At the risk of turning this into a Rust thread, is fuzzing less relevant in languages with more strict handling of nullables?<p>I can see it being very useful in go-land, since it's relatively easy to make mistakes w/ nils that the compiler won't complain about, but I'm curious how far having a stronger type system can go vs fuzzing.