Skip to content

Commit 3ac8825

Browse files
test: Add integration test for standalone app start tracing
Verify the full path from SentryAppStartTracker through StandaloneTransactionStrategy captures a transaction with the correct name and operation, and does not set the global static.
1 parent 973cc2f commit 3ac8825

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Tests/SentryTests/Integrations/Performance/AppStartTracking/SentryAppStartTrackerTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,26 @@ class SentryAppStartTrackerTests: NotificationCenterTestCase {
364364
assertValidStart(type: .cold, expectedDuration: 0.45)
365365
}
366366

367+
func testStart_whenStandaloneAppStartTracingEnabled_shouldCaptureTransaction() throws {
368+
fixture.options.tracesSampleRate = 1
369+
let client = TestClient(options: fixture.options)
370+
let hub = TestHub(client: client, andScope: Scope())
371+
SentrySDKInternal.setCurrentHub(hub)
372+
373+
fixture.enableStandaloneAppStartTracing = true
374+
startApp(callDisplayLink: true)
375+
376+
let serialized = try XCTUnwrap(hub.capturedTransactionsWithScope.invocations.first?.transaction)
377+
XCTAssertEqual(serialized["transaction"] as? String, "App Start Cold")
378+
379+
let contexts = try XCTUnwrap(serialized["contexts"] as? [String: Any])
380+
let traceContext = try XCTUnwrap(contexts["trace"] as? [String: Any])
381+
XCTAssertEqual(traceContext["op"] as? String, "app.start.cold")
382+
383+
// The global static must not be set — standalone bypasses it.
384+
XCTAssertNil(SentrySDKInternal.getAppStartMeasurement())
385+
}
386+
367387
private func store(appState: SentryAppState) {
368388
fixture.fileManager.store(appState)
369389
}

0 commit comments

Comments
 (0)