Skip to content

Commit

Permalink
Revert PR #867
Browse files Browse the repository at this point in the history
  • Loading branch information
boyan-soubachov committed Feb 19, 2020
1 parent 624f997 commit 3ebf1dd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 40 deletions.
6 changes: 4 additions & 2 deletions 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
Expand Down
16 changes: 3 additions & 13 deletions suite/suite.go
Expand Up @@ -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)
Expand Down
25 changes: 0 additions & 25 deletions suite/suite_test.go
Expand Up @@ -10,7 +10,6 @@ import (
"time"

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

Expand Down Expand Up @@ -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)
}

0 comments on commit 3ebf1dd

Please sign in to comment.