I´ve tried to setup a router for navigating to the right Viewcontroller. When I call this in the simulator, it does work fine.
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.
My Method looks like the following:
func navigateToViewController(_ viewController: UIViewController, animated: Bool) {
self.pushViewController(viewController, animated: animated)
}
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.
When I assert that the topViewController or presentedViewController should be a HomeViewController, I always get a different ViewController as result.
XCTAssertTrue(self.sut.topViewController is HomeViewController,
"The TopViewController should be set to the HomeViewController but instead: \(self.sut.topViewController)")
How could that be and how can I solve this?