title: Testing pushViewController in Swift
body: <p>I´ve tried to setup a router for navigating to the right Viewcontroller. When I call this in the simulator, it does work fine. </p>
  
  <p>BUT: When I try to test the outcome of this transition via the topViewController or presentedViewController property of my NavigationController, I always get every Viewcontroller but not the correct one. </p>
  
  <p>My Method looks like the following:</p>
  
  <pre><code>func navigateToViewController(_ viewController: UIViewController, animated: Bool) {
      self.pushViewController(viewController, animated: animated)
  }
  </code></pre>
  
  <p>As I said. It works perfectly fine in the Simulator but I´d like to test it. Every time I call this the ViewController is correctly set. But the result of the Test is a completely different Controller.</p>
  
  <p>When I assert that the topViewController or presentedViewController should be a HomeViewController, I always get a different ViewController as result.</p>
  
  <pre><code>XCTAssertTrue(self.sut.topViewController is HomeViewController,
                     "The TopViewController should be set to the HomeViewController but instead: \(self.sut.topViewController)")
  </code></pre>
  
  <p>How could that be and how can I solve this?</p>