fabioCollini / DaggerMock

A JUnit rule to easily override Dagger 2 objects
Apache License 2.0
1.16k stars 91 forks source link

Custom inject INTO dagger module #69

Closed marc-neureiter closed 6 years ago

marc-neureiter commented 6 years ago

Hi, first and foremost: Thanks for your fabulous work! I'm really happy that someone filled that specific gap!

Have you considered making injecting something manually into dagger? So e.g. in the @Before-annotated setup function you create an instance of a dependency which is then injected "back" into dagger.

What's the aim? That way we can set up a custom mock or something.

Thanks for sharing thoughts!

fabioCollini commented 6 years ago

Hi, I am not sure I understood your request... However DaggerMock collects all the fields (not just the mocks) and the uses them in a module when the type is the same. So you can declare fields in the test and then use them in the module. I am pretty sure I haven't answered to your question :) Can you add an example of what you want to achieve?

marc-neureiter commented 6 years ago

Oh sorry, I haven't read the documentation carefully enough, my fault! What I inquired about is already implemented!