lundi 7 décembre 2015

How to test deinit of viewController

I want to test if I remove all the key value observers in the deinit of my view controller.

In the test class I have defined following method to start view controller lifecycle

  func startLifecycle() {
   _ = viewController.view
  }

In my test method I'm trying to invoke deinit by simply assigning nil to my view controller instance

testViewController = nil
XCTAssert for stuff...

But deinit is not called when I execute my test. I see no obvious retain cycles in my VC's code, what's more when I run the code in my app, not the test environment, deinit is called so it doesn't seem like something is keeping view controller in memory.

What is the correct way to release a view controller when testing?

Aucun commentaire:

Enregistrer un commentaire