Created
September 21, 2015 17:01
-
-
Save chadaustin/45c3032b30f0091b8338 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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