Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Generating unit tests for current function generates tests for other functions, too #1483

Description

If you have two functions where one's name is a prefix of the other's and you generate unit tests for the shorter one, tests are also generated for the other one:

func foo()    {}
func fooBar() {}

Upon executing "Go: Generate Unit Tests for Function" for foo() I get a message saying "Generated: Test_foo, Test_fooBar" and the following tests:

func Test_foo(t *testing.T) {
	tests := []struct {
		name string
	}{
	// TODO: Add test cases.
	}
	for range tests {
		t.Run(tt.name, func(t *testing.T) {
			foo()
		})
	}
}

func Test_fooBar(t *testing.T) {
	tests := []struct {
		name string
	}{
	// TODO: Add test cases.
	}
	for range tests {
		t.Run(tt.name, func(t *testing.T) {
			fooBar()
		})
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions