getsentry / getsentry/sentry-cocoa
Audit usage of SentryFileManager in the unit tests
- Dominant language
- Swift
- Stars
- 1.1k
- Forks
- 418
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 106
Description
### Description
SentryFileManager dispatches a delayed block to do some work, which winds up triggering other parts of the SDK. This interferes with other unit tests in a nondeterministic way. I ran the unit tests and logged every time the real SentryFileManager's `deleteOldEnvelopeItems` method was called:
```
SentryNetworkTrackerIntegrationTests
SentryHttpTransportTests
SentryHubTests
SentrySDKTests
SentryCrashInstallationReporterTests has both the real and test version both calling to remove old envelope items
SentryCoreDataTrackingIntegrationTests
SentryClientTest
SentryUIViewControllerPerformanceTrackerTests
SentryScreenshotIntegrationTests
SentryCrashObjC_Tests
SentryUIViewControllerSwizzlingTests
SentryViewHierarchyIntegrationTests
SentryNSNotificationCenterWrapperTests
SentryThreadInspectorTests
SentryTests
SentryFileManagerTests
```
The only one that should actually exercise the real version's method is the last one. All others should be using TestFileManager. Any unit tests that need to test the integration of another SDK component with the file manager need to be moved to either `SentryFileManagerTests` or a new test class like `SentryFileManagerIntegrationTests`.
Contributor guide
Assessment
This issue has not been assessed yet.