Skip to content

Commit 2f303dd

Browse files
🔧 Add detox config for Android
1 parent 3ea1738 commit 2f303dd

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

InstabugSample/android/app/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ android {
119119
targetSdkVersion rootProject.ext.targetSdkVersion
120120
versionCode 1
121121
versionName "1.0"
122+
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
123+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
122124
}
123125
splits {
124126
abi {
@@ -173,6 +175,11 @@ dependencies {
173175
} else {
174176
implementation 'org.webkit:android-jsc:+'
175177
}
178+
179+
// androidTestImplementation(project(path: ":detox"))
180+
implementation "androidx.annotation:annotation:1.1.0"
181+
androidTestImplementation('com.wix:detox:+') { transitive = true }
182+
androidTestImplementation 'junit:junit:4.12'
176183
}
177184

178185
// Run this once to be able to run the application with BUCK
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.instabugsample;
2+
3+
import com.wix.detox.Detox;
4+
5+
import org.junit.Rule;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
9+
import androidx.test.ext.junit.runners.AndroidJUnit4;
10+
import androidx.test.filters.LargeTest;
11+
import androidx.test.rule.ActivityTestRule;
12+
13+
@RunWith(AndroidJUnit4.class)
14+
@LargeTest
15+
public class DetoxTest {
16+
17+
@Rule
18+
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
19+
20+
@Test
21+
public void runDetoxTests() {
22+
Detox.runTests(mActivityRule);
23+
}
24+
}

InstabugSample/android/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
buildscript {
44
ext {
55
buildToolsVersion = "28.0.3"
6-
minSdkVersion = 16
6+
minSdkVersion = 18
77
compileSdkVersion = 28
88
targetSdkVersion = 28
99
supportLibVersion = "28.0.0"
10+
kotlinVersion = '1.3.10'
1011
}
1112
repositories {
1213
google()
1314
jcenter()
1415
}
1516
dependencies {
1617
classpath("com.android.tools.build:gradle:3.4.1")
18+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1719

1820
// NOTE: Do not place your application dependencies here; they belong
1921
// in the individual module build.gradle files
@@ -31,6 +33,10 @@ allprojects {
3133
// Android JSC is installed from npm
3234
url("$rootDir/../node_modules/jsc-android/dist")
3335
}
36+
maven {
37+
// All of Detox' artifacts are provided via the npm module
38+
url "$rootDir/../node_modules/detox/Detox-android"
39+
}
3440

3541
google()
3642
jcenter()

InstabugSample/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@
4444
"build": "xcodebuild -workspace ios/InstabugSample.xcworkspace -scheme InstabugSample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
4545
"type": "ios.simulator",
4646
"name": "iPhone X"
47+
},
48+
"android.emu.debug": {
49+
"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
50+
"build":
51+
"cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
52+
"type": "android.emulator",
53+
"name": "Pixel_3_API_28"
54+
},
55+
"android.emu.release": {
56+
"binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
57+
"build":
58+
"cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
59+
"type": "android.emulator",
60+
"name": "Pixel_3_API_28"
4761
}
4862
}
4963
}

0 commit comments

Comments
 (0)