Flipper: fix unit tests

This commit is contained in:
johan12345
2023-05-01 18:28:16 +02:00
parent d04661e925
commit 17c1a11675

View File

@@ -24,6 +24,16 @@ fun addDebugInterceptors(context: Context) {
}
fun OkHttpClient.Builder.addDebugInterceptors(): OkHttpClient.Builder {
this.addNetworkInterceptor(FlipperOkhttpInterceptor(networkFlipperPlugin))
// Flipper does not work during unit tests - so check whether we are running tests first
var isRunningTest = true
try {
Class.forName("org.junit.Test")
} catch (e: ClassNotFoundException) {
isRunningTest = false
}
if (!isRunningTest) {
this.addNetworkInterceptor(FlipperOkhttpInterceptor(networkFlipperPlugin))
}
return this
}