2017-09-17 7 views
2

golangにデザインパターンのリポジトリを構築しています。すべてのテストを実行するために、私はこのbashスクリプトを使用します。できます。複雑なフォルダ構造でテストする

#!/bin/bash 
go test creational/abstract_factory/*.go 
go test creational/builder/*.go 
go test creational/factory/*.go 
go test creational/pool/*.go 
go test creational/prototype/*.go 
go test creational/singleton/*.go 

それは正常に動作します:すべて一つのディレクトリになければなりません

prompt> ./runtests.sh 
ok  command-line-arguments 0.006s 
ok  command-line-arguments 0.006s 
ok  command-line-arguments 0.006s 
ok  command-line-arguments 0.006s 
ok  command-line-arguments 0.005s 
ok  command-line-arguments 0.006s 

をしかし、私はgo testに複数のディレクトリを送信しようとすると...私は、ファイルの名前このメッセージを」受信し、生成に関する/プールを持っています/ and creational/factory/"と書かれています。これが私がそのbashスクリプトを作成した理由です。

すべてのフォルダを1つのコマンドでテストする可能性はありますか?

答えて

3

...を使用すると何が問題になりますか?その後、creationalにディレクトリを変更し、

go test ./... 

これは、すべてのサブフォルダに再帰し、見つかったすべてのパッケージのテストを実行します。詳細は、Difference in output when calling go test with packageを参照してください。 How do you run `go test` when test files are within a module?

注:./...を使用した場合、サブパッケージのサブパッケージのパッケージは1.9から始まり、一致しません。出典:Go 1.9 Release Notes - Vendor matching with ./...。 Go 1.9より前はgo test ./...vendorサブフォルダに入っていて、販売されたパッケージのテストを実行しました。

関連する問題