-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add a Run helper method #510
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,21 @@ func (suite *Suite) Assert() *assert.Assertions { | |
return suite.Assertions | ||
} | ||
|
||
// Run is a helper method to do a simple subtest. It sets `T()` to the | ||
// `*testing.T` of the subtest. | ||
func (suite *Suite) Run(name string, f func()) { | ||
oldT := suite.T() | ||
suite.T().Run(name, func(t *testing.T) { | ||
suite.SetT(t) | ||
|
||
defer func() { | ||
suite.SetT(oldT) | ||
}() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this result in race conditions if somebody called |
||
|
||
f() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than receiving an empty Would that prevent race conditions? |
||
}) | ||
} | ||
|
||
// Run takes a testing suite and runs all of the tests attached | ||
// to it. | ||
func Run(t *testing.T, suite TestingSuite) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JelteF could the name be confusing considering we already have
suite.Run
?