Created
August 5, 2014 07:45
-
-
Save tasdomas/649ecf86ba43e4cd4b36 to your computer and use it in GitHub Desktop.
Demonstration of undetected test failures with incorrect usage of gocheck.C
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
package gc | |
import ( | |
"launchpad.net/gocheck" | |
) | |
func Failure(c *gocheck.C) func() { | |
return func() { | |
// fails immediately | |
c.Fail() | |
} | |
} |
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
package gc | |
import ( | |
"testing" | |
"launchpad.net/gocheck" | |
) | |
func TestPackage(t *testing.T) { | |
gocheck.TestingT(t) | |
} | |
type Suite struct { | |
runner func() | |
} | |
var _ = gocheck.Suite(&Suite{}) | |
func (s *Suite) SetUpTest(c *gocheck.C) { | |
s.runner = Failure(c) | |
} | |
// This test will not fail | |
func (s *Suite) TestFailure(c *gocheck.C) { | |
s.runner() | |
} | |
// This test will fail as expected | |
//func (s *Suite) TestFailuteImmediate(c *gocheck.C) { | |
// Failure(c)() | |
//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment