Skip to content

Instantly share code, notes, and snippets.

@koyo-miyamura

koyo-miyamura/hoge.go

Last active Apr 27, 2019
Embed
What would you like to do?
go tests でテストの自動生成 http://kdnakt.hatenablog.com/entry/2019/01/03/080000
package add
// Add add two integer
func Add(a int, b int) int {
return a + b
}
package add
import "testing"
func TestAdd(t *testing.T) {
type args struct {
a int
b int
}
tests := []struct {
name string
args args
want int
}{
{
"add",
args{
a: 1,
b: 2,
},
3,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Add(tt.args.a, tt.args.b); got != tt.want {
t.Errorf("Add() = %v, want %v", got, tt.want)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment