Closed
Description
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.
Activity
matryer commentedon Jan 28, 2014
I wouldn't use that pattern. And it turns out it isn't very easy to do at all. @tyleerb - any ideas?
tylerstillwater commentedon Jan 28, 2014
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?
—
Reply to this email directly or view it on GitHub.
matryer commentedon Jan 28, 2014
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: