Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detox android setup #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ rootProject.allprojects {
maven {
url 'https://x.klarnacdn.net/mobile-sdk/'
}
maven {
url("$rootDir/../node_modules/detox/Detox-android")
}
}
/*
afterEvaluate { project ->
Expand Down
7 changes: 7 additions & 0 deletions demo-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ android {
targetSdk 34
versionCode 1
versionName "1.0"
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

signingConfigs {
Expand All @@ -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)) {
Expand Down Expand Up @@ -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')
}
30 changes: 30 additions & 0 deletions demo-app/src/androidTest/java/DetoxTest.java
Original file line number Diff line number Diff line change
@@ -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<MainActivity> 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);
}
}
30 changes: 30 additions & 0 deletions demo-app/src/main/java/io/hyperswitch/demoapp/DetoxTest.java
Original file line number Diff line number Diff line change
@@ -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<MainActivity> 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);
}
}