Add interface tests for suite.T

pull/687/head^2
Boyan Soubachov 2020-02-05 21:03:40 +11:00 committed by Boyan Soubachov
parent 9dfcf7c562
commit 55d8b5740c
1 changed files with 25 additions and 0 deletions

View File

@ -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)
}