Android tests not running

I created a test project with the same code as here:

http://developer.android.com/tools/testing/testing_ui.html

I downloaded the jar file to the Android virtual device and now I am ready to run the tests. But I always get this output on the console:

INSTRUMENTATION_STATUS: stream =

Test results for WatcherResultPrinter =

Time: 0.0

OK (0 tests)

INSTRUMENTATION_STATUS_CODE: -1


I also created a simple test with the following code:

public void FailedTest() throws UiObjectNotFoundException { assertTrue("This test was executed", false); } 

If something is wrong with the code using ui elements.

The package name is Tests and the class name is Login , so I run the following command:

adb shell uiautomator runtest TestProject.jar -c Tests.Login

Edit

When I run it on a real device, I get:

uiautomator: permission denied

+4
source share
1 answer

As a first step, you can change the name of the test method to match the standard convention used in JUnit 3 t public void testWhatever() { ... } first 4 letters of the name NITU are "test" in lower case, the signature is public void and the method is not accepts no parameters.

Similarly, you can change the package name to a more standard subordinate convention, for example. org.example.tests If the file is called Tests.java (and a class, also called Tests), then you should be able to call it like this:

adb shell uiautomator runtest Tests.jar -c com.example.tests.Tests

If this does not help, can you reconsider the question to include all the code from your Tests.java file?

Note. I did not try to reproduce the code at this stage when I travel. I can do this if my suggestions do not unblock your problems.

I will follow uiautomator: permission denied separately. UI Automator tests run on real devices. They do not need the device to be implemented. I run them on standard Android 4.2.x devices.

+3
source

All Articles