testify
testify copied to clipboard
suite: allow Suite methods to take *testing.T parameter
Summary
Allow suite methods to take *testing.T
parameter (as normal tests do). This is BC, and we are already messing with reflection there, so no penalties either.
Changes
Extend allowed suite method signature to include optional *testing.T
.
Fail with a friendly error when the signature doesn't match (before it panicked).
Motivation
There are many places where you need t
, like for example for mocks and other testing libraries. And typing s.T()
get's tedious after a while, and is completely avoidable at no cost :)
type MyTestSuite struct {
suite.Suite
}
func (s *MyTestSuite) TestLorem(t *testing.T) {
s.Same(t, s.T())
mockA := mocks.NewMockA(t)
mockB := mocks.NewMockB(t)
mockIHaveTooManyMocks := mocks.NewMockMyLife()
testStuff(mockA, mockB, mockIHaveTooManyMocks)
}
func (s *MyTestSuite) TestSimple() {
s.NotEqual("this is", "backwards compatible")
}