How do you push Android Instrumentation Tests to Emulator/Device? - android

I'm trying to run the Webkit Layout Tests on the Android emulator using the command line shell in Ubuntu 9.04.
adb -s emulator-5554 shell am instrument -w \
com.android.dumprendertree/com.android.dumprendertree.LayoutTestsAutoRunner
I get this error:
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.android.dumprendertree/com.android.dumprendertree.LayoutTestsAutoRunner}
I found that you need to use development/testrunner/runtest.py to push tests in android/frameworks/base/tests.
I've tried this to push the AndroidTests:
. ./build/envsetup.sh
emulator&
./development/testrunner/runtest.py android
But it gives me this error:
Error: ANDROID_PRODUCT_OUT not defined. Please run envsetup.sh
I did run envsetup.sh! Anyone know how to do this?

I've found an answer at Android - Instrumentation Testing
. build/envsetup.sh
(cd frameworks/base/tests/DumpRenderTree/ && mm) && \
adb install out/target/product/generic/data/app/DumpRenderTree.apk
Then you can run the instrumentation tests:
adb -s emulator-5554 shell am instrument -w \
com.android.dumprendertree/com.android.dumprendertree.LayoutTestsAutoRunner

once you launch adb shell in command line:
go with a command stating the package(com.ni.Keyboard) say of Keyboard application..
am instrument -w com.ni.Keyboard.test/android.test.InstrumentationTestRunner

Related

connectedAndroidTest on multidex app is not finding any tests

I am trying to automate my build and make running our acceptance tests a part of that.
Unfortunately the gradle task connectedAndroidTest is reporting
Starting 0 tests on Nexus_5X_API_25(AVD) - 7.1.1
com.android.builder.testing.ConnectedDevice > No tests found.[Nexus_5X_API_25(AVD) - 7.1.1] FAILED .
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack #Test annotations).
This does not happen when I run the tests/suite from the IDE.
I found that Android Studio is executing following commands:
$ adb push /path/to/apk/app-debug.apk /data/local/tmp/com.MyApp
$ adb shell pm install -r "/data/local/tmp/com.MyApp"
$ adb push /path/to/apk/app-debug-androidTest.apk /data/local/tmp/com.MyApp.test
$ adb shell pm install -r "/data/local/tmp/com.MyApp.test"
$ adb shell am instrument -w -r -e debug false -e class com.myapp.TestSuite com.MyApp.test/com.myapp.testrunners.CreationInterceptingTestRunner
I know what those commands do but I do not know what connectedAndroidTest is doing under the hood and why it fails.
I found out that the issue has to do with multidex. At the end of the official page about enabling multidex it reads:
Notes:
* Don't use MultiDexTestRunner, which is deprecated; use AndroidJUnitRunner instead.
* Using multidex to create a test APK is not currently supported.
I do not understand what is mean with create test APK and why the adb command works.
I do not want to run the adb commands by hand as they have no reporting built in and I would need to do this all myself.
Is there any way to use connectedAndroidTest with multidex apps?

Equivalent adb command for MonkeyDevice.installPackage() method

Is there exist any adb equivalent command for MonkeyDevice.installPackage() method?
By using the installPackage()method in python script for monkeyrunner I'm able to install apk successfully.
But when i use the command:
adb install ApkFileName.apk
it returns protocol failure message. So what kinds of protocol used by monkeyrunner tool to execute installPackage() method successfully.
You can try what Android Studio does to install the APK
$ adb push ApkFileName.apk /data/local/tmp/apkfilename
$ adb shell pm install -r "/data/local/tmp/apkfilename"

Android treats ARM executable as a script

I am trying to execute an ARM binary on an Android emulator using adb, but it gives me an error as if it were trying to execute it as a script. Hello.c is a simple hello world program cross compiled for Android. How do I execute it properly? Below is what I did in my terminal. Thanks a lot.
arm-linux-androideabi-gcc --sysroot=/home/lotus/android-ndk-r13/platforms/android-9/arch-arm -o hello.o hello.c
adb -s emulator-5554 push hello.o /data/bin/hello
100 KB/s (6284 bytes in 0.061s)
adb -s emulator-5554 shell chmod 777 /data/bin/hello
adb -s emulator-5554 shell /data/bin/hello
/data/bin/hello: 1: Syntax error: word unexpected (expecting ")")

Robotium + Robolectric

I am using both frameworks to test my application.
I know these commands to run each:
Instrumentaion: gradlew clean connectedAndroidTest
Robolectric : gradlew clean build
I have tried others, but these are the points in my opinion.
Are there any command to run both tests?
You can use this command to run all tests:
adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner
Or this to run single testcase:
adb shell am instrument -w -e class com.android.foo.FooTest com.android.foo/android.test.InstrumentationTestRunner
More info how to use here: link
Here is example how I'm using this command
adb shell am instrument -w -e class app.name.androidTest.TestCustomer mobile.touch.core.test/android.test.InstrumentationTestRunner
It's great becouse it runs test immediately
Another way is implementing spoon-gradle-plugin Spoon plugin is great for running test and generating reports.
Command to run test with spoon:
gradle spoon -PspoonClassName=fully.qualified.TestCase

start ndk SanAngeles from shell#android

I have put the SanAngeles demo to run in my phone.
Here are steps I took:
$ android update project -p . --target android-14
$ ndk-build -B V=1 APP_OPTIM=debug NDK_DEBUG=1
$ ant debug install
It install fine. I saw the program was installed from the list of Apps in my smartphone. If I click on the icon DemoActivity, it runs.
But if I try to do it on host console:
$ adb shell
shell#android: $ am start -a android.intent.action.MAIN -n com.example.sanangeles/com.example.sanangeles.demoactivity
Error type 3
Error: Activity class {com.example.sanangeles/com.example.sanangeles.demoactivity}
does not exist.
Any suggestion?

Categories

Resources