UI Automation Instruments: How to reset the app state? - ios

I am new to UI Automation with Instruments, and I haven't found a way to reset the app state. How should I prevent tests from affecting each other? I also haven't found a way to use setUp or tearDown methods? It would be awesome if someone has a advice for me - thanks a lot!
I read in quit old blog post that it is not possible? On the other hand Appium is able to do it and it is actually using Instruments - so there must be a way?
Best regards,
Daniel

I think only way is by restarting application.
You can check this question How to continue testing an iOS app, using UIAutomation instrument, even after the app exits?

Related

how to debug and issue tracking ios ui freezing?

I am developing a live platform using amazon IVS player SDK.
But I have a little problem.
The ui freezing phenomenon occurs intermittently, but it is difficult to debug because the clear call stack is not visible.
I have doubts, but I can't see it as open source.
mainThread callstack
Suspicious thread
The situation is as follows, but my expectation is that "psync_mutexwait" occurs on the "AVSampleBufferDisplayLayer" side on the open source side and freezes.. I am not sure if this is correct.
So, I'm going to do more debugging, but if there is any reason to think about it or any tips for debugging when the call stack is as follows in the state of ui freezing,
Please let me know that knowledge.
thank you.
Use XCode profiler. Go to Product > Profile and select Game Performance. It should help you to detect UI freezes at runtime. Detailed guide here.

Xcode/iOS App freezing, how to track such errors

I have sometimes app freezing I do not know what is the source of problem.
It happens rarely but happens. I consider how to track such issue
I have crashlytics from firebase but there is no errors as freezing is I suppose something with threads maybe some deadlocks or infinite loops.
Is there way to track such things?
What maybe reasons of app freezing and being inactive (it is SwiftUI app) ?
Are there possibilities to track/profile apps installed on devices (not connected via Xcode) and send informations such that are available in Instrument to something like firebase console or other 3rd party tools.
Update
I think I do not indicated important fact.
It freezes UI definitely not for a few seconds but app need do be killed and restarted again.
There might be some heavy process that locks your main thread, so it freezes your UI.
You track the problems, performance, leaks and more using Instruments.
There are sample topics:
Instruments Tutorial with Swift: Getting Started
How to find and fix slow code using Instruments
And WWDC videos like
Using Time Profiler in Instruments
Creating Custom Instruments
I have experienced some of these weird behaviours before. And mostly the reason behind it was a task that is blocking the main thread making it unresponsive. Pause the app and check the stack trace. Also make sure all your UI operations are done on the main thread. Hope this helps!

When will instruments process stop

Now I'm learning UI testing in Instruments. I want to know in what cases will the instruments process stop. Like when the App that is being tested crashes or something. Does someone konw?
I suggest you to use UI Testing based on XCTest instead of instruments and javascript. The javascript way of UI testing is officially deprecated.

Communicate between UIAutomation and app

Is there any way for a UIAutomation script to communicate with the running app and just send it information, trigger a function, or change a variable - directly rather than through the UI?
I ask because I am using just using the script to take screenshots and it would be really handy if I could tell the app to set a couple of integers rather than dealing with somewhat unreliable and difficult to set up multitouch gestures and timing.
I stumble upon this today while having same need.
I have solved this is by using GCDWebServer and sending post message from my app to the local web server end point hosted in UIAutomation.

IOS Core Data Concurrency

We are developing an IPad application with synchronization support, this synchronization logic is launched at the startup of the application to check if there are any updates by invoking a WCF service.
As the synchronization process takes time, we would like to put it on a background worker to not block the user interface, so my question is:
is it possible to develop a background worker that synchronize the sqlite database on background and on the same time the user interface is using this database? If it's possible can you please provide code or links to help me implement this?
Thank's in advance
This is definitely possible. What you are referring to is Threading where a process is done in the Background. Read up on Apple's Thread Programming Guide and Concurrency Programming Guide to get a better idea on how exactly it's implemented in iOS

Resources