Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark test should be avoided #93

Open
zerjioang opened this issue Apr 4, 2019 · 2 comments
Open

Benchmark test should be avoided #93

zerjioang opened this issue Apr 4, 2019 · 2 comments
Labels

Comments

@zerjioang
Copy link

When selecting -all in gotests, Benchmark functions should be avoided for test generation purposes.

@cweill
Copy link
Owner

cweill commented Apr 7, 2019

@zerjioang: This does sound like a bug. Can you please provide an example code file where this happens?

@cweill cweill added the bug label Apr 7, 2019
@zerjioang
Copy link
Author

zerjioang commented Apr 9, 2019

@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}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants