Skip to content

proposal: testing: allow importing API from _test.go functions in other tests #39565

@fernandomachado90

Description

@fernandomachado90

What version of Go are you using (go version)?

1.14

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

GOOS="darwin"
GOARCH="amd64"

What did you do?

In order to make it visible for tests that are located on different packages, I had to move a common database mock to a non _test.go file.

You can view it here:
https://github.com/fernandomachado90/go-transactions/blob/master/core/database_mock.go

What did you expect to see?

I wanted to be able to import and use common _test.go functions on different packages.

What did you see instead?

In order to avoid code duplication and reuse the same mock code in other places I have to make it available outside a _test.go file, which works but seems odd.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions