I was struggling with fixing the dryRun Test after...
# koin
r
I was struggling with fixing the dryRun Test after I had upgraded my koin to 2.x. As there was some problem with context, and koin was not able to create context dependent dependencies. I mocked all the relevant ones and got it working. Now, I run into a problem, when koin tries to create
retrofit
when i do
checkModules
it throws up
Method getMainLooper in android.os.Looper not mocked.
As my retrofit builder by default created with
.io scheduler
, i tried adding trampoline, or removing it. Or custom rules for it to do it on the current thread. But no luck. Wondering, if any one else had faced the same.
o
have you tried adding
Copy code
android {
  testOptions {
    unitTests.returnDefaultValues = true
  }
}
?
r
Yup. It works. I would avoid adding it, as it does solves the problem here as it returns default. It also leads to unkown bugs in unit tests. The return values can introduce regressions in the tests, which are hard to debug and might allow failing tests to pass. I would only use it as a last resort. I believe there should be a better problem to this. @oleg_osipenko
I found the solution, the retrofit default executor, if not provided is
MainThreadExecutor
. I provided
currentThreadExecutor
and it worked.