make local test work and separate espresso test draft
authorNevin Chen <cnevinchen@gmail.com>
Tue, 28 Nov 2017 11:47:05 +0800
changeset 708917 4594af36865115ecbfd438530e0434907178a11f
parent 708916 38d52cf57a10381fd81ab482cd9c2d8be141d924
child 708918 2f3c8ee7d4cdcbdd2b1039669ac3e4313dd1fb3b
push id92480
push userbmo:cnevinchen@gmail.com
push dateThu, 07 Dec 2017 09:53:01 +0000
milestone59.0a1
make local test work and separate espresso test MozReview-Commit-ID: Idi2xUb18kj
mobile/android/app/build.gradle
mobile/android/app/src/androidTest/java/org/mozilla/gecko/EspressoBrowserAppTest.java
mobile/android/app/src/androidTest/java/org/mozilla/gecko/EspressoOnly.java
mobile/android/app/src/androidTest/java/org/mozilla/gecko/TestEnvOnly.java
testing/config/tooltool-manifests/linux64/hostutils.manifest
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -20,17 +20,17 @@ android {
 
         applicationId mozconfig.substs.ANDROID_PACKAGE_NAME
         testApplicationId 'org.mozilla.roboexample.test'
         testInstrumentationRunner 'org.mozilla.gecko.FennecInstrumentationTestRunner'
         // Used by Robolectric based tests; see TestRunner.
         buildConfigField 'String', 'BUILD_DIR', "\"${project.buildDir}\""
 
         vectorDrawables.useSupportLibrary = true
-        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
+
     }
 
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_7
         targetCompatibility JavaVersion.VERSION_1_7
     }
 
     dexOptions {
@@ -77,16 +77,22 @@ android {
     //
     // The "skin" flavor dimension distinguishes between different user interfaces.  We sometimes
     // want to develop significant new user interface pieces in-tree that don't ship (even in the
     // Nightly channel) while under development.  A new "skin" flavour allows us to develop such
     // pieces in Gradle without changing the mainline configuration.
     flavorDimensions "audience", "skin"
 
     productFlavors {
+        espresso{
+            dimension "audience"
+
+            testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
+            testInstrumentationRunnerArgument 'annotation', 'org.mozilla.gecko.EspressoOnly'
+        }
         // For API 21+ - with pre-dexing, this will be faster for local development.
         local {
             dimension "audience"
 
             // For pre-dexing, setting `minSdkVersion 21` allows the Android gradle plugin to
             // pre-DEX each module and produce an APK that can be tested on
             // Android Lollipop without time consuming DEX merging processes.
             minSdkVersion 21
@@ -264,16 +270,18 @@ dependencies {
     // Include LeakCanary in most gradle based builds. LeakCanary adds about 5k methods, so we disable
     // it for the (non-proguarded, non-predex) localOld builds to allow space for other libraries.
     // Gradle based tests include the no-op version.  Mach based builds only include the no-op version
     // of this library.
     // It doesn't seem like there is a non-trivial way to be conditional on 'localOld', so instead we explicitly
     // define a version of leakcanary for every flavor:
     localCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
     localOldCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
+    espressoCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
+
     officialCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
     officialCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
     testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
 
     androidTestCompile ('com.android.support.test.espresso:espresso-core:3.0.1'){
         exclude module: 'support-annotations'
         exclude module: 'support-v4'
         exclude module: 'support-v13'
--- a/mobile/android/app/src/androidTest/java/org/mozilla/gecko/EspressoBrowserAppTest.java
+++ b/mobile/android/app/src/androidTest/java/org/mozilla/gecko/EspressoBrowserAppTest.java
@@ -2,17 +2,17 @@ package org.mozilla.gecko;
 
 import android.support.test.rule.ActivityTestRule;
 import android.support.test.runner.AndroidJUnit4;
 
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-@TestEnvOnly
+@EspressoOnly
 @RunWith(AndroidJUnit4.class)
 public class EspressoBrowserAppTest {
 
     @Rule
     public ActivityTestRule<BrowserApp> mActivityRule =
             new ActivityTestRule(BrowserApp.class);
 
     @Test
new file mode 100644
--- /dev/null
+++ b/mobile/android/app/src/androidTest/java/org/mozilla/gecko/EspressoOnly.java
@@ -0,0 +1,14 @@
+package org.mozilla.gecko;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+// https://medium.com/@satyajit/running-subset-of-espresso-tests-locally-and-gcloud-4713931da56
+//Needed to have annotations at a test level
+@Target({ ElementType.METHOD, ElementType.TYPE })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface EspressoOnly {
+}
\ No newline at end of file
deleted file mode 100644
--- a/mobile/android/app/src/androidTest/java/org/mozilla/gecko/TestEnvOnly.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.mozilla.gecko;
-
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-// https://medium.com/@satyajit/running-subset-of-espresso-tests-locally-and-gcloud-4713931da56
-//Needed to have annotations at a test level
-@Target({ ElementType.METHOD, ElementType.TYPE })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface TestEnvOnly {
-}
\ No newline at end of file
--- a/testing/config/tooltool-manifests/linux64/hostutils.manifest
+++ b/testing/config/tooltool-manifests/linux64/hostutils.manifest
@@ -1,10 +1,10 @@
 [
   {
-    "size": 72528696,
+    "size": 72112596,
     "visibility": "public",
-    "digest": "6a0ed81e1aa43ad9bb3ebbb32d259fbcb15d7f5bd0bac47471cb41fb29fe74c6ff8ab4559cecd9d4f15c68cf5ad2ed4a8e924e4f89638cb4e2edaa06b65e5527",
+    "digest": "4d3fe61dd8ad9ca09c72e677e8d2d5b7409988de32d6feb9fc55cb0a320a4835b6e2f384a68d2409e89e7a0d2f622bf3ceb9b707e01ad8afe1270ad0d1c9973c",
     "algorithm": "sha512",
-    "filename": "host-utils-58.0a1.en-US-linux-x86_64.tar.gz",
+    "filename": "host-utils-58.0a1.en-US.mac.tar.gz,
     "unpack": true
   }
 ]