From c9f054bd47446344c63bb18fef6a9b96a0644e38 Mon Sep 17 00:00:00 2001 From: triplem <160079+triplem@users.noreply.github.com> Date: Thu, 1 Aug 2019 21:20:17 +0200 Subject: [PATCH] disable firebase for tests --- .travis.yml | 2 +- app/build.gradle | 3 +++ app/src/main/java/info/nightscout/androidaps/MainApp.java | 1 + app/src/test/java/info/AAPSMocker.java | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e32e1822ce..165a1eff9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_install: script: # Unit Test - - ./gradlew -Pcoverage testFullDebugUnitTest jacocoTestFullDebugUnitTestReport + - ./gradlew -Pcoverage -PfirebaseDisable testFullDebugUnitTest jacocoTestFullDebugUnitTestReport after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/app/build.gradle b/app/build.gradle index 3335387f40..c2121708da 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -145,6 +145,9 @@ android { debug { testCoverageEnabled(project.hasProperty('coverage')) } + firebaseDisable { + System.setProperty("disableFirebase", "true") + } } productFlavors { flavorDimensions "standard" diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index dd51afbec5..f539f2e33f 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -148,6 +148,7 @@ public class MainApp extends Application { } mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); + mFirebaseAnalytics.setAnalyticsCollectionEnabled(!Boolean.getBoolean("disableFirebase")); JodaTimeAndroid.init(this); diff --git a/app/src/test/java/info/AAPSMocker.java b/app/src/test/java/info/AAPSMocker.java index 1ca2566eb8..465fc9251d 100644 --- a/app/src/test/java/info/AAPSMocker.java +++ b/app/src/test/java/info/AAPSMocker.java @@ -159,6 +159,7 @@ public class AAPSMocker { } public static MainApp mockMainApp() { + System.setProperty("disableFirebase", "true"); PowerMockito.mockStatic(MainApp.class); MainApp mainApp = mock(MainApp.class); when(MainApp.instance()).thenReturn(mainApp);