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

changed dependency to interface #867

Merged
merged 4 commits into from Jan 29, 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: 2 additions & 4 deletions suite/interfaces.go
@@ -1,12 +1,10 @@
package suite

import "testing"

// TestingSuite can store and return the current *testing.T context
// generated by 'go test'.
type TestingSuite interface {
T() *testing.T
SetT(*testing.T)
T() TestingT
SetT(TestingT)
}

// SetupAllSuite has a SetupSuite method, which will run before the
Expand Down
14 changes: 11 additions & 3 deletions suite/suite.go
Expand Up @@ -16,21 +16,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
Errorf(format string, args ...interface{})
FailNow()
Log(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 *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