Skip to content

Instantly share code, notes, and snippets.

@chadaustin
Created September 21, 2015 17:01
Show Gist options
  • Select an option

  • Save chadaustin/45c3032b30f0091b8338 to your computer and use it in GitHub Desktop.

Select an option

Save chadaustin/45c3032b30f0091b8338 to your computer and use it in GitHub Desktop.
package abstracttest
import (
"fmt"
"testing"
. "gopkg.in/check.v1"
)
type MySuite struct {
impl func()int
}
func (s* MySuite) SetUpTest(c *C) {
fmt.Println("MySuite::SetUpTest")
}
// 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) {
fmt.Println("DSuite::SetUpTest")
s.impl = func() int { return 2; }
}
type ESuite struct {
MySuite
}
func (s *ESuite) SetUpTest(c *C) {
fmt.Println("ESuite::SetUpTest")
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