<@U7TJY2ZD3> Is <mockK.io> compatible w/ Android E...
# android
d
@oleksiyp Is mockK.io compatible w/ Android Espresso?
o
I haven't tested that, dont know about other users, so have no idea.
n
We are still using mockito, but adding a
TestAppModule
which provides your mocks should work just the same
Copy code
@Module
class TestAppModule(private val application: Application) {

    @Singleton
    @Provides
    fun provideMockNavigationRouter(): NavigationRouter = mock()
...
}
Copy code
val component = DaggerEspressoTestComponent
                .builder()
                .testAppModule(TestAppModule(application))
                .build()

        Application.dependencies = component
d
@neil.armstrong You declare a
public var dependencies
in your Application's
companion object
? So the real dependencies get loaded and then you overwrite them w/ the test deps?
@oleksiyp It would have been nice to have something like https://github.com/fabioCollini/DaggerMock for mockK...
Or is it maybe compatible or easily adaptable to mockK?
n
Yea we have a
EspressoTestComponent
which extends the
ApplicationComponent
so that we can override what gets injected
Copy code
@Singleton
@Component(modules = [TestAppModule::class])
interface EspressoTestComponent : ApplicationComponent {
Copy code
@Singleton
@Component(modules = [AppModule::class])
interface ApplicationComponent {
we also created a custom rule for setting it up
that’s where that component snippet is stolen from 🙂
d
@neil.armstrong Do you have a little gist with a complete setup? I'm still not clear on all the details... 🤔
n
If I get a minute later I’ll strip out any copyrighted stuff and send you it
d
Thanks! 😃
o
Surely I'll check that