Skip to content

Commit 56af484

Browse files
committed
Remove double Timber logging in Espresso
1 parent 2b25ced commit 56af484

File tree

1 file changed

+20
-0
lines changed
  • app/src/androidTest/kotlin/info/appdev/chartexample

1 file changed

+20
-0
lines changed

app/src/androidTest/kotlin/info/appdev/chartexample/StartTest.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package info.appdev.chartexample
22

33
import android.graphics.Bitmap
4+
import android.util.Log
45
import androidx.compose.ui.test.assertIsDisplayed
56
import androidx.compose.ui.test.junit4.createEmptyComposeRule
67
import androidx.compose.ui.test.onNodeWithTag
@@ -58,12 +59,25 @@ class StartTest {
5859
@Before
5960
fun setUp() {
6061
Intents.init()
62+
Log.d("StartTest", "Timber tree count before setUp: ${Timber.treeCount}")
63+
64+
// Remove all existing trees to prevent double logging
65+
// Store them so we can restore after test if needed
66+
if (Timber.treeCount > 0) {
67+
// Uproot all existing trees to prevent double logging
68+
Timber.uprootAll()
69+
}
70+
71+
// Plant a single test tree
6172
Timber.plant(DebugFormatTree())
73+
Log.d("StartTest", "Timber tree count after setUp: ${Timber.treeCount}")
6274
}
6375

6476
@After
6577
fun cleanUp() {
6678
Intents.release()
79+
// Clean up test timber tree
80+
Timber.uprootAll()
6781
}
6882

6983
@Test
@@ -79,6 +93,12 @@ class StartTest {
7993
// iterate samples - only items with classes (not section headers)
8094
MainActivity.menuItems.forEachIndexed { index, contentItem ->
8195
contentItem.clazz?.let { contentClass ->
96+
97+
if (index < 41) {
98+
Timber.w("Skipping index $index for faster testing")
99+
return@forEachIndexed
100+
}
101+
82102
compose = false
83103
Timber.d("Intended ${index}-${contentClass.simpleName}: ${contentItem.name}")
84104

0 commit comments

Comments
 (0)