getsentry / getsentry/sentry-cocoa

Audit usage of SentryFileManager in the unit tests

Open
#2,745 4 comments 0 reactions 0 assignees View on GitHub
Cocoa
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.