Skip to content

Commit

Permalink
test: clear test state in tests using SentryDependencyContainer (#3378)
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Nov 6, 2023
1 parent bbcbaff commit 282cc99
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions Tests/SentryTests/Helper/SentryAppStateManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class SentryAppStateManagerTests: XCTestCase {
override func tearDown() {
super.tearDown()
fixture.fileManager.deleteAppState()
clearTestState()
}

func testStartStoresAppState() {
Expand Down
1 change: 1 addition & 0 deletions Tests/SentryTests/Helper/SentryFileManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class SentryFileManagerTests: XCTestCase {
sut.deleteAllFolders()
sut.deleteTimestampLastInForeground()
sut.deleteAppState()
clearTestState()
}

func testInitDoesNotOverrideDirectories() {
Expand Down
1 change: 1 addition & 0 deletions Tests/SentryTests/Helper/SentryLogTests.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import SentryTestUtils
import XCTest

class SentryLogTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SentryANRTrackerTests: XCTestCase, SentryANRTrackerDelegate {

wait(for: [fixture.threadWrapper.threadFinishedExpectation], timeout: 5)
XCTAssertEqual(0, fixture.threadWrapper.threads.count)
clearTestState()
}

func start() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SentryAppStartTrackingIntegrationTests: NotificationCenterTestCase {
fixture = Fixture()
SentrySDK.setAppStartMeasurement(nil)
sut = SentryAppStartTrackingIntegration()
clearTestState()
}

override func tearDown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SentryFramesTrackingIntegrationTests: XCTestCase {

override func tearDown() {
PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = false
clearTestState()
super.tearDown()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class SentryHttpTransportTests: XCTestCase {
super.tearDown()
fixture.fileManager.deleteAllEnvelopes()
fixture.requestManager.waitForAllRequests()
clearTestState()
}

func testInitSendsCachedEnvelopes() {
Expand Down
15 changes: 6 additions & 9 deletions Tests/SentryTests/Protocol/SentryEnvelopeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,13 @@ class SentryEnvelopeTests: XCTestCase {
SentryDependencyContainer.sharedInstance().dateProvider = TestCurrentDateProvider()
}

override func tearDown() {
super.tearDown()
do {
let fileManager = FileManager.default
if fileManager.fileExists(atPath: fixture.path) {
try fileManager.removeItem(atPath: fixture.path)
}
} catch {
XCTFail("Couldn't delete files.")
override func tearDownWithError() throws {
try super.tearDownWithError()
let fileManager = FileManager.default
if fileManager.fileExists(atPath: fixture.path) {
try fileManager.removeItem(atPath: fixture.path)
}
clearTestState()
}

private let defaultSdkInfo = SentrySdkInfo(name: SentryMeta.sdkName, andVersion: SentryMeta.versionString)
Expand Down
1 change: 1 addition & 0 deletions Tests/SentryTests/SentryHubTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class SentryHubTests: XCTestCase {
fixture.fileManager.deleteAppState()
fixture.fileManager.deleteTimestampLastInForeground()
fixture.fileManager.deleteAllEnvelopes()
clearTestState()
}

func testBeforeBreadcrumbWithoutCallbackStoresBreadcrumb() {
Expand Down

0 comments on commit 282cc99

Please sign in to comment.