jonathanpenn / ui-auto-monkey

UI AutoMonkey is a simple stress testing script for iOS applications that runs in UI Automation and Instruments. Grass fed. Free range.
http://cocoamanifest.net
MIT License
1.47k stars 249 forks source link

ui-auto-monkey script would stop when app go to background #16

Open vigossjjj opened 9 years ago

vigossjjj commented 9 years ago

Hello,

I face a problem that if tap some button app would go to background, then script stop runing. For example tap on 3rd login button. How to i solve it?

JohnnyWuMigme commented 9 years ago

I had same problem while I use auto-monkey doing test. If the monkey taps out of the target app, the instruments will hang over there and nothing can do. Is there a way to detect the thread runs to different app? I notice there is a demo: https://www.youtube.com/watch?v=y5PZGVbLHtI&feature=youtu.be In this demo, he could detect and stop the monkey, but I don't have idea how did he make it.

screen shot 2015-05-15 at 2 39 12 pm

Currently I use a workaround to overcome this situation. Because we use Monkey as our stress test to try if there is any crash for current version. So I write a script to launch the Monkey for at most 10 mins one time, and set the script in LaunchAgent to run it every 10 mins. In this way to relaunch Monkey and make sure it can run through the whole weekend. But if possible I still would like to know how to detect while it runs to different app.

JohnnyWuMigme commented 9 years ago

Find another better workaround. Please refer link as below: http://developer.appcelerator.com/question/40081/ios4---make-app-not-run-in-background

Config the Info.plist file to enable "UIApplicationExitsOnSuspend", in this way if the target app is hidden to background the app will exit right away, so it would cause instruments to be terminated.

But in this way the log will show "2015-05-19 08:51:29 +0000 Fail: The target application appears to have died", which might be confused with real crash. Still have to find a way to detect the status and log it.

vigossjjj commented 9 years ago

@JohnnyWuMigme @jonathanpenn I refer the CrashMonkey and ui-auto-monkey to make a Project https://github.com/vigossjjj/CrashMonkey4IOS, it fix the app hang,and will relaunch the app to continue working via idevicedebug.

BruceBGordon commented 9 years ago

Is running with Guided Access on an option? Your script could pause and allow you to enter Guided Access manually. You can also enter programmatically (via objective-c code or swift) if you have a managed device. That requires adding some code to your application and creating a managed iOS device (Meraki is one provider).