File tree Expand file tree Collapse file tree
src/androidTest/java/com/infeez/androidmoduleexample Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ FROM agoda/docker-emulator-android-28
2+
3+ ENV MARATHON_VER "0.5.1"
4+ ENV PATH="${PATH}:/opt/marathon-${MARATHON_VER}/bin"
5+
6+ RUN apt-get update && \
7+ yes | apt-get install unzip && \
8+ yes | apt-get install openjdk-8-jdk && \
9+ apt-get -yq autoremove && \
10+ apt-get clean && \
11+ apt-get autoclean && \
12+ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
13+
14+ RUN mkdir -p /opt/marathon && \
15+ curl -sL "https://github.com/Malinskiy/marathon/releases/download/${MARATHON_VER}/marathon-${MARATHON_VER}.zip" -o /opt/marathon.zip && \
16+ unzip /opt/marathon.zip -d /opt && \
17+ rm /opt/marathon.zip
18+
19+ COPY entrypoint.sh /opt/entrypoint.sh
20+
21+ RUN mkdir -p /opt/test/apks && \
22+ chmod +x /opt/entrypoint.sh
23+
24+ COPY Marathonfile.yml /Marathonfile
25+ COPY app/build/outputs/apk/debug/app-debug.apk /opt/test/apk/app-debug.apk
26+ COPY app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk /opt/test/apk/app-debug-androidTest.apk
27+
28+ ENTRYPOINT ["/opt/entrypoint.sh" ]
Original file line number Diff line number Diff line change 1+ name : " sample-app tests"
2+ outputDir : " build/reports/marathon"
3+ retryStrategy :
4+ type : " fixed-quota"
5+ totalAllowedRetryQuota : 100
6+ retryPerTestQuota : 2
7+ vendorConfiguration :
8+ type : " Android"
9+ applicationApk : " /opt/test/apk/app-debug.apk"
10+ testApplicationApk : " /opt/test/apk/app-debug-androidTest.apk"
11+ autoGrantPermission : true
12+ instrumentationArgs :
13+ debug : " true"
14+ applicationPmClear : true
15+ testApplicationPmClear : true
Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ dependencies {
3333 implementation ' androidx.core:core-ktx:1.0.2'
3434 implementation ' androidx.constraintlayout:constraintlayout:1.1.3'
3535 testImplementation ' junit:junit:4.12'
36+ androidTestImplementation ' com.agoda.kakao:kakao:2.1.0'
37+ androidTestImplementation ' androidx.test:rules:1.2.0'
38+ androidTestImplementation ' androidx.test.ext:junit:1.1.1'
39+ androidTestImplementation ' androidx.test:core:1.2.0'
3640 androidTestImplementation ' androidx.test:runner:1.2.0'
3741 androidTestImplementation ' androidx.test.espresso:espresso-core:3.2.0'
3842
Original file line number Diff line number Diff line change 11package com.infeez.androidmoduleexample
22
3- import androidx.test.InstrumentationRegistry
4- import androidx.test.runner.AndroidJUnit4
3+
4+ import androidx.test.ext.junit.runners.AndroidJUnit4
5+ import androidx.test.platform.app.InstrumentationRegistry
56import org.junit.Assert.assertEquals
67import org.junit.Test
78import org.junit.runner.RunWith
@@ -16,7 +17,7 @@ class ExampleInstrumentedTest {
1617 @Test
1718 fun useAppContext () {
1819 // Context of the app under test.
19- val appContext = InstrumentationRegistry .getTargetContext()
20+ val appContext = InstrumentationRegistry .getInstrumentation().targetContext
2021 assertEquals(" com.infeez.androidmoduleexample" , appContext.packageName)
2122 }
2223}
Original file line number Diff line number Diff line change 1+ package com.infeez.androidmoduleexample
2+
3+ import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
4+ import androidx.test.rule.ActivityTestRule
5+ import com.agoda.kakao.screen.Screen
6+ import com.agoda.kakao.screen.Screen.Companion.onScreen
7+ import com.agoda.kakao.text.KButton
8+ import org.junit.Rule
9+ import org.junit.Test
10+ import org.junit.runner.RunWith
11+
12+ @RunWith(AndroidJUnit4ClassRunner ::class )
13+ class FeatureTest {
14+
15+ @Rule
16+ @JvmField
17+ val rule = ActivityTestRule (MainActivity ::class .java)
18+
19+ @Test
20+ fun firstFeatureTest () {
21+ onScreen<FeaturesScreen > {
22+ button1 {
23+ click()
24+ }
25+ }
26+ }
27+
28+ }
29+
30+ class FeaturesScreen : Screen <FeaturesScreen >() {
31+
32+ val button1 = KButton { withId(R .id.b_first_feature) }
33+ val button2 = KButton { withId(R .id.b_second_feature) }
34+ val button3 = KButton { withId(R .id.b_third_feature) }
35+
36+ }
Original file line number Diff line number Diff line change 11// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
33buildscript {
4- ext. kotlin_version = ' 1.3.31 '
4+ ext. kotlin_version = ' 1.3.41 '
55 repositories {
66 google()
77 jcenter()
88
99 }
1010 dependencies {
11- classpath ' com.android.tools.build:gradle:3.4.1 '
11+ classpath ' com.android.tools.build:gradle:3.4.2 '
1212 classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version "
1313 // NOTE: Do not place your application dependencies here; they belong
1414 // in the individual module build.gradle files
@@ -19,7 +19,6 @@ allprojects {
1919 repositories {
2020 google()
2121 jcenter()
22-
2322 }
2423}
2524
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -e
3+
4+ adb connect 172.17.0.2:5555
5+
6+ sleep 5
7+
8+ echo " Connected to "
9+
10+ # adb push /opt/app-debug.apk /data/local/tmp/com.infeez.androidmoduleexample
11+ # adb shell pm install -t -r "/data/local/tmp/com.infeez.androidmoduleexample"
12+
13+ # adb push /opt/app-debug-androidTest.apk /data/local/tmp/com.infeez.androidmoduleexample.test
14+ # adb shell pm install -t -r "/data/local/tmp/com.infeez.androidmoduleexample.test"
15+
16+ # echo "Test started"
17+
18+ # adb shell am instrument -w -r -e debug false -e class 'com.infeez.androidmoduleexample.ExampleInstrumentedTest' com.infeez.androidmoduleexample.test/androidx.test.runner.AndroidJUnitRunner
19+
20+ echo " Marathon started"
21+
22+ ls -lah /opt
23+
24+ marathon --marathonfile Marathonfile
25+ # --android-sdk "${ANDROID_SDK}"
You can’t perform that action at this time.
0 commit comments