LoginSignup
1
0

More than 3 years have passed since last update.

cweill/gotestsでtestifyを利用する

Last updated at Posted at 2020-01-05

動機

プロダクトコードからTableDrivenTestsに基づいたテストコードを生成してくれる cweill/gotestsでは値の比較はreflect.DeepEqualを用いている. testifyを利用することができるようになったようなので試す.(PR#109

手順

CLI

# reflect.DeepEqual
$ gotests -w -only Hello hello.go -exported hello_test.go

# stretchr/testify/assert
$ gotests -w -template testify -only Hello hello.go -exported hello_test.go

エディタ

VSCodeの場合settings.jsonに下記項目を追加する.

{
    "go.generateTestsFlags": [
        "-template",
        "testify"
    ]
}

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0