Bladeren bron

fixed robolectric

Daniel Zlotin 8 jaren geleden
bovenliggende
commit
c3827f08f0
3 gewijzigde bestanden met toevoegingen van 36 en 1 verwijderingen
  1. 1
    0
      android/app/build.gradle
  2. 34
    0
      android/prepare-robolectric.gradle
  3. 1
    1
      package.json

+ 1
- 0
android/app/build.gradle Bestand weergeven

@@ -1,4 +1,5 @@
1 1
 apply plugin: 'com.android.library'
2
+apply from: '../prepare-robolectric.gradle'
2 3
 
3 4
 android {
4 5
     compileSdkVersion 23

+ 34
- 0
android/prepare-robolectric.gradle Bestand weergeven

@@ -0,0 +1,34 @@
1
+def robolectricDependenciesFolder = rootProject.buildDir.path + "/robolectric-dependencies"
2
+
3
+configurations.create('robolectricRuntime')
4
+
5
+dependencies {
6
+    robolectricRuntime "org.ccil.cowan.tagsoup:tagsoup:1.2"
7
+    robolectricRuntime "org.robolectric:android-all:6.0.0_r1-robolectric-0"
8
+    robolectricRuntime "org.robolectric:shadows-core-v23:3.1.4"
9
+    robolectricRuntime "org.json:json:20080701"
10
+}
11
+
12
+rootProject.task(type: Copy, overwrite: true, "downloadRobolectricDependencies") {
13
+    println "downloadRobolectricDependencies " + robolectricDependenciesFolder
14
+    from configurations.robolectricRuntime
15
+    into robolectricDependenciesFolder
16
+}
17
+
18
+project.afterEvaluate {
19
+  tasks.all {
20
+      if (it.name.startsWith("test")) {
21
+          it.dependsOn(rootProject.tasks.findByName("downloadRobolectricDependencies"))
22
+      }
23
+  }
24
+}
25
+
26
+android {
27
+    testOptions {
28
+        unitTests.all {
29
+            systemProperty 'robolectric.offline', 'true'
30
+            systemProperty 'robolectric.dependency.dir', robolectricDependenciesFolder
31
+        }
32
+    }
33
+}
34
+

+ 1
- 1
package.json Bestand weergeven

@@ -22,7 +22,7 @@
22 22
     "build": ":",
23 23
     "lint": "eslint src test",
24 24
     "test:js": "jest",
25
-    "test:android": "cd android && ./gradlew clean testDebugUnitTest -Dpre-dex=false",
25
+    "test:android": "cd android && ./gradlew clean testDebugUnitTest -Dpre-dex=true",
26 26
     "test:ios": ":",
27 27
     "pretest": "npm run lint",
28 28
     "test": "npm run test:js && npm run test:android && npm run test:ios",