We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
In my previous post, I've outlined how I write tests.
Since I ended up writing a lot of code multiple times, I made my life slightly easier by creating two simple snippets for Visual Studio Code.
tcimp
You can use the tcimp
snippet to quickly add the basic imports needed for writing a test.
It uses the testing
and assert
libaries.
Just type tcimp
and you'll get the following snippet:
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/<package>"
)
tc
Typing tc
sets up the basic structure for an empty test and results in:
func Test_<name>(t *testing.T) {
type test struct {
name string
}
var tests = []test{}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
})
}
}
You can get the snippets from here.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.