func TestMyFunc(t *testing.T) { c := check.New(t) result := myFunc(2) c.Check(result, check.Equals, 10) } func myFunc(x int) int { return 5*x }
func (s *MySuite) TestMyFunc(c *check.C) { var tmpDir string c.Assert(os.Mkdir(tmpDir, 0755), check.IsNil) defer os.RemoveAll(tmpDir) ... }
type MySuite struct { dir string } func (s *MySuite) SetUpSuite(c *gocheck.C) { ... } func (s *MySuite) TestMyFunc(c *gocheck.C) { ... } func (s *MySuite) TearDownSuite(c *gocheck.C) { ... } func Test(t *testing.T) { gocheck.Suite(&MySuite{}) }This example shows how to use a suite to group together related tests. We define a struct that contains the state we want to maintain across multiple tests, and then use SetUpSuite() and TearDownSuite() functions to set up and tear down the fixture. We also register the suite by passing it to the Suite() function. Based on the code examples and the description, this package is a testing library for Go applications.