@@ -5,8 +5,6 @@ import XCTest
55#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
66final class FlushLogsIntegrationTests : XCTestCase {
77
8- private static let dsnAsString = TestConstants . dsnForTestCase ( type: FlushLogsIntegrationTests . self)
9-
108 private class Fixture {
119 let options : Options
1210 let client : TestClient
@@ -16,7 +14,7 @@ final class FlushLogsIntegrationTests: XCTestCase {
1614
1715 init ( ) throws {
1816 options = Options ( )
19- options. dsn = FlushLogsIntegrationTests . dsnAsString
17+ options. dsn = TestConstants . dsnForTestCase ( type : FlushLogsIntegrationTests . self )
2018 options. enableLogs = true
2119
2220 client = TestClient ( options: options) !
@@ -32,6 +30,7 @@ final class FlushLogsIntegrationTests: XCTestCase {
3230 }
3331
3432 private var fixture : Fixture !
33+ private var sut : FlushLogsIntegration < SentryDependencyContainer > ?
3534
3635 override func setUpWithError( ) throws {
3736 try super. setUpWithError ( )
@@ -42,58 +41,48 @@ final class FlushLogsIntegrationTests: XCTestCase {
4241 override func tearDown( ) {
4342 super. tearDown ( )
4443 clearTestState ( )
44+ sut = nil
4545 }
4646
4747 func testInstall_Success( ) {
48- let sut = fixture. getSut ( )
49-
48+ sut = fixture. getSut ( )
5049 XCTAssertNotNil ( sut)
5150 }
5251
5352 func testInstall_FailsWhenLogsDisabled( ) {
5453 fixture. options. enableLogs = false
55-
56- let sut = fixture. getSut ( )
54+ sut = fixture. getSut ( )
5755
5856 XCTAssertNil ( sut)
5957 }
6058
6159 func testName_ReturnsCorrectName( ) {
60+ sut = fixture. getSut ( )
61+
6262 XCTAssertEqual ( FlushLogsIntegration< SentryDependencyContainer> . name, " FlushLogsIntegration " )
6363 }
6464
6565 func testWillResignActive_FlushesLogs( ) {
66- guard let sut = fixture. getSut ( ) else {
67- XCTFail ( " Integration should be initialized " )
68- return
69- }
70- // Keep sut alive so observers don't get deallocated
71- _ = sut
66+ sut = fixture. getSut ( )
7267
7368 fixture. notificationCenterWrapper. post ( Notification ( name: CrossPlatformApplication . willResignActiveNotification) )
7469
7570 XCTAssertEqual ( fixture. client. captureLogsInvocations. count, 1 )
7671 }
7772
7873 func testWillTerminate_FlushesLogs( ) {
79- guard let sut = fixture. getSut ( ) else {
80- XCTFail ( " Integration should be initialized " )
81- return
82- }
83- // Keep sut alive so observers don't get deallocated
84- _ = sut
74+ sut = fixture. getSut ( )
8575
8676 fixture. notificationCenterWrapper. post ( Notification ( name: CrossPlatformApplication . willTerminateNotification) )
8777
8878 XCTAssertEqual ( fixture. client. captureLogsInvocations. count, 1 )
8979 }
9080
9181 func testUninstall_RemovesObservers( ) {
92- guard let sut = fixture. getSut ( ) else {
82+ guard let sut = fixture. getSut ( ) else {
9383 XCTFail ( " Integration should be initialized " )
9484 return
9585 }
96-
9786 sut. uninstall ( )
9887
9988 fixture. notificationCenterWrapper. post ( Notification ( name: CrossPlatformApplication . willResignActiveNotification) )
@@ -104,12 +93,7 @@ final class FlushLogsIntegrationTests: XCTestCase {
10493 }
10594
10695 func testMultipleNotifications_FlushesLogsMultipleTimes( ) {
107- guard let sut = fixture. getSut ( ) else {
108- XCTFail ( " Integration should be initialized " )
109- return
110- }
111- // Keep sut alive so observers don't get deallocated
112- _ = sut
96+ sut = fixture. getSut ( )
11397
11498 fixture. notificationCenterWrapper. post ( Notification ( name: CrossPlatformApplication . willResignActiveNotification) )
11599 fixture. notificationCenterWrapper. post ( Notification ( name: CrossPlatformApplication . willTerminateNotification) )
0 commit comments