Skip to content

Commit 4d283d3

Browse files
authored
Merge pull request #339 from wordpress-mobile/add/espresso-uitest-setup
Initial Setup for Espresso UI Tests
2 parents 963b428 + 821d26d commit 4d283d3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ android {
1111
targetSdkVersion 25
1212
versionCode 1
1313
versionName "1.0"
14+
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
1415
}
1516

1617
buildTypes {
@@ -38,4 +39,7 @@ dependencies {
3839
compile "com.android.support:appcompat-v7:25.3.1"
3940
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
4041
compile "org.wordpress:utils:1.14.0"
42+
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
43+
exclude group: 'com.android.support', module: 'support-annotations'
44+
}
4145
}

app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ class MainActivity : AppCompatActivity(),
119119
UNKNOWN +
120120
EMOJI +
121121
LONG_TEXT
122+
123+
private val isRunningTest : Boolean by lazy {
124+
try {
125+
Class.forName("android.support.test.espresso.Espresso")
126+
true
127+
} catch (e: ClassNotFoundException) {
128+
false
129+
}
130+
}
122131
}
123132

124133
private val MEDIA_CAMERA_PHOTO_PERMISSION_REQUEST_CODE: Int = 1001
@@ -256,7 +265,9 @@ class MainActivity : AppCompatActivity(),
256265
aztec.setToolbar(formattingToolbar)
257266

258267
// initialize the text & HTML
259-
source.displayStyledAndFormattedHtml(EXAMPLE)
268+
if (!isRunningTest) {
269+
source.displayStyledAndFormattedHtml(EXAMPLE)
270+
}
260271

261272
if (savedInstanceState == null) {
262273
aztec.fromHtml(source.getPureHtml())

0 commit comments

Comments
 (0)