Skip to content

Instantly share code, notes, and snippets.

@tasdomas
Created August 5, 2014 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tasdomas/649ecf86ba43e4cd4b36 to your computer and use it in GitHub Desktop.
Save tasdomas/649ecf86ba43e4cd4b36 to your computer and use it in GitHub Desktop.
Demonstration of undetected test failures with incorrect usage of gocheck.C
package gc
import (
"launchpad.net/gocheck"
)
func Failure(c *gocheck.C) func() {
return func() {
// fails immediately
c.Fail()
}
}
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