Running Android emulator from Jenkins to run Junit test with Robotium - java

How can I run Android emulator from Jenkins to run my tests?
When I write in Execiute Windows bath comand, command to run emulator:
emulator -avd Tester
and run my tests I have this errors:
..>emulator -avd Tester 'emulator' is not recognized as an internal
or external command, operable program or batch file.
..>exit 9009 Build step 'Execute Windows batch command' marked build
as failure
I set path for Android_SDK, java in Windows path and it works from cmd.
What should I do to run emulator?

You can automate the process with the Android Emulator Plugin for Jenkins.

You just need to find where the file "emulator.exe" is located, and then run the command in that location. For example, the most probably is that it is located in C:...android-sdk\tools
so, go to the command promt, type cd C:\android-sdk\tools. Then type the command, and it will work just fine. I hope this is the answer even though it´s late. So, accept the answer.

Related

How to execute an APK (Test cases) through ADB command?

I'm unable to get the detailed description of installation of an apk. I have tried adb install "filename.apk" it showing only success. Is there any way to get full log file while installing or executing ?
When running a UI test on the emulator or device the gradle builds two apk files, one for the app, and one for the testing code. Let’s build both the app and the testing app and install them.
First connect a device or an emulator, and type in the command line in the project folder:
./gradlew clean installDebug installDebugAndroidTest
This command will:
clean the build folder
compile and install the app on the device
compile and install testing app on the device
Now for the fun part. Run the tests from command line:
adb shell am instrument -w -r -e debug false -e class com.your.app.ExampleInstrumentedTest#checkButton com.your.app.test/android.support.test.runner.AndroidJUnitRunner
Let’s explain the above command first:
“adb shell am instrument -w” runs all the UI tests
“-e debug false” is because we don’t want to debug the testing
“-e class com.your.app.ExampleInstrumentedTest#checkButton com.your.app.test/android.support.test.runner.AndroidJUnitRunner” this tells our app to run a specific test

Android error- Working Directory: null Environment: null

I am trying executing this bat in android studio and I get the below error. I am not sure how to resolve this as I am new to android. can anyone please suggest what needs to be tried.
Process p = Runtime.getRuntime().exec("cmd /c start /src/androidTest/CopyFiles.bat");
Error:
java.io.IOException: Error running exec(). Command: [cmd, /c, start, /src/androidTest/CopyFiles.bat] Working Directory: null Environment: null
at java.lang.ProcessManager.exec(ProcessManager.java:211)
at java.lang.Runtime.exec(Runtime.java:174)
at java.lang.Runtime.exec(Runtime.java:247)
at java.lang.Runtime.exec(Runtime.java:190)
The problem is simply that you are trying to run the cmd command on a Linux (which Android actually consists of) system. cmd is the short name for cmd.exe which is located in C:\Windows\system32\cmd.exe but not on Linux/Android phones. So it does not exist. If you are only trying to copy files, you could do this with Java.
If you are trying to extend your application with plugins or extensions you may want to have a look at BeanShell. Running .bat files is not easy on Android. You would at least have to run a shell script instead. Just Google around to see how you can run shell scripts on Android and how they differ from Batch files.
Long story short: CMD is not found on your Android phone because it's a Windows program. Because it cannot be found you get this error.

How can I run gradle startscript created using installDist task from a batch file in windows OS?

I have Executed the gradle installDist task for my project. After that two start scripts were created one for running in unix like system and another for windows.
I am able to successfully execute the script created for unix systems. But when I tried to run the windows .bat file in my windows system. It is giving below error in command line.
Even if I am trying to run the batch file directly from cmd. It is giving the below error
The input line is too long.
The syntax of the command is incorrect.

Executing windows batch script on Jenkins

I am building a project using Maven and using Jenkins for continuos integration. After the maven build i am getting an executable jar in my target folder which i am trying to run using a windows batch command as build step. But when i put the command in the box under execute windows batch command i get the following error
"cmd /c call /tmp/hudson2033384960131825453.bat FATAL: command
execution failed java.io.IOException: Cannot run program "cmd" (in
directory "/hosting/workspace/myProject"): error=2, No such file or
directory""
I am using mac OSX 10.9.3. The jenkins is deployed in a remote server which i don't have access to.
I want to execute this jar file as a build process. How can i do it?
You should not be expecting a windows batch command to be able to run on a mac. Jenkins is pretty cool, I agree, but it isn't magical.
Also, yes, it is a little confusing that the option is available to you even though you are on a Mac, but its there incase you have a linux / mac master with windows slave: https://issues.jenkins-ci.org/browse/JENKINS-17010?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab
You cannot execute a windows batch command on mac or linux, end of story.
You are trying to launch windows command through jenkins on another operating system which is not going to work

Executing adb command on java program

i made a java tool which calls certain adb command to download an app from market. When i made it into a runnable JAR, its executing fine in the system where i made it, but when i try it on other system the adb commands just fail to execute
Any suggestions
AFAIK executable jar donot work on android. Sun Java and Android are not compatible
Have you included the Adb executable and the related dll in your solution?
You should include it for 2 main reasons:
if the system hasn't the android sdk, it doen't have adb
the path to adb can differ from one computer to another.

Categories

Resources