I learn from the go flags from Testing flags
And I write some test files in my project.
This is my service
folder:
- service
- family_limit_settings.go
- family_limit_settings_test.go
- xxxxxx.go (others go source files)
- xxxxxx_test.go (others go test source files)
and my family_limit_settings_test.go
content is as follows:
func TestSaveSettings(t *testing.T) {
// todo
}
func TestListByFamilyId(t *testing.T) {
// todo
}
func TestFamilyLimitVerify(t *testing.T) {
// todo
}
func BenchmarkFamilyListByFamilyId(b *testing.B) {
// todo
}
func BenchmarkFamilySaveSettings(b *testing.B) {
// todo
}
func BenchmarkFamilyLimitVerify(b *testing.B) {
// todo
}
my first question
I cd
this service file and run command follow:
go test -v -bench=.
But I find it run other test function those are not benchmark function.(I know it because something wrong occurs in other common test function)
my second question
go test -v -bench=. -run=BenchmarkFamilyListByFamilyId
I want to execute the benchmark function with the name BenchmarkFamilyListByFamilyId
but I found it execute all the benchmark functions.