add Detox integrations to Android RNTester app

Summary:
This diff adds required Detox integrations to the RNTester app to be able to run Detox end-to-end tests on the Android version of the app.

* Instructions at https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md were followed.
* The `minSdkVersion` version for the app was bumped to 18, as required by Detox.
* I also added build and test configurations in `package.json`
*  The debug app is able to run some of the existing tests, but the release app instacrashes. I do not know the reason for the instacrash at this time.
* CI integrations to build and test the Android app will be added in future diffs

Changelog:
[Internal] add Detox integrations to the RNTester Android app

Reviewed By: TheSavior

Differential Revision: D19566834

fbshipit-source-id: 5dd506bbdbb426a5db18146e5dc7c450a27b1d0c
This commit is contained in:
Chad Smith
2020-02-11 10:09:18 -08:00
committed by Facebook Github Bot
parent 6ba2aeefa8
commit 29d3dfbd19
5 changed files with 69 additions and 2 deletions
+9 -1
View File
@@ -120,10 +120,12 @@ android {
defaultConfig {
applicationId "com.facebook.react.uiapp"
minSdkVersion 16
minSdkVersion 18
targetSdkVersion 29
versionCode 1
versionName "1.0"
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
signingConfigs {
release {
@@ -149,6 +151,8 @@ android {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
// Detox-specific additions to pro-guard
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
}
}
}
@@ -187,4 +191,8 @@ dependencies {
} else {
jscImplementation 'org.webkit:android-jsc:+'
}
// Use detox test library
androidTestImplementation('com.wix:detox:+') { transitive = true }
androidTestImplementation 'junit:junit:4.12'
}
@@ -0,0 +1,33 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This uses instructions from
// https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#4-create-android-test-class
package com.facebook.react.uiapp;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
import com.wix.detox.Detox;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class DetoxTest {
@Rule
public ActivityTestRule<RNTesterActivity> mActivityRule =
new ActivityTestRule<>(RNTesterActivity.class, false, false);
@Test
public void runDetoxTests() {
Detox.runTests(mActivityRule);
}
}
+5
View File
@@ -25,6 +25,11 @@ allprojects {
maven {
url = uri("$rootDir/node_modules/jsc-android/dist")
}
maven {
// https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md
// All of Detox's artifacts are provided via the npm module
url = uri("$rootDir/node_modules/detox/Detox-android")
}
mavenLocal()
google()
jcenter()
+19
View File
@@ -159,6 +159,25 @@
"runner-config": "RNTester/e2e/config.json",
"specs": "",
"configurations": {
"android.emu.release": {
"binaryPath": "RNTester/android/app/build/outputs/apk/hermes/release/app-hermes-x86-release.apk",
"testBinaryPath": "RNTester/android/app/build/outputs/apk/androidTest/hermes/release/app-hermes-release-androidTest.apk",
"build":
"./gradlew RNTester:android:app:assembleRelease RNTester:android:app:assembleAndroidTest -DtestBuildType=release",
"type": "android.emulator",
"device": {
"avdName": "Nexus_6_API_29"
}
},
"android.emu.debug": {
"binaryPath": "RNTester/android/app/build/outputs/apk/hermes/debug/app-hermes-x86-debug.apk",
"testBinaryPath": "RNTester/android/app/build/outputs/apk/androidTest/hermes/debug/app-hermes-debug-androidTest.apk",
"build": "./gradlew RNTester:android:app:assembleDebug RNTester:android:app:assembleAndroidTest -DtestBuildType=debug",
"type": "android.emulator",
"device": {
"avdName": "Nexus_6_API_29"
}
},
"ios.sim.release": {
"binaryPath": "RNTester/build/Build/Products/Release-iphonesimulator/RNTester.app/",
"build": "xcodebuild -workspace RNTester/RNTesterPods.xcworkspace -scheme RNTester -configuration Release -sdk iphonesimulator -derivedDataPath RNTester/build -UseModernBuildSystem=NO -quiet",
+3 -1
View File
@@ -11,9 +11,11 @@ buildscript {
google()
jcenter()
}
ext.kotlinVersion = '1.3.0'
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// for Detox
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}