Skip to content

Commit 55d8b57

Browse files
Add interface tests for suite.T
1 parent 9dfcf7c commit 55d8b57

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

suite/suite_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/stretchr/testify/assert"
13+
"github.com/stretchr/testify/mock"
1314
"github.com/stretchr/testify/require"
1415
)
1516

@@ -482,3 +483,27 @@ func (s *CallOrderSuite) Test_A() {
482483
func (s *CallOrderSuite) Test_B() {
483484
s.call("Test B")
484485
}
486+
487+
func TestMockTCompatibility(t *testing.T) {
488+
suiteTester := new(SuiteTester)
489+
suiteTester.SetT(t)
490+
491+
// compatible with mock.T
492+
_, ok := suiteTester.T().(mock.TestingT)
493+
assert.True(t, ok)
494+
495+
// compatible with testing.T
496+
_, ok = suiteTester.T().(*testing.T)
497+
assert.True(t, ok)
498+
499+
// compatible with testing.TB
500+
_, ok = suiteTester.T().(testing.TB)
501+
assert.True(t, ok)
502+
503+
// control check
504+
type wrongInterface interface {
505+
NotInSuiteT() string
506+
}
507+
_, ok = suiteTester.T().(wrongInterface)
508+
assert.False(t, ok)
509+
}

0 commit comments

Comments
 (0)