-
Take advantage of Go’s built-in testing framework to write idiomatic tests.
-
Make sure that tests cover positive and negative cases.
-
Use the
testdatadirectory to hold data for running your tests. -
Use
t.Context() instead ofcontext.Background(). -
Consider whether go-cmp would simplify comparisons.
-
Use table tests to validate the same logic with different data.
-
If your tests are independent (and they should be), use
t.Parallel().
Progress is saved on this device.