草庐IT

MyClassDoingSomething

全部标签

java - 如何模拟未在模块中声明的注入(inject)对象?

对于dagger2模块@ModulepublicclassMyModule{@Provides@SingletonpublicRestServiceprovideRestService(){returnnewRestService();}@Provides@SingletonpublicMyPrinterprovideMyPrinter(){returnnewMyPrinter();}}我们可以将测试模块作为测试publicclassTestModuleextendsMyModule{@OverridepublicMyPrinterprovideMyPrinter(){returnMo