Re:Error stack traces in Go with x/xerror
by benhoyt on Monday August 23, 2021 @09:21PM
(#28284099)
Aside from the "assertion" libraries, which I have mixed feelings about, I often use table-driven tests to avoid this. That way each test is generally one line, like `{"1234", 1234}` for testing an Atoi function. Or, I've seen little test helper functions that "fatal" the test on error -- that way it only takes one line instead of three: https://play.golang.org/p/WIALie5fsgd
[ Parent
| on HN ]
Re:Error stack traces in Go with x/xerror
by simiones on Tuesday August 24, 2021 @06:48AM
(#28287076)
The thing I hate about table-driven tests is that they make it slightly harder to identify where an error has occurred, and much harder to debug the specific test case that triggered the error, especially in Go where dlv lacks value breakpoints (or it did last time I checked - if they've added that in the meantime, this becomes much less of a problem).