Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's very hard to do Test Driven Development in Go because there is no mocking library that can help with stubbing constructor or static method.

Well, you'll be happy to learn that Go doesn't have constructors or static methods, then. :)

What Go does have is a standard unit testing framework which is quite nice: http://golang.org/pkg/testing/

"Mocks" in general are a cumbersome and somewhat lame attempt to deal with the many limitations of inheritance-based designs in languages such as Java. In Go, there's no need to create a Mock, because you can easily create a wrapper object for whatever object you want to test using Go's anonymous member syntax. Then you simply override whatever methods you want to on the wrapper object, and let the others get passed through.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: