mirror of https://github.com/stretchr/testify.git
Add interface tests for suite.T
parent
9dfcf7c562
commit
55d8b5740c
|
@ -10,6 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -482,3 +483,27 @@ 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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue