Open zerjioang opened 5 years ago
@zerjioang: This does sound like a bug. Can you please provide an example code file where this happens?
@cweill, when I execute the gotests with -all flag, the functions with following header definition:
func BenchmarkGetState(b *testing.B){}
are also treated as test candidate generating following code snippet:
func TestBenchmarkGetState(t *testing.T) {
type args struct {
b *testing.B
}
tests := []struct {
name string
args args
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
BenchmarkGetState(tt.args.b)
})
}
}
I wont consider this as a bug, but could be a great improvement for those project that have Test functions and Benchmarks.
The way I found to fix this is using the regular expression option an running it via:
${GOPATH}/bin/gotests -excl Benchmark.* -w ${file}
When selecting -all in gotests, Benchmark functions should be avoided for test generation purposes.