Skip to content

Commit 4991f22

Browse files
fix: Android span e2e tests (#397)
## Summary Fixes and removes ignore on span e2e tests. Flag Eval on the launch was intervening with tests <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: changes are limited to the Android E2E test harness and test annotations, with no impact on production SDK logic beyond skipping a test-only span trigger during tests. > > **Overview** > Fixes flaky Android span E2E tests by preventing `BaseApplication` from running `flagEvaluation()` during test runs (gated on `testUrl == null`), avoiding extra spans that interfered with assertions. > > Re-enables previously ignored span-related E2E coverage by removing `@Ignore` from several trace/export and sampling tests in `DisablingConfigOptionsE2ETest` and `SamplingE2ETest`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 618e2b1. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 43d2dc3 commit 4991f22

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

e2e/android/app/src/main/java/com/example/androidobservability/BaseApplication.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ open class BaseApplication : Application() {
9191
LDClient.init(this@BaseApplication, ldConfig, context)
9292
telemetryInspector = observabilityPlugin.getTelemetryInspector()
9393

94-
flagEvaluation()
94+
if (testUrl == null) {
95+
// intervenes in E2E tests by trigger spans
96+
flagEvaluation()
97+
}
9598

9699
LDReplay.start()
97100
}

e2e/android/app/src/test/java/com/example/androidobservability/DisablingConfigOptionsE2ETest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class DisablingConfigOptionsE2ETest {
7373

7474

7575
@Test
76-
@Ignore
7776
fun `Spans should NOT be exported when TracesApi is disabled`() {
7877
application.observabilityOptions = getOptionsAllEnabled().copy(tracesApi = ObservabilityOptions.TracesApi.disabled())
7978
application.initForTest()
@@ -90,7 +89,6 @@ class DisablingConfigOptionsE2ETest {
9089
}
9190

9291
@Test
93-
@Ignore
9492
fun `Spans should NOT be exported when TracesApi does not include spans`() {
9593
application.observabilityOptions = getOptionsAllEnabled().copy(
9694
tracesApi = ObservabilityOptions.TracesApi(includeSpans = false)
@@ -152,7 +150,6 @@ class DisablingConfigOptionsE2ETest {
152150
}
153151

154152
@Test
155-
@Ignore
156153
fun `Errors should NOT be exported when TracesApi does not include errors`() {
157154
application.observabilityOptions = getOptionsAllEnabled().copy(
158155
tracesApi = ObservabilityOptions.TracesApi(includeErrors = false)
@@ -171,7 +168,6 @@ class DisablingConfigOptionsE2ETest {
171168
}
172169

173170
@Test
174-
@Ignore
175171
fun `Errors should be exported as spans when TracesApi include errors but not spans`() {
176172
application.observabilityOptions = getOptionsAllEnabled().copy(
177173
tracesApi = ObservabilityOptions.TracesApi(includeErrors = true, includeSpans = false)

e2e/android/app/src/test/java/com/example/androidobservability/SamplingE2ETest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import io.opentelemetry.api.common.Attributes
1212
import io.opentelemetry.api.logs.Severity
1313
import junit.framework.TestCase.assertEquals
1414
import kotlinx.coroutines.test.runTest
15-
import org.junit.Ignore
1615
import org.junit.Before
1716
import org.junit.Rule
1817
import org.junit.Test
@@ -73,7 +72,6 @@ class SamplingE2ETest {
7372
}
7473

7574
@Test
76-
@Ignore
7775
fun `should avoid exporting spans matching sampling configuration for spans`() = runTest {
7876
triggerSpans()
7977
telemetryInspector?.spanExporter?.flush()

0 commit comments

Comments
 (0)