馃挕 In Go tests, mark helper functions like assertEquals and doRequest with t.Helper() This causes the Go tooling to point to the line where the function was called rather than a line in the helper function, which makes it easier to debug a failing test. #golang

Sep 12, 2025 路 1:05 PM UTC

6
9
118
5,250
Sort replies: Relevant Recent Liked
Replying to @joncalhoun
I see you already switched to GoLand 馃憖
1
1
124
I鈥檝e been trying it out for a month or so and plan to write up some comparisons in the future.
1
1
82
Replying to @joncalhoun
Do you still need to use this if yo don't have assert helper functions?
1
114
It can be useful for any helper functions. Setup, teardown, a doRequrest helper to perform an http request, etc.
1
52
Replying to @joncalhoun
Do people write custom asserts like this in real projects? I thought it's just for tutorials. In real code, I only see libs like stretchr/testify
1
160
Sometimes orgs/people don鈥檛 want to import a big library, and instead they build a small assertion library that they use internally. This advice also applies to set up and tear down functions, along with other helpers. Basically any scenario where you鈥檇 rather the test output point to the caller when an error is encountered.
1
1
103
Replying to @joncalhoun
Cleaner stack traces are a huge win for developer experience
1
52
Replying to @joncalhoun
Thanks for this. I didn't know, this wil help a lot 馃槉
1
19