diff --git a/Tests/Tests/AFURLSessionManagerTests.m b/Tests/Tests/AFURLSessionManagerTests.m index c43e673b9c..deb067dfe2 100644 --- a/Tests/Tests/AFURLSessionManagerTests.m +++ b/Tests/Tests/AFURLSessionManagerTests.m @@ -142,6 +142,12 @@ - (void)testSessionTaskDoesReportMetrics { #endif return YES; }]; + + __weak XCTestExpectation *metricsBlock = [self expectationWithDescription:@"Metrics completion block is called"]; + [self.localManager setTaskDidFinishCollectingMetricsBlock:^(NSURLSession * _Nonnull session, NSURLSessionTask * _Nonnull task, NSURLSessionTaskMetrics * _Nullable metrics) { + [metricsBlock fulfill]; + }]; + NSURLSessionTask *task = [self.localManager downloadTaskWithRequest:[self bigImageURLRequest] progress:nil destination:nil