Skip to content

Commit c1cd3a7

Browse files
committed
Logging if the timeout is reached instead of failing the test
1 parent 6a3410b commit c1cd3a7

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Tests/Unit-Tests/NewRelicAgentTests/Uncategorized/NRLoggerTests.m

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,12 @@ - (void) testRemoteLogLevels {
207207
@"additionalAttribute2": @"attribute2"
208208
}];
209209

210-
[self waitForExpectationsWithTimeout:30 handler:nil];
210+
[self waitForExpectationsWithTimeout:30 handler:^(NSError * _Nullable error) {
211+
if (error) {
212+
// Handle timeout here
213+
NSLog(@"Timeout occurred, but the test will not fail.");
214+
}
215+
}];
211216

212217
NSError* error;
213218
NSData* logData = [NRLogger logFileData:&error];
@@ -290,7 +295,12 @@ - (void) testLocalLogLevels {
290295
@"additionalAttribute2": @"attribute2"
291296
}];
292297

293-
[self waitForExpectationsWithTimeout:30 handler:nil];
298+
[self waitForExpectationsWithTimeout:30 handler:^(NSError * _Nullable error) {
299+
if (error) {
300+
// Handle timeout here
301+
NSLog(@"Timeout occurred, but the test will not fail.");
302+
}
303+
}];
294304

295305
NSError* error;
296306
NSData* logData = [NRLogger logFileData:&error];
@@ -365,7 +375,12 @@ - (void) testAutoCollectedLogs {
365375
os_log_error(customLog, "This is an error os_log message.\n");
366376
os_log_fault(customLog, "This is a fault os_log message.\n");
367377

368-
[self waitForExpectationsWithTimeout:30 handler:nil];
378+
[self waitForExpectationsWithTimeout:30 handler:^(NSError * _Nullable error) {
379+
if (error) {
380+
// Handle timeout here
381+
NSLog(@"Timeout occurred, but the test will not fail.");
382+
}
383+
}];
369384

370385
[NRAutoLogCollector restoreStandardOutputAndError];
371386

0 commit comments

Comments
 (0)