Skip to content

Commit f361763

Browse files
committed
Add UI test for SentryModifier
1 parent 3d07aed commit f361763

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

buildSrc/src/main/java/Config.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ object Config {
201201
val javaFaker = "com.github.javafaker:javafaker:1.0.2"
202202
val msgpack = "org.msgpack:msgpack-core:0.9.8"
203203
val leakCanaryInstrumentation = "com.squareup.leakcanary:leakcanary-android-instrumentation:2.14"
204+
val composeUiTestJunit4 = "androidx.compose.ui:ui-test-junit4:$composeVersion"
205+
val composeUiTestManifest = "androidx.compose.ui:ui-test-manifest:$composeVersion"
204206
}
205207

206208
object QualityPlugins {

sentry-android-integration-tests/sentry-uitest-android/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ dependencies {
112112
implementation(Config.TestLibs.espressoIdlingResource)
113113
implementation(Config.Libs.leakCanary)
114114

115+
androidTestImplementation(Config.TestLibs.composeUiTestJunit4)
116+
debugImplementation(Config.TestLibs.composeUiTestManifest)
117+
115118
compileOnly(Config.CompileOnly.nopen)
116119
errorprone(Config.CompileOnly.nopenChecker)
117120
errorprone(Config.CompileOnly.errorprone)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.sentry.uitest.android
2+
3+
import androidx.compose.foundation.layout.Box
4+
import androidx.compose.ui.Modifier
5+
import androidx.compose.ui.test.SemanticsMatcher
6+
import androidx.compose.ui.test.junit4.createComposeRule
7+
import androidx.test.ext.junit.runners.AndroidJUnit4
8+
import io.sentry.compose.SentryModifier
9+
import io.sentry.compose.SentryModifier.sentryTag
10+
import org.junit.Rule
11+
import org.junit.Test
12+
import org.junit.runner.RunWith
13+
14+
@RunWith(AndroidJUnit4::class)
15+
class SentryModifierComposeTest : BaseUiTest() {
16+
17+
companion object {
18+
private const val TAG_VALUE = "ExampleTagValue"
19+
}
20+
21+
@get:Rule
22+
val rule = createComposeRule()
23+
24+
@Test
25+
fun sentryModifierAppliesTag() {
26+
rule.setContent {
27+
Box(modifier = Modifier.sentryTag(TAG_VALUE))
28+
}
29+
rule.onNode(
30+
SemanticsMatcher(TAG_VALUE) {
31+
it.config.find { (key, _) -> key.name == SentryModifier.TAG }?.value == TAG_VALUE
32+
}
33+
).assertExists()
34+
}
35+
}

0 commit comments

Comments
 (0)