-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Is it possible to implement partial mocking? #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I wouldn't use that pattern. And it turns out it isn't very easy to do at all. @tyleerb - any ideas? |
It may be easier to provide a way to create a "set" of mocks that can be applied in a single line. On January 28, 2014 at 9:13:34 AM, Mat Ryer (notifications@github.com) wrote: I wouldn't use that pattern. And it turns out it isn't very easy to do at all. @tyleerb - any ideas? — |
But first - I’d consider extracting the information into a new concept… if one thing uses itself, that’s just internals - which I am a fan of testing, but Go makes it hard. If you can pull it out into something else, i.e. the thing you’re testing has a pointer to the other thing - then you can easily mock that other thing. On Jan 28, 2014, at 10:18 AM, Tyler notifications@github.com wrote:
|
I think it may be impossible,but I am want to share my thought,for example
func (s *impl) test() {
if needToPartialMocked() {
doSomething()
}else{
//.......if I want to come here,I must mock dependency0 and dependency1
doElse()
}
}
func (s *impl) needToPartialMocked() bool{
if xxxx() {
return s.dependency0,IsExisted();
}else{
return s.dependency1.IsExisted();
}
}
As commenting,if I can partial mock the method "needToPartialMocked()",set it return false directly,in some test case,lots of mocking stuff can be cut away.
The text was updated successfully, but these errors were encountered: