Skip to content

Commit

Permalink
Unset connectivity delegate during tearDown in connectivity tests (#527)
Browse files Browse the repository at this point in the history
Motivation:

Some tests register a connectivity state delegate which fulfills
expectations on state changes. In some cases this causes the test to
fail during tear down as the expectation may be over fulfilled.

Modifications:

Remove the connectivity state delegate during the first step of tear
down.

Result:

Expectations are not overfulfilled during test tear down.
  • Loading branch information
glbrntt authored and MrMage committed Jul 24, 2019
1 parent 7416161 commit 42af0d7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Tests/GRPCTests/ClientConnectionBackoffTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class ClientConnectionBackoffTests: GRPCTestCase {
}

override func tearDown() {
// We have additional state changes during tear down, in some cases we can over-fulfill a test
// expectation which causes false negatives.
self.client.connectivity.delegate = nil

if let server = self.server {
XCTAssertNoThrow(try server.flatMap { $0.channel.close() }.wait())
}
Expand Down

0 comments on commit 42af0d7

Please sign in to comment.