DaggerMock
DaggerMock copied to clipboard
A JUnit rule to easily override Dagger 2 objects
Is it possible to mock dependencies in both the parent component and child component in an espresso test? Child components are being created using the builder.
Hi I followed the example on to create a custom DaggerMock Rule and I am getting error I/TestRunner: java.lang.RuntimeException: Error invoking setter with parameter class com.visa.cardcontrols.di.AppModule on object com.visa.cardcontrols.di.DaggerAppComponent$Builder@ba12a92 at...
Hi i am getting the following error following your example error: @Component.Builder has setters for modules or components that aren't required: this happens when i add the following line to...
I have tried implementing everything exactly as the sample project - not sure what I am missing, or maybe I am just not understanding how Mockito works... I am injecting...
Let's say I have an AppComponent, which has a subcomponent UserComponent, which in turn has a ProfileComponent, each with sub/modules: ``` @AppScope @Component(modules={AppModule.class, NetworkModule.class}) interface AppComponent { UserComponent userComponent(...); }...
When I use AndroidInjection the mock doesn't t work Example ``` /* FooActivity */ override fun onCreate(savedInstanceState: Bundle?) { AndroidInjection.inject(this) super.onCreate(savedInstanceState) setContentView(R.layout.activity_register) } ``` When I inject by AppComponent the...
Hi Fabio, Here is my Component and Dependent Component **Main Component** @AppScope @Component(modules = {AndroidInjectionModule.class, ActivityModule.class}, dependencies = RepositoryComponent.class) public interface ApplicationComponent { void inject(Application application); } **Dependent Component** @Singleton...
Hi Fabio! I'm trying to do something like this: ``` class MyTest { @Rule [...DaggerMockRule with MyComponent...] @InjectFromComponent @Dog Animal a1; @InjectFromComponent @Cat Animal a2; fun `test inject from component...
Hello, I'm trying to test my login and I have some problems. The repo that I use to login has a function with username and password params. In my test...
In my activity I have a module that depends on the activity itself. How would I mock this with DaggerMock? I have tried instantiating it in the test like I...