Last active
May 3, 2017 19:02
-
-
Save dperny/dacdcd9f43c24c480eb0c76e7cf97bae to your computer and use it in GitHub Desktop.
Defer if passing example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func DeferIfPassing(t *testing.T, f func()) { | |
if t.Failed() { | |
return | |
} | |
f() | |
} | |
TestDeferIfPassing(t *testing.T) { | |
// skip a bit, fill in the blanks | |
defer DeferIfPassing(t, func() { someCleanUp(with, some, args) }) | |
require.Fail(t, "Fail this test") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.--------------. | |
| ~MAGIC~ | | |
| ____ | | |
| |.--.| | | |
| || || | | |
| ||__|| | | |
| ||\ \| | | |
| |\ \_\ | | |
| |_\[_] | | |
| | | |
| ~MORE MAGIC~ | | |
'--------------' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment