diff --git a/suite/interfaces.go b/suite/interfaces.go index b55db4362..b37cb0409 100644 --- a/suite/interfaces.go +++ b/suite/interfaces.go @@ -1,10 +1,12 @@ package suite +import "testing" + // TestingSuite can store and return the current *testing.T context // generated by 'go test'. type TestingSuite interface { - T() TestingT - SetT(TestingT) + T() *testing.T + SetT(*testing.T) } // SetupAllSuite has a SetupSuite method, which will run before the diff --git a/suite/suite.go b/suite/suite.go index d05ec595f..619530187 100644 --- a/suite/suite.go +++ b/suite/suite.go @@ -17,31 +17,21 @@ import ( var allTestsFilter = func(_, _ string) (bool, error) { return true, nil } var matchMethod = flag.String("testify.m", "", "regular expression to select tests of the testify suite to run") -type TestingT interface { - Run(name string, f func(t *testing.T)) bool - Errorf(format string, args ...interface{}) - Fatalf(format string, args ...interface{}) - FailNow() - Log(args ...interface{}) - Logf(format string, args ...interface{}) - Skip(args ...interface{}) -} - // Suite is a basic testing suite with methods for storing and // retrieving the current *testing.T context. type Suite struct { *assert.Assertions require *require.Assertions - t TestingT + t *testing.T } // T retrieves the current *testing.T context. -func (suite *Suite) T() TestingT { +func (suite *Suite) T() *testing.T { return suite.t } // SetT sets the current *testing.T context. -func (suite *Suite) SetT(t TestingT) { +func (suite *Suite) SetT(t *testing.T) { suite.t = t suite.Assertions = assert.New(t) suite.require = require.New(t) diff --git a/suite/suite_test.go b/suite/suite_test.go index a17860008..5d757dd1b 100644 --- a/suite/suite_test.go +++ b/suite/suite_test.go @@ -10,7 +10,6 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -483,27 +482,3 @@ func (s *CallOrderSuite) Test_A() { func (s *CallOrderSuite) Test_B() { s.call("Test B") } - -func TestMockTCompatibility(t *testing.T) { - suiteTester := new(SuiteTester) - suiteTester.SetT(t) - - // compatible with mock.T - _, ok := suiteTester.T().(mock.TestingT) - assert.True(t, ok) - - // compatible with testing.T - _, ok = suiteTester.T().(*testing.T) - assert.True(t, ok) - - // compatible with testing.TB - _, ok = suiteTester.T().(testing.TB) - assert.True(t, ok) - - // control check - type wrongInterface interface { - NotInSuiteT() string - } - _, ok = suiteTester.T().(wrongInterface) - assert.False(t, ok) -}