Closed artem-zinnatullin closed 8 years ago
Can't you mock the component and use AdditionalAnswers.delegatesTo()
?
See http://site.mockito.org/mockito/docs/current/org/mockito/Mockito.html#27
I'll try and report, looks promising (did same thing manually), thanks for suggestion!
On Tue, 16 Feb 2016, 20:04 Thomas Broyer notifications@github.com wrote:
Can't you mock the component and use AdditionalAnswers.delegateTo()?
— Reply to this email directly or view it on GitHub https://github.com/google/dagger/issues/318#issuecomment-184956362.
@artem_zin
@tbroyer works like a charm, thanks a lot!
You also probably want to consider just creating a new component/module set if you're going to be overriding behavior so that you make sure the graph is properly composed. Just mocking the component's getSomething()
method doesn't actually replace the binding elsewhere in the graph.
Sure sure, I understand possible problems and apply it carefully.
At the moment, Dagger generates
final class DaggerSomeComponent implements SomeComponent
.Basically, I just want to
Mockito.spy(component)
to be able to override its behavior likeinject()
andgetSomething()
in integration tests, but the fact that class isfinal
makes me sad (not a fan of PowerMock).Can we please make impl classes non-final?