Skip to content

NewFoo(t TestingT): Not documented #1832

Open

Description

@guettli

The generated code contains this method:

// NewFoo creates a new instance of Foo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewFoo(t interface {
	mock.TestingT
	Cleanup(func())
}) *Foo {

I use testify mock for several months now, and just found that.

There seems to be no documentation for that:

At least not here: https://pkg.go.dev/github.com/stretchr/testify/mock

And not here: https://github.com/stretchr/testify


Is there a reason for that? I think that method is very handy, because it lets your test fail, instead of getting a random panic in another goroutine if you have an error in On(...).

Activity

  1. dolmen commented on May 7, 2026

    @dolmen
    Collaborator

    I don't understand this issue.

    What code generator are your talking about?

  2. added
    questionQuestions related to API usage
    rejected/invalidNot a bug but a misunderstanding by the requester
    and removed on May 7, 2026
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

    questionQuestions related to API usagerejected/invalidNot a bug but a misunderstanding by the requester

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions