Skip to content

Commit f6a9918

Browse files
authored
Merge pull request #72 from AppDevNext/EspressoTests
Espresso tests
2 parents 842e50a + 0a0364a commit f6a9918

File tree

4 files changed

+63
-25
lines changed

4 files changed

+63
-25
lines changed

.github/workflows/Android-CI.yml

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,29 @@ jobs:
2929
run: ./gradlew assembleDebug
3030
- name: Run tests
3131
run: ./gradlew test
32-
# - name: Run instrumentation tests
33-
# uses: malinskiy/action-android/emulator-run-cmd@release/0.1.4
34-
# with:
35-
# cmd: ./gradlew :app:cAT
36-
# api: 28
37-
# tag: default
38-
# abi: x86
39-
# cmdOptions: -noaudio -no-boot-anim -no-window
40-
# - name: Archive Espresso results
41-
# uses: actions/upload-artifact@v3.1.1
42-
# if: ${{ always() }}
43-
# with:
44-
# name: Chart-Espresso-report
45-
# path: app/build/reports/androidTests/connected
46-
# - name: Save logcat output
47-
# uses: actions/upload-artifact@v3.1.1
48-
# if: failure()
49-
# with:
50-
# name: Chart-logcat
51-
# path: artifacts/logcat.log
52-
# - name: Archive screenshots
53-
# uses: actions/upload-artifact@v3.1.1
54-
# with:
55-
# name: Chart-Screenshots
56-
# path: screenshots/adb
32+
- name: Run instrumentation tests
33+
uses: malinskiy/action-android/emulator-run-cmd@release/0.1.4
34+
with:
35+
cmd: ./gradlew cAT --continue
36+
api: 28
37+
tag: default
38+
abi: x86_64
39+
cmdOptions: -noaudio -no-boot-anim -no-window
40+
- name: Archive Espresso results
41+
uses: actions/upload-artifact@v3
42+
if: ${{ always() }}
43+
with:
44+
name: MPChart-Espresso-report
45+
path: MPChartExample/build/reports/androidTests/connected
46+
if-no-files-found: error
47+
- name: Archive screenshots
48+
if: ${{ always() }}
49+
uses: actions/upload-artifact@v3
50+
with:
51+
name: MPChart-Screenshots
52+
path: |
53+
MPChartExample/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected
54+
MPChartExample/build/outputs/androidTest-results/connected
5755
Check:
5856
name: Check
5957
runs-on: ubuntu-latest

MPChartExample/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'com.android.application'
3+
id 'kotlin-android'
34
}
45

56
android {
@@ -11,6 +12,7 @@ android {
1112
versionCode 57
1213
versionName '3.1.0'
1314
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15+
testInstrumentationRunnerArguments useTestStorageService: 'true'
1416
}
1517

1618
buildTypes {
@@ -26,4 +28,9 @@ dependencies {
2628
implementation "androidx.appcompat:appcompat:1.5.1"
2729
implementation 'com.google.android.material:material:1.7.0'
2830
implementation project(':MPChartLib')
31+
32+
androidTestImplementation "androidx.test.ext:junit-ktx:1.1.4"
33+
androidTestUtil "androidx.test.services:test-services:1.4.2"
34+
androidTestImplementation "androidx.test.espresso:espresso-core:3.5.0"
2935
}
36+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.xxmassdeveloper.mpchartexample
2+
3+
import androidx.test.core.graphics.writeToTestStorage
4+
import androidx.test.espresso.Espresso
5+
import androidx.test.espresso.matcher.ViewMatchers
6+
import androidx.test.espresso.screenshot.captureToBitmap
7+
import androidx.test.ext.junit.rules.activityScenarioRule
8+
import androidx.test.ext.junit.runners.AndroidJUnit4
9+
import com.xxmassdeveloper.mpchartexample.notimportant.MainActivity
10+
import org.junit.Rule
11+
import org.junit.Test
12+
import org.junit.rules.TestName
13+
import org.junit.runner.RunWith
14+
15+
@RunWith(AndroidJUnit4::class)
16+
class StartTest {
17+
18+
@get:Rule
19+
val activityScenarioRule = activityScenarioRule<MainActivity>()
20+
21+
@get:Rule
22+
var nameRule = TestName()
23+
24+
@Test
25+
fun smokeTestSimplyStart() {
26+
Espresso.onView(ViewMatchers.isRoot())
27+
.captureToBitmap()
28+
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}")
29+
}
30+
}

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
buildscript {
2+
ext.kotlin_version = '1.7.22'
3+
24
repositories {
35
google()
46
mavenCentral()
57
}
68
dependencies {
79
classpath 'com.android.tools.build:gradle:7.3.1'
810
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
11+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
912
}
1013
}
1114

0 commit comments

Comments
 (0)