4 ms·
Go doesn't have any mocking framework like Mockito/Java or Rspec mock. You will end up writing a ton of code yourself if you want to mock something simple.
by trungonnews 14y ago
Go doesn't have any mocking framework like Mockito/Java or Rspec mock. You will end up writing a ton of code yourself if you want to mock something simple.
- drivebyacct2 14y agoUh what? No, that couldn't possibly be less true. Have you ever heard of "interfaces" in Go? They're kind of an important feature.
- trungonnews 14y agoThat's what the other gophers say too. Java has interfaces too, but it also has Mockito that makes testing much easier. You should look into it. Mocking library will help reduce boiler code. You would know that if you had used one.
- drivebyacct2 14y ago>You would know that if you had used one. Cute.
- trungonnews 14y agoMy bad. :)
- burntsushi 14y agoGo interfaces are not the same as Java interfaces. Go interfaces are implemented using structural sub-typing.
- prodigal_erik 14y agoI've only dabbled a bit but I haven't seen a DSL that easily creates a mock that implements all the methods of a given interface, verifies that methods were (not) called with expected arguments, and returns or throws canned values. It's not difficult to write mocks from scratch, but it's very repetitive and hard to skim what the test does.
- trungonnews 14y agoYou nailed it!
- enneff 14y agohttps://code.google.com/p/gomock/ https://code.google.com/p/gomock/ works well.