gotests icon indicating copy to clipboard operation
gotests copied to clipboard

Skip creating args for case when only one TestParams

Open mekegi opened this issue 7 years ago • 1 comments

A lot of cases when func with one param func Sin(x int) int, or writers func Write(w io.Writer, b []bytes) and in generated tests for such func we see a lot of boilercode like type args struct { x int } In my pull request I try ti prevent creating unuseful args type for one param Now generated tests looks like:

	tests := []struct {
		name string
		arg  string
	}{
	// TODO: Add test cases.
	}
	for _, tt := range tests {
		Foo3(tt.arg)
	}

instead of

	type args struct {
		s string
	}
	tests := []struct {
		name string
		args args
	}{
	// TODO: Add test cases.
	}
	for _, tt := range tests {
		Foo3(tt.args.s)
	}

mekegi avatar Jul 17 '18 16:07 mekegi

Coverage Status

Coverage remained the same at 96.327% when pulling 45ff4bc572dd0ea811a5692d13bfd73580230726 on mekegi:master into a680bea514ee00a99d2383786a99e24f8c374e57 on cweill:master.

coveralls avatar Jul 17 '18 16:07 coveralls