From d9bfe4850f4ef3de7684278d4912057801062e3f Mon Sep 17 00:00:00 2001 From: Sanskar Atrey Date: Fri, 6 Dec 2024 17:20:08 +0530 Subject: [PATCH] detox android setup --- build.gradle | 3 ++ demo-app/build.gradle | 7 +++++ demo-app/src/androidTest/java/DetoxTest.java | 30 +++++++++++++++++++ .../io/hyperswitch/demoapp/DetoxTest.java | 30 +++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 demo-app/src/androidTest/java/DetoxTest.java create mode 100644 demo-app/src/main/java/io/hyperswitch/demoapp/DetoxTest.java diff --git a/build.gradle b/build.gradle index dd87e02..24a56bc 100644 --- a/build.gradle +++ b/build.gradle @@ -46,6 +46,9 @@ rootProject.allprojects { maven { url 'https://x.klarnacdn.net/mobile-sdk/' } + maven { + url("$rootDir/../node_modules/detox/Detox-android") + } } /* afterEvaluate { project -> diff --git a/demo-app/build.gradle b/demo-app/build.gradle index ff0f0d6..2e6f7d5 100644 --- a/demo-app/build.gradle +++ b/demo-app/build.gradle @@ -14,6 +14,8 @@ android { targetSdk 34 versionCode 1 versionName "1.0" + testBuildType System.getProperty('testBuildType', 'debug') + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } signingConfigs { @@ -38,6 +40,8 @@ android { renderscriptDebuggable false pseudoLocalesEnabled false zipAlignEnabled true + proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro" + } buildTypes.all { buildType -> if (!['debug', 'release'].contains(buildType.name)) { @@ -89,5 +93,8 @@ dependencies { implementation 'com.github.kittinunf.fuel:fuel:2.3.1' implementation 'com.github.kittinunf.fuel:fuel-json:2.3.1' implementation project(':app') + implementation 'com.wix:detox:20.28.0' + androidTestImplementation('com.wix:detox:+') + implementation 'androidx.appcompat:appcompat:1.1.0' implementation project(':hyperswitch-sdk-android-lite') } \ No newline at end of file diff --git a/demo-app/src/androidTest/java/DetoxTest.java b/demo-app/src/androidTest/java/DetoxTest.java new file mode 100644 index 0000000..40e8a91 --- /dev/null +++ b/demo-app/src/androidTest/java/DetoxTest.java @@ -0,0 +1,30 @@ +import com.wix.detox.Detox; +import com.wix.detox.config.DetoxConfig; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; + +import io.hyperswitch.BuildConfig; +import io.hyperswitch.demoapp.MainActivity; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class DetoxTest { + @Rule // (2) + public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); + + @Test + public void runDetoxTests() { + DetoxConfig detoxConfig = new DetoxConfig(); + detoxConfig.idlePolicyConfig.masterTimeoutSec = 90; + detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60; + detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60); + + Detox.runTests(mActivityRule, detoxConfig); + } +} \ No newline at end of file diff --git a/demo-app/src/main/java/io/hyperswitch/demoapp/DetoxTest.java b/demo-app/src/main/java/io/hyperswitch/demoapp/DetoxTest.java new file mode 100644 index 0000000..c716ab0 --- /dev/null +++ b/demo-app/src/main/java/io/hyperswitch/demoapp/DetoxTest.java @@ -0,0 +1,30 @@ +package io.hyperswitch.demoapp; +import com.wix.detox.Detox; +import com.wix.detox.config.DetoxConfig; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; + +import io.hyperswitch.BuildConfig; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class DetoxTest { + @Rule // (2) + public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); + + @Test + public void runDetoxTests() { + DetoxConfig detoxConfig = new DetoxConfig(); + detoxConfig.idlePolicyConfig.masterTimeoutSec = 90; + detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60; + detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60); + + Detox.runTests(mActivityRule, detoxConfig); + } +} \ No newline at end of file