UITests: deinit is not called

Why, when I test my controllers in Xcode , everything is fine, but deinit methods are not called. Is it correct?

Although the application works fine, it's fine, but not for the UITest target.

For complex construction simulators, many and more objects are allocated, and ... do not free it at all. Thus, often on slow machines, the application sometimes quits for no reason ... and tests cannot be performed.

Using Xcode 8, iOS 10, macOS Sierra.

+8
ios xcode swift xcode-ui-testing
source share
2 answers

I can’t answer your question completely without seeing a sample test code, however your case makes me suspect a couple of things.

Basically, what happens is that the application creates new processes for each test you run. The first problem to investigate will be a memory leak inside the code. If you leak in memory, a testing structure that deploys a bunch of processes can cause a crash and allow this problem to fly under the radar during normal operation.

Also, if you do not initialize the controllers explicitly through the break function in your test class, the process usually just kills at the end of the test. If you want to test your reinitialization, I would suggest explicitly causing a stall in the tests to test your behavior in memory allocation. In addition, the Xcode parsing function may be useful here.

If you could post a sample of your test code, that would be a big help, and I will edit my answer accordingly.

0
source share

Make sure deinit is not empty. If it is empty, then it will never work. Indicate everything you need for release and check if it works.

My suggestion

  better to use dealloc method rather than using deinit. 
0
source share

All Articles