Skip to content

Commit 39280ec

Browse files
test: Use XCTestExpectation in HttpTransportTests (#5829)
Replace the dispatch group with a XCTestExpectation to get a failure message when the wait times out. Contributes to GH-5789
1 parent 2207f4f commit 39280ec

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Tests/SentryTests/Networking/SentryHttpTransportTests.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,22 +671,25 @@ class SentryHttpTransportTests: XCTestCase {
671671

672672
let queue = fixture.queue
673673

674-
let group = DispatchGroup()
675-
for _ in 0...20 {
676-
group.enter()
674+
let loopCount = 21
675+
676+
let expectation = XCTestExpectation(description: "Send envelopes concurrently")
677+
expectation.expectedFulfillmentCount = loopCount
678+
679+
for _ in 0..<loopCount {
677680
queue.async {
678681
self.givenRecordedLostEvents()
679682
self.sendEventAsync()
680-
group.leave()
683+
expectation.fulfill()
681684
}
682685
}
683686

684687
queue.activate()
685-
group.waitWithTimeout()
688+
wait(for: [expectation], timeout: 10)
686689

687690
waitForAllRequests()
688691

689-
XCTAssertEqual(self.fixture.requestManager.requests.count, 21)
692+
XCTAssertEqual(self.fixture.requestManager.requests.count, loopCount)
690693
}
691694

692695
func testBuildingRequestFails_DeletesEnvelopeAndSendsNext() {

0 commit comments

Comments
 (0)