Browse Source

Unset connectivity delegate during tearDown in connectivity tests (#527)

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.
George Barnett 6 years ago
parent
commit
42af0d71d7
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Tests/GRPCTests/ClientConnectionBackoffTests.swift

+ 4 - 0
Tests/GRPCTests/ClientConnectionBackoffTests.swift

@@ -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())
     }