GAE/Goで特定の関数だけテストを実行したい場合のコマンド
ローカルで開発を行なっていて、確認のためにgitにcommit前に特定の関数だけのテストを実行したい場合など有効。
シンプルな表示だけをしたい場合
コマンド
goapp test ./テストしたい関数の所属するディレクトリ/... -run 実行したい関数名
実行結果例
ok path/to/テストした関数の所属するディレクトリ テストにかかった秒数
被テスト関数が出力するログや各テストケースも表示したい場合
コマンド
goapp test ./テストしたい関数の所属するディレクトリ/... -v -run 実行したい関数名
実行結果例
以下の内容が表示される
- 被テスト関数が出力するログ
- 各テストケース
ok path/to/テストした関数の所属するディレクトリ テストにかかった秒数
コマンドの引数の意味
ディレクトリ/...
ディレクトリ以下のテストを実行する
参考 : はじめてのgo test - Qiita
-v
-v
Verbose output: log all tests as they are run. Also print all
text from Log and Logf calls even if the test succeeds.
引用元 : goapp test -helpコマンド
意訳 :
冗長な出力 : 動作する全てのテストのログを記録する。Logの出力する全てのテキストを表示し、テストが成功したとしても、Logfを呼び出す。
-run regexp
-run regexp
Run only those tests and examples matching the regular expression.
For tests the regular expression is split into smaller ones by
top-level '/', where each must match the corresponding part of a
test's identifier.
引用元 : goapp test -helpコマンド
意訳 :
正規表現に適合するテストとexamplesを動作させる。
テストにおいては、正規表現は最上位の'/'で分割される。分割された各々の箇所は、テストの識別子の部分一致に適合しなければならない。