I had something similar implemented a few years ago. Indeed not difficult to do.
But I switched to Jukito because it offers a few advanced features: - Interfaces and abstract classes are automatically mocked (as a singleton). In many cases you don’t need to define any binding if you use interfaces for your injected dependencies. - you can have parameters on your test methods and these parameters are automatically injected. This can even work on @Before methods. - Uses annotations to provide the modules to use (that would allow defining your own bindings). Groeten, David On 8 Jun 2018, 09:46 +0200, yu via google-guice <[email protected]>, wrote: > The problem seemed simple enough, so I didn't bother looking for an existing > solution. It took less than a day and two iterations to get everything I > needed into the custom library. Of course, it took a lot longer to make it > look prettier. :) > > On Thursday, June 7, 2018 at 11:34:04 PM UTC-7, David Nouls wrote: > > Never tried Jukito ? works great. > > On 8 Jun 2018, 00:55 +0200, yu via google-guice > > <[email protected]>, wrote: > > > 5 years late to the party. I ended up implementing my own library at my > > > current company: > > > https://eng.collectivehealth.com/introducing-testmodule-bdab286f12db. > > > > > > On Monday, November 4, 2013 at 8:09:29 AM UTC-8, Ari King wrote: > > > > How can I mock injected dependencies in JUnit tests? Thanks. > > > > > > > > > Collective Health introduces the Employer-Driven Healthcare > > > Economy > > > > > > This message may contain confidential, proprietary, or protected > > > information. If you are not the intended recipient, you may not review, > > > copy, or distribute this message. If you received this message in error, > > > please notify the sender by reply email and delete this message. > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "google-guice" group. > > > To unsubscribe from this group and stop receiving emails from it, send an > > > email to [email protected]. > > > To post to this group, send email to [email protected]. > > > Visit this group at https://groups.google.com/group/google-guice. > > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/google-guice/ad0848e7-a545-4214-a4af-b174a5106b2f%40googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > > > Collective Health introduces the Employer-Driven Healthcare Economy > > This message may contain confidential, proprietary, or protected information. > If you are not the intended recipient, you may not review, copy, or > distribute this message. If you received this message in error, please notify > the sender by reply email and delete this message. > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/google-guice. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-guice/e8380991-a1d2-4ec6-b407-533440452d6f%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-guice. To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/9e7c6e19-3ea5-47bb-9e96-02d89648efe9%40Spark. For more options, visit https://groups.google.com/d/optout.
