Skip to content

Commit 50fa209

Browse files
authored
Espresso improved logging (#276)
1 parent 9418940 commit 50fa209

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

MPChartExample/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ dependencies {
4343
implementation project(':MPChartLib')
4444

4545
androidTestImplementation "androidx.test.ext:junit-ktx:1.1.5"
46+
androidTestImplementation "com.github.AppDevNext.Logcat:LogcatCoreLib:3.2"
4647
androidTestUtil "androidx.test.services:test-services:1.5.0"
4748
androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
4849
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.5.1'

MPChartExample/src/androidTest/java/com/xxmassdeveloper/mpchartexample/StartTest.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.xxmassdeveloper.mpchartexample
22

3-
import android.util.Log
43
import androidx.test.core.app.takeScreenshot
54
import androidx.test.core.graphics.writeToTestStorage
65
import androidx.test.espresso.Espresso
@@ -17,9 +16,11 @@ import androidx.test.espresso.matcher.ViewMatchers.withText
1716
import androidx.test.espresso.screenshot.captureToBitmap
1817
import androidx.test.ext.junit.rules.activityScenarioRule
1918
import androidx.test.ext.junit.runners.AndroidJUnit4
19+
import androidx.test.platform.app.InstrumentationRegistry
2020
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
2121
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase.Companion.optionMenus
2222
import com.xxmassdeveloper.mpchartexample.notimportant.MainActivity
23+
import info.hannes.timber.DebugFormatTree
2324
import org.hamcrest.CoreMatchers.allOf
2425
import org.hamcrest.CoreMatchers.anything
2526
import org.junit.After
@@ -28,6 +29,7 @@ import org.junit.Rule
2829
import org.junit.Test
2930
import org.junit.rules.TestName
3031
import org.junit.runner.RunWith
32+
import timber.log.Timber
3133

3234

3335
@RunWith(AndroidJUnit4::class)
@@ -42,6 +44,7 @@ class StartTest {
4244
@Before
4345
fun setUp() {
4446
Intents.init()
47+
Timber.plant(DebugFormatTree())
4548
}
4649

4750
@After
@@ -59,7 +62,7 @@ class StartTest {
5962
// iterate samples
6063
MainActivity.menuItems.forEachIndexed { index, contentItem ->
6164
contentItem.clazz?.let {
62-
Log.d(nameRule.methodName, "Intended ${index}-${it.simpleName}")
65+
Timber.d("Intended ${index}-${it.simpleName}")
6366

6467
try {
6568
onData(anything())
@@ -81,7 +84,7 @@ class StartTest {
8184
//Thread.sleep(100)
8285
Espresso.pressBack()
8386
} catch (e: Exception) {
84-
Log.e("smokeTestStart", optionMenu + e.message!!)
87+
Timber.e(optionMenu + e.message!!)
8588
takeScreenshot()
8689
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}-${index}-${it.simpleName}-Error")
8790
}
@@ -91,7 +94,7 @@ class StartTest {
9194

9295
private fun screenshotOfOptionMenu(simpleName: String, menuTitle: String) {
9396
onView(withText(menuTitle)).perform(click())
94-
Log.d(nameRule.methodName, "screenshotOfOptionMenu ${menuTitle}-${simpleName}")
97+
Timber.d("screenshotOfOptionMenu ${menuTitle}-${simpleName}")
9598
takeScreenshot()
9699
.writeToTestStorage("${simpleName}-2menu-click-$menuTitle")
97100
}

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ allprojects {
1616
repositories {
1717
google()
1818
mavenCentral()
19+
maven { url 'https://jitpack.io' }
1920
}
2021
}
2122

0 commit comments

Comments
 (0)