Skip to content

Commit 670b474

Browse files
test: Improve testResumeAndPauseAppHangTracking (#6184)
Ensure the anrTrackingIntegration isn't nil and add a more descriptive test failure message.
1 parent 870b081 commit 670b474

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Tests/SentryTests/SentrySDKInternalTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ class SentrySDKInternalTests: XCTestCase {
608608
#endif
609609

610610
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
611-
func testResumeAndPauseAppHangTracking() {
611+
func testResumeAndPauseAppHangTracking() throws {
612612
SentrySDK.start { options in
613613
options.dsn = SentrySDKInternalTests.dsnAsString
614614
options.setIntegrations([SentryANRTrackingIntegration.self])
@@ -617,7 +617,7 @@ class SentrySDKInternalTests: XCTestCase {
617617
let client = fixture.client
618618
SentrySDKInternal.currentHub().bindClient(client)
619619

620-
let anrTrackingIntegration = SentrySDKInternal.currentHub().getInstalledIntegration(SentryANRTrackingIntegration.self)
620+
let anrTrackingIntegration = try XCTUnwrap(SentrySDKInternal.currentHub().getInstalledIntegration(SentryANRTrackingIntegration.self))
621621

622622
SentrySDK.pauseAppHangTracking()
623623
Dynamic(anrTrackingIntegration).anrDetectedWithType(SentryANRType.unknown)
@@ -629,7 +629,7 @@ class SentrySDKInternalTests: XCTestCase {
629629
if SentryDependencyContainer.sharedInstance().crashWrapper.isBeingTraced {
630630
XCTAssertEqual(0, client.captureEventWithScopeInvocations.count)
631631
} else {
632-
XCTAssertEqual(1, client.captureEventWithScopeInvocations.count)
632+
XCTAssertEqual(1, client.captureEventWithScopeInvocations.count, "The SDK should capture an AppHang after resuming the tracking, but it didn't.")
633633
}
634634
}
635635

0 commit comments

Comments
 (0)