This question pertains specifically to Flurry, but I'd be curious how to do it for any 3rd party language.
Essentially, Flurry is causing a crash in Robolectric (as per: https://github.com/robolectric/robolectric-gradle-plugin/issues/144) and the only way I can get my unit tests to work is to remove all calls to Flurry (e.g. FlurryAgent.init, FlurryAgent.onStartSession, etc...).
Short of putting all of these under a BuildConfig.Debug 'if' block (which means having a lot of them), is there any way to globally cause all calls to FlurryAgent compile as no-ops in debug mode, for example?
LeakCanary is a good example of the effect I would like to see.
dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
}
We are also using Flurry. So for the rest of application Flurry is hidden by our
Analytics
class and this helps us easy to mock it and verify interaction with it.To test
Analytics
itself we use another technics:And the test:
This is workaround but I don't have better solution for now.