Android代码-A JUnit rule to easily override Dagger 2 objects

时间:2022-08-25 21:51:30
【文件属性】:

文件名称:Android代码-A JUnit rule to easily override Dagger 2 objects

文件大小:521KB

文件格式:ZIP

更新时间:2022-08-25 21:51:30

Android代码

DaggerMock A JUnit rule to easily override Dagger 2 objects More info about testing using Dagger 2 and Mockito are available in this Medium post. Overriding an object managed by Dagger 2 is not easy, you need to define a TestModule and, if you want to inject your test object, a TestComponent. Using a DaggerMockRule it's possible to override easily (in Java or Kotlin) the objects defined in a Dagger module: Java public class MainServiceTest { @Rule public DaggerMockRule rule = new Dagger


网友评论