Skip to content

Commit

Permalink
changed dependency to interface, s.t. consumers can easily mock the t…
Browse files Browse the repository at this point in the history
…esting.T type
  • Loading branch information
npxcomplete authored and boyan-soubachov committed Jan 29, 2020
1 parent 17a1e1d commit 045d838
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,29 @@ 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
Helper()

Errorf(format string, args ...interface{})
FailNow()
}

// 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 *testing.T
t TestingT
}

// T retrieves the current *testing.T context.
func (suite *Suite) T() *testing.T {
func (suite *Suite) T() TestingT {
return suite.t
}

// SetT sets the current *testing.T context.
func (suite *Suite) SetT(t *testing.T) {
func (suite *Suite) SetT(t TestingT) {
suite.t = t
suite.Assertions = assert.New(t)
suite.require = require.New(t)
Expand Down

0 comments on commit 045d838

Please sign in to comment.