go-mocking
gomock
Our great sponsors
go-mocking | gomock | |
---|---|---|
1 | 25 | |
0 | 7,517 | |
- | 5.7% | |
1.0 | 5.2 | |
8 months ago | 10 days ago | |
Go | Go | |
- | Apache License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
go-mocking
gomock
-
Is there a runtime mocking library using generics available or being worked on?
https://github.com/golang/mock has a code gen and a runtime mode
-
how to mock DBs
In all other layers, my repositories are mocked using https://github.com/golang/mock
-
How do you decide you are gonna use interface?
If you don't know how to mock databases, checkout some tutorials on it, it's a big topic, and I can't give you all the details on it. Checkout these repositories, they are used for mocking in golang https://github.com/golang/mock, https://github.com/stretchr/testify
-
Mocking database or use a test database
You can test the code outside those data classes using more general mocks. https://github.com/golang/mock
- Testes unitários com Golang
-
mock listener/conn via injection or just test a running server?
Have a look at https://github.com/golang/mock.
-
Dependency Injection in Golang
If you want to write tests, DI also can help you! Sometimes you need mocks for tests (to be independent of some modules like logger in tests), you have to generate it! There is an amazing tool for this task in go - GoMock. When you describe only needed methods in DI interface, the GoMock generate mocks just for those methods - it is faster and more readable in practice, than hundreds methods in mocks.
-
What is the real USP of Go's interfaces when compared to those in Java or C#?
I really disagree with this statement. In fact, there is a Google-developed mocking tool in the official Go organization - https://github.com/golang/mock. I am not a huge fan of mocking and I avoid it when I can, but there is nothing that indicates you must be writing Java code in Go if you're using mocks. You'll even find the use of mocks in the Go standard library test code.
- Gerando mocks de interfaces no go!
What are some alternatives?
mockery - A mock code autogenerator for Golang
sqlx - general purpose extensions to golang's database/sql
Testify - A toolkit with common assertions and mocks that plays nicely with the standard library
pgx - PostgreSQL driver and toolkit for Go
counterfeiter - A tool for generating self-contained, type-safe test doubles in go
monkey - Monkey patching in Go
go-sqlmock - Sql mock driver for golang to test database interactions
zerolog - Zero Allocation JSON Logger
minimock - Powerful mock generation tool for Go programming language
gock - HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽
realize - Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.
moq - Interface mocking tool for go generate