Please make a public generator for testify mocks akin to https://github.com/matryer/moq
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- go
- Domain
- testing-qa
Research direction
No repository file or test is named. Start by comparing testify's mock API with the moq generator and the MyInterface example; done means a public generator can turn an interface into a testify mock with configurable call counts and return values.
Written by the indexing model from the issue text.
Description
https://github.com/matryer/moq generates a mock from an interface which, though nice, isn't as rich a mocking language as testify (ability to just say how many times, or return what as part of test).
It would be great if testify could provide a means of generating, for instance, from:
type MyInterface interface {
DoSomething(int) (int, error)
}
this:
type MyInterfaceMock struct {
mock.Mock
}
func (m *MyInterfaceMock) DoSomething(in1 int) (int, error) {
replyArgs := m.Called(in1)
return replyArgs.Int(0), replyArgs.Error(1)
}
- Dominant language
- Go
- Stars
- 26.2k
- Forks
- 1.9k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stretchr/testify
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
internal/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
All issues in stretchr/testify
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100