Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert PR #867 #894

Merged
merged 1 commit into from Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
}