Skip to content

Possibility of accepting an interface instead of testing.T #527

Description

@hrtkpf

What do you want to see?

Hello,

we have implemented a custom struct that embeds *testing.T and adds some internal functionality, but does not change the interface.

Our custom struct looks something like this:

type Custom struct {
	*testing.T
}

func (t *Custom) Errorf(format string, args ...any) {
	// Some custom functionality here

	t.T.Errorf(format, args...)
}

Using that custom struct with e2e-framework, however, is a bit difficult because funcs like Test in the Environment interface (see here) require a concrete *testing.T type instead of an interface.

Would it be possible to accept an interface instead, like testing.TB? Are there specific reasons why the concrete type was chosen instead of an interface? For reference, testify even has an own interface, which makes using custom wrappers like ours straightforward to use.

Thank you!

Extra Labels

No response

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

    kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions