diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 5b647b78c9..61d36d244b 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -554,7 +554,6 @@ 7BED3576266F7BFF00EAA70D /* TestSentryCrashWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BED3575266F7BFF00EAA70D /* TestSentryCrashWrapper.m */; }; 7BEF4957270C4B9D00F8F30E /* SentryUIViewControllerSwizzlingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BEF4956270C4B9D00F8F30E /* SentryUIViewControllerSwizzlingTests.swift */; }; 7BEFB044270B0F630025F808 /* SentryTracerObjCTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BEFB043270B0F630025F808 /* SentryTracerObjCTests.m */; }; - 7BF1F6AE282A4FE2006BD6AB /* SentryTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BF1F6AD282A4FE2006BD6AB /* SentryTestObserver.m */; }; 7BF536D124BDF3E7004FA6A2 /* SentryEnvelopeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BF536D024BDF3E7004FA6A2 /* SentryEnvelopeTests.swift */; }; 7BF536D424BEF255004FA6A2 /* SentryAssertions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BF536D324BEF255004FA6A2 /* SentryAssertions.swift */; }; 7BF6505F292B77EC00BBA5A8 /* SentryMetricKitIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BF6505E292B77EC00BBA5A8 /* SentryMetricKitIntegrationTests.swift */; }; @@ -1435,8 +1434,6 @@ 7BED3575266F7BFF00EAA70D /* TestSentryCrashWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestSentryCrashWrapper.m; sourceTree = ""; }; 7BEF4956270C4B9D00F8F30E /* SentryUIViewControllerSwizzlingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIViewControllerSwizzlingTests.swift; sourceTree = ""; }; 7BEFB043270B0F630025F808 /* SentryTracerObjCTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryTracerObjCTests.m; sourceTree = ""; }; - 7BF1F6AC282A4FC6006BD6AB /* SentryTestObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryTestObserver.h; sourceTree = ""; }; - 7BF1F6AD282A4FE2006BD6AB /* SentryTestObserver.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryTestObserver.m; sourceTree = ""; }; 7BF536D024BDF3E7004FA6A2 /* SentryEnvelopeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelopeTests.swift; sourceTree = ""; }; 7BF536D324BEF255004FA6A2 /* SentryAssertions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryAssertions.swift; sourceTree = ""; }; 7BF6505E292B77EC00BBA5A8 /* SentryMetricKitIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetricKitIntegrationTests.swift; sourceTree = ""; }; @@ -2956,8 +2953,6 @@ 7B6D98EC24C703F8005502FA /* Async.swift */, 7BF9EF712722A84800B5BBEF /* SentryClassRegistrator.h */, 7BF9EF732722A85B00B5BBEF /* SentryClassRegistrator.m */, - 7BF1F6AC282A4FC6006BD6AB /* SentryTestObserver.h */, - 7BF1F6AD282A4FE2006BD6AB /* SentryTestObserver.m */, 7B72D23928D074BC0014798A /* TestExtensions.swift */, 7BB7E7C629267A28004BF96B /* EmptyIntegration.swift */, 7B4F22DB294089530067EA17 /* FormatHexAddress.swift */, @@ -4071,7 +4066,6 @@ 7BE3C7752445C82300A38442 /* SentryCurrentDateTests.swift in Sources */, 7B3398672459C4AE00BD9C96 /* SentryEnvelopeRateLimitTests.swift in Sources */, 8EA9AF492665AC48002771B4 /* SentryPerformanceTrackerTests.swift in Sources */, - 7BF1F6AE282A4FE2006BD6AB /* SentryTestObserver.m in Sources */, 7B3B473E25D6CEA500D01640 /* SentryNSErrorTests.swift in Sources */, 632331F62404FFA8008D91D6 /* SentryScopeTests.m in Sources */, D808FB88281AB33C009A2A33 /* SentryUIEventTrackerTests.swift in Sources */, diff --git a/Tests/SentryTests/TestUtils/SentryTestObserver.h b/Tests/SentryTests/TestUtils/SentryTestObserver.h deleted file mode 100644 index 92f65751bc..0000000000 --- a/Tests/SentryTests/TestUtils/SentryTestObserver.h +++ /dev/null @@ -1,13 +0,0 @@ -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -/** - * Report failing tests to Sentry. - */ -@interface SentryTestObserver : NSObject - -@end - -NS_ASSUME_NONNULL_END diff --git a/Tests/SentryTests/TestUtils/SentryTestObserver.m b/Tests/SentryTests/TestUtils/SentryTestObserver.m deleted file mode 100644 index 439cf61203..0000000000 --- a/Tests/SentryTests/TestUtils/SentryTestObserver.m +++ /dev/null @@ -1,100 +0,0 @@ -#import "SentryTestObserver.h" -#import "SentryBreadcrumb.h" -#import "SentryClient.h" -#import "SentryCrashIntegration.h" -#import "SentryCrashWrapper.h" -#import "SentryCurrentDate.h" -#import "SentryDefaultCurrentDateProvider.h" -#import "SentryHub.h" -#import "SentryLog+TestInit.h" -#import "SentryOptions.h" -#import "SentryScope.h" -#import "SentrySdk+Private.h" -#import "XCTest/XCTIssue.h" -#import "XCTest/XCTest.h" -#import "XCTest/XCTestCase.h" -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface -SentryTestObserver () - -@property (nonatomic, strong) SentryOptions *options; -@property (nonatomic, strong) SentryScope *scope; - -@end - -@implementation SentryTestObserver - -+ (void)load -{ -#if defined(TESTCI) - [[XCTestObservationCenter sharedTestObservationCenter] - addTestObserver:[[SentryTestObserver alloc] init]]; -#endif -} - -- (instancetype)init -{ - if (self = [super init]) { - SentryOptions *options = [[SentryOptions alloc] init]; - options.dsn = @"https://6cc9bae94def43cab8444a99e0031c28@o447951.ingest.sentry.io/5428557"; - options.environment = @"unit-tests"; - options.debug = YES; - options.enableAutoSessionTracking = NO; - options.maxBreadcrumbs = 5000; - - // The SentryCrashIntegration enriches the scope. We need to install the integration - // once to get the scope data. - [SentrySDK startWithOptions:options]; - - self.scope = [[SentryScope alloc] init]; - [SentryCrashIntegration enrichScope:self.scope - crashWrapper:[SentryCrashWrapper sharedInstance]]; - - self.options = options; - } - return self; -} - -#pragma mark - XCTestObservation - -- (void)testCaseWillStart:(XCTestCase *)testCase -{ - SentryBreadcrumb *crumb = [[SentryBreadcrumb alloc] initWithLevel:kSentryLevelDebug - category:@"test.started"]; - [crumb setMessage:testCase.name]; - // The tests might have a different time set - [crumb setTimestamp:[NSDate new]]; - [self.scope addBreadcrumb:crumb]; -} - -- (void)testBundleDidFinish:(NSBundle *)testBundle -{ - [SentrySDK flush:5.0]; -} - -- (void)testCase:(XCTestCase *)testCase didRecordIssue:(XCTIssue *)issue -{ - // Tests set a fixed time. We want to use the current time for sending - // the test result to Sentry. - id currentDateProvider = [SentryCurrentDate getCurrentDateProvider]; - [SentryCurrentDate setCurrentDateProvider:[SentryDefaultCurrentDateProvider sharedInstance]]; - - // The tests might mess up the files or something else. Therefore, we create a fresh client and - // hub to make sure the sending works. - SentryClient *client = [[SentryClient alloc] initWithOptions:self.options]; - // We create our own hub here, because we don't know the state of the SentrySDK. - SentryHub *hub = [[SentryHub alloc] initWithClient:client andScope:self.scope]; - NSException *exception = [[NSException alloc] initWithName:testCase.name - reason:issue.description - userInfo:nil]; - [hub captureException:exception withScope:hub.scope]; - - [SentryCurrentDate setCurrentDateProvider:currentDateProvider]; -} - -@end - -NS_ASSUME_NONNULL_END