Skip to content

If a matcher panics and AssertExpectations has been deferred, a hang occurs #1155

@cchalm

Description

@cchalm

In the code below, the test case TestMatcherPanic hangs. To reproduce the hang, two conditions must be met:

  1. AssertExpectations is deferred
  2. An argument matcher panics
import (
	"testing"

	"github.com/stretchr/testify/mock"
)

type Mock struct {
	mock.Mock
}

func (_m *Mock) F() {
	_m.Called()
}

func TestMatcherPanic(t *testing.T) {
  m := &Mock{}
  defer m.AssertExpectations(t)

  matcher := mock.MatchedBy(func(_ interface{}) bool {
    panic("test")
  })
  m.On("F", matcher)

  m.F()
}

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