I'm setting up a Jenkins job in order to run adb monkey on my app. I run the following command:
adb shell monkey -p nl.tmg.telegraaf -v 500
In some cases it succeeds and sometimes it fails. However, the exit code is always 0. Hence jenkins treats it as a successful job. Anybody know how this can be prevented?
You could use the Android Emulator Plugin for Jenkins, which can run Monkey for you, parse the output, and change the build result accordingly.
Related
At some point in my Monkeyrunner I want to launch random Monkey tests (The ones we can get through a command adb shell monkey -p my.package -v 500), So I added this line device.shell('monkey -p my.package -v 500') to my python script. But nothing happens, Any Ideas?
Your command should start the monkey tests. However, you need to pause the script execution during there random monkey tests by adding MonkeyRunner.sleep(no_of_seconds) statements. This will give time for the random tests to complete.
Yes normally it should start it, but it didn't.
Alternatively I imported os import os,
then I called monkey through this command os.system('adb shell monkey -p mypackage -v 500').
Sadly it relaunches the my application. Not the best outcome.
Can anyone tell me how can we get adb logs using eggPlant automation tool.Actually i want to have adb logs for my device when running eggPlant scripts.
Please help me out in this situation.
Actually, the previous answer is incorrect as adb command support does exist in eggPlant. There are ways to get adb logs in eggPlant. Here's how:
adb logcat is the command that enables getting adb logs. (Warning: This will print a ton of info!)
You need a way to execute adb logcat within eggPlant. This is accomplished using the shell command
On some systems (I am using eggPlant for Windows) you need to dump the output of the shell command to a file and then read the file back into a variable.
I guess there is no such command or something else.eggPlant identifies only object or script to execute the command.
I'm currently trying to automate few steps in android ICS CTS.
When we execute ./cts-tradefed we get cts-tf > prompt.
then I am able to enter run cts --plan CTS
then exit command to exit from prompt.
Here I want to write all the above 3 steps in one shell script. But unable to do it with below script. Tried in many way but could not achieve it. Please help.
Want to execute:
1. ./cts-tradefed
2. run cts --plan CTS exit
3. ./cts-tradefed
4. run cts --plan CTS
5. exit
Help in any shell, python or perl languages appreciated.
Excerpt from help of CTS-tradefed (version 6.0_r0)
exit: gracefully exit the cts console, waiting till all invocations are complete
We can leverage above argument to serve the purpose as follows:
echo exit | cts-tradefed <arguments to cts>
I am not sure which version of CTS you are using, so I assume the version is 4.0.3_r3.
You could execute the command ./cts-tradefed run cts --plan CTS in one line.
However, the prompt still exist after finish the command.
According to this issue,
I think there are no simple ways to solve it.
Therefore, I just apply the patch in the above link, and execute the following command:
echo | ./cts-tradefed run cts --plan CTS
With Android CTS 7.0, you can simply run this command line, it's most convenient for automation:
(Assume "cts-tradefed" is in your PATH.)
$ cts-tradefed run commandAndExit cts
Help from cts-tradefed:
r(?:un)? help:
commandAndExit <config> [options] Run the specified command, and run 'exit -c' immediately afterward
cmdfileAndExit <cmdfile.txt> Run the specified commandfile, and run 'exit -c' immediately afterward
How can I run my android junit/robotium tests from the command line on every single emulator? I want to make sure my tests run on many android OS versions and many screen resolutions.
I'd like to write a batch file that runs from the windows command line to run my test suite over and over again on each emulator I have installed.
To run from the command line I can do this:
adb shell am instrument -w
com.myapp.client.test/android.test.InstrumentationTestRunner
but that just runs it on the default emulator. How can I force that command to run on all of the emulators I have setup?
Ideally, the batch file would looking something like:
launch emulator1
run tests
close emulator1
launch emulator2
run tests
close emulator2
...
I don't know how to do the launch and close part.
Thanks
EDIT: Found solutions. Below is my batch file
set PORTRAIT=medium
set LANDSCAPE=large
:: launch emulator
emulator -avd android2.2
:: wait for emulator to load
adb wait-for-device
:: install apps?
:: run tests in portrait
adb shell am instrument -w -e size %PORTRAIT% com.myapp.client.test/android.test.InstrumentationTestRunner
:: run tests in landscape
adb shell am instrument -w -e size %LANDSCAPE% com.myapp.client.test/android.test.InstrumentationTestRunner
:: pull screenshots
adb pull /sdcard/ c:\
:: close/kill emulator (android bug here, so must use windows taskkill)
taskkill /IM emulator-arm.exe
I would really recommend you looking to use something like Jenkins to handle this for you. You can use the android emulator plugin to build up a whole matrix of API versions/Screen size to have your tests run against.
I'm using the emulator by command-line for our continuous integration server for our android application. With that approach we can test all Android Versions automatically. For the automatic installation and testing we are using the property "dev.bootcomplete", which is provided by the android emulator. Unfortunately we don't get it always. After a newly created emulator we are retrieving it, but when the emulator is several times used it do'nt throw it again...
Has Anybody an idea?
Commands/ results:
[user#mob_ci ~]$ adb shell getprop dev.bootcomplete
error: device offline
[user#mob_ci ~]$ adb shell getprop dev.bootcomplete
1
I use hudson as a ci server, for hudson there is a android plugin which manages the emulator, it even creates the emulator for you if you want.
I would either check if "error: device offline" happens and then run
adb kill-server
adb start-server
or
shutdown the emulator after each build, as it's not necessary that the emulator runs all the time or do the tests run all the time ?
hope this helps :)