Skip to content

Instantly share code, notes, and snippets.

@mattmc3 mattmc3/unittest_method.go
Last active Apr 14, 2017

What would you like to do?
Go: unittest method template
func Test{{THING}}(t *testing.T) {
var tests = []struct {
input string
expected string
{``, ``},
for _, tt := range tests {
method := fmt.Sprintf(`{{THING}}(%#v)`, tt.input)
actual, err := {{THING}}(tt.input)
if err != nil {
t.Errorf(`%v errored unexpectedly: %#v`, method, err.Error())
} else if !reflect.DeepEqual(actual, tt.expected) {
t.Errorf(`%v == %#v; want %#v`, method, actual, tt.expected)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.