Skip to content

Instantly share code, notes, and snippets.

@chadaustin
Created September 19, 2015 01:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadaustin/ae1487ac0cf5b83851f2 to your computer and use it in GitHub Desktop.
Save chadaustin/ae1487ac0cf5b83851f2 to your computer and use it in GitHub Desktop.
package abstracttest
import (
"testing"
. "gopkg.in/check.v1"
)
type MySuite struct {
impl func()int
}
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }
type DSuite struct {
MySuite
}
func (s *DSuite) SetUpTest(c *C) {
s.impl = func() int { return 2; }
}
type ESuite struct {
MySuite
}
func (s *ESuite) SetUpTest(c *C) {
s.impl = func() int { return 1 + 1; }
}
var _ = Suite(&DSuite{})
var _ = Suite(&ESuite{})
func (s *MySuite) TestFoo(c *C) {
c.Assert(s.impl(), Equals, 2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment