I currently use the Android Monkey tool for stress testing Android system/packages. I find it to be useful. But so far everything has been manual testing (i.e. open emulator, execute adb shell monkey <...>, etc.). I'd like to "automate" this and have it triggered externally by a build server.
My initial instinct is to just write a shell script to execute monkey (using random seeds) and then store the results in an build server accessible file. But is this really useful?
Just curious if anyone has done this before and/or has a "smarter" idea for automating Android Monkey runs. A Google search using terms "automating android monkey" turned up little relevant information.
All thoughts welcome.
Update:
I decided to go with a simple shell script since I couldn't think of anything "smarter" to do. It's still a work in progress. Here it is at it's current state:
#!/bin/bash
REPORTROOT=./reports
# remove old report files
echo "Removing old output report files..."
rm $REPORTROOT
# make dir for new report files
echo "Output reports will be stored in $REPORTROOT..."
mkdir $REPORTROOT
# run monkey on the entire system
echo "Running Monkey on entire system..."
adb -e shell monkey -v -v -v 500 > $REPORTROOT/monkey_sys.txt
# pull the log file from device?
# run monkey on particular packages
# packages here...
# create composite report
echo "Running reports..."
grep -A 5 -h -r CRASH $REPORTROOT > $REPORTROOT/crash_report.txt
The output is a simple .txt file with a few lines about any crashes.
You could look at Hudson - that should be able to start an emulator and then do your android monkey commands.
Related
I'm too lazy to reach out and tap the application icon on my tablet. After installing and testing, how do I tell ./gradlew to launch the app? This command returns nothing:
$ ./gradlew tasks --all | grep -i launch
A related question that might fix my ulterior problem is: How to write an Android app that prefers to be on all the time? My app is in-house, so our tablets have no reason to exist except to run our app.
Per CommonsWare's comment, try:
adb -s WHATEVER shell am start -n com.mycorp.myapp/com.mycorp.myapp.MainActivity
and forget gradlew because I have all my command lines in a Rakefile already because it's easy to maintain.
Let assume that I want to add logs in MediaHTTPConnection
Couple weeks ago I was just doing:
make -j8 framework
And then framework.jar was created, which I could push on rooted device.
However now I see that boot.art and boot.oat are created and framework.jar is more or less "empty" and useless.
On the other hand I saw that I could build with:
DEXPREOPT_BOOT_JARS=false
and maybe it could fix my problem, however rebuilding whole project just to add some logs to framework doesn't look like smart idea ... So I would like to know if there is a way to somehow flash those new boot.art and boot.oat?
EDIT:
As stated above for now my workaround is rebuilding whole Android with flags that prevents dex optimization. Then I have normal framework.jar (couple MB instead of couple KB) which I can replace with framework build with the same flags. It's not so terrible (since I build whole project once) but still I would like to know better solution for that. Although I doubt it currently exists.
Perform the following:
mmm frameworks/base
adb remount
adb shell stop
adb sync
adb shell start
additional resources can be found here:
http://devtcg.blogspot.in/2009/03/building-running-and-debugging-android.html
If ADB remount won't work:
# Script to mount Android Device as read/write.
# List the Devices.
adb devices;
# Run adb as root (Needs root access).
adb root;
# Since you're running as root su is not required
adb shell mount -o rw,remount /;
adb sync
adb shell start
I'm trying to build an automated build script with applescript on MacOS X.
For now everything works correctly with one glitch.
The command "do script ("zipalign -f -v 4 /tmp/src.apk /tmp/tgt.apk") works fine if I run it in a separate tell for application "Terminal" but leaves the terminal window open when it's done. Everything else in the script works fine in tells for application "Finder".
If I try to run the command via "do shell script" inside the tell for "Finder" I only get an error "command not found".
The path to zipalign is set in /etc/paths and is reachable through any terminal window and "do shell" but not to "do shell script" command.
What is the correct way to ensure that "do shell script" uses $PATH to find commands or alternatively is there a bulletproof way to close the terminal left by "do script"?
When you invoke bash as an interactive login shell, the paths in /etc/paths and /etc/paths.d/* are added to PATH by /usr/libexec/path_helper, which is run from /etc/profile. do shell script invokes bash as sh and as a non-interactive non-login shell, which does not read /etc/profile.
You can run path_helper manually though:
do shell script "eval `/usr/libexec/path_helper -s`; echo $PATH"
Though this question was four years ago, but I think the simplest answer is needed to be told. I use the command 'wkhtmltopdf' (which is used to print pdf and it is placed in /usr/local/bin) for example
--past
wkhtmltopdf out.html out.pdf
--now
PATH=$PATH:/usr/local/bin; wkhtmltopdf out.html out.pdf
It just add new PATH variable to the sh process called up by AppleScript.
I have a problem with beanshell.I want to create a BeanShell script that allows me to automate a Robotium test.
I have a shell script that works and lets me do whatever I want, but I'm looking Beanshell equivalent:
#!/bin/bash
echo "on lance l'AVD"
emulator -avd test &
echo "wait the end of launch"
sleep 15
echo "Installation of the application under test"
adb install -r /home/marie/workspace/AndroidCalculator/bin/AndroidCalculator.apk
echo "Installation of the test application"
adb install -r /home/marie/workspace/TestProject/bin/TestProject.apk
echo "Launch of test"
adb shell am instrument -w com.calculator.test/com.neenbedankt.android.test.InstrumentationTestRunner
echo "Saving file results"
adb pull data/data/com.calculator/files/TEST-all.xml ./resultats.xml
echo "killing the AVD"
adb emu kill
How, through BeanShell, I can run the script pre-made, or when an equivalent result by any other means that you can suggest me.
I am looking for answers for 3 days, and I have nothing conclusive
Thank you in advance for your help.
Marie,
u can have look into the integrating ur robotium project with jenkins. Its a build deployment tool. It has plugin which allows to control the android testing.
Have a look at below links:
http://dnlkntt.wordpress.com/2012/08/02/robotium-jenkins-and-ant/
It helped me a lot to automate the test execution process.
Part of my android app's functionality it to place a script I have written in init.d, so that it will be executed on every startup. (obviously my app is for root users only)
Here's what I am doing:
busybox mount -o rw,remount /system"
busybox cp -f /sdcard/*******/script /system/etc/init.d/script
busybox chmod +x /etc/init.d/script
update-rc.d script 99
The "update-rc.d script 99" line is where I run into trouble, it fails with an "update-rc.d not found" error.
Does anyone know what the proper command would be to make this work in Android??
I realize that this isn't exactly the most appropriate place to post this question, but I have come realize that this community is extremely knowledgeable on these matters.
Add something like this to your init.rc
service script /system/etc/init.d/script
oneshot
There's no update-rc.d in Android because there's no SYSV init either.