Skip to content

Running the Instrumentation

Diego Torres Milano edited this page Jun 17, 2018 · 14 revisions

Table of Contents

In order to be able to access some of the components that make up the whole Culebra Tester system, Culebra Tester Instrumentation has to be running.

It's currently (Android M) not possible to start the Instrumentation from an Activity, thus it has to be started in a different way.

Culebra Tester UI

Culebra Tester UI shows the command that is required to be run to start the Instrumentation.

NOTE: The name of the script changed to runinstrumentation.sh.

Command line

Using server

Linux and OS X

Execute

    $ curl -o - http://192.168.2.250:9999/Assets/runinstrumentation.sh | bash

If there are more than one device connected a menu will be presented to select the target device

    1) emulator-5554	device
    2) 01234567890123	device
    Select the device to use, <Q> to quit:

Windows

You may execute the same as Linux if you have `bash` installed, or you can just run

    adb shell am instrument -w com.dtmilano.android.culebratester.test/com.dtmilano.android.uiautomatorhelper.UiAutomatorHelperTestRunner

if you have only one device connected or specify the correct serial number parameter.

Using script

If you have access to the source code, go to Culebra Tester directory and then execute:

    $ ./culebratester.sh runinstrumentation

This will start the Instrumentation on the selected device.

The use of the script to start the Instrumentation is useful in some situations where the device has no network connectivity and it's not possible to use `curl` to run the script.

Device with no network connectivity

Once the Instrumentation has been started as described before, it is needed to forward the TCP ports so Culebra Tester UI can be accessed.

    $ adb -s <serial-no> forward tcp:9999 tcp:9999

Replace the serial number for the one corresponding to the device in use.

Then you will be able to use

    http://localhost:9999

to access Culebra Tester UI.

This has been mentioned in If the user doesn't want or can't connect device network CulebraTester can't continue #3.

Instrumentation

Once run by some of the alternatives mentioned above, the Instrumentation will run and wait

    $ curl -s http://192.168.2.250:9999/Assets/runinstrumentation.sh | bash
    .
    com.dtmilano.android.uiautomatorhelper.UiAutomatorHelper:

It will run until CulebraTester Quits or it is interrupted (i.e. CTRL-C)

Problems running Instrumentation

INSTRUMENTATION_FAILED

 android.util.AndroidException: INSTRUMENTATION_FAILED: com.dtmilano.android.culebratester.test/com.dtmilano.android.uiautomatorhelper.UiAutomatorHelperTestRunner
 	at com.android.commands.am.Am.runInstrument(Am.java:890)
 	at com.android.commands.am.Am.onRun(Am.java:400)
 	at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
 	at com.android.commands.am.Am.main(Am.java:121)
 	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
 	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:262)
 INSTRUMENTATION_STATUS: id=ActivityManagerService
 INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.dtmilano.android.culebratester.test/com.dtmilano.android.uiautomatorhelper.UiAutomatorHelperTestRunner}
 INSTRUMENTATION_STATUS_CODE: -1

This indicates the Instrumentation APK has not been installed.