Android tests are not executed

谁说我不能喝 提交于 2019-12-10 16:12:50

问题


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

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

I have uploaded the jar file in the android virtual device and now I'm 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 have also created a simple test with the following code:

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

In case there is something wrong with the code using ui elements.

The package name is Tests and the class name 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


回答1:


As a first step, can you change the name of the test method to match the standard convention used in jUnit 3 i.e. public void testWhatever() { ... } the first 4 letters of the name nust be 'test' in lower case, the signature is public void and the method does not take any parameters.

Similarly, can you change the package name to the more standard lowercase convention e.g. org.example.tests If you file is called Tests.java (and the class also called Tests) then you should be able to call it as follows:

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

If these don't help, please can you revise the question to include the entire code from your Tests.java file?

Note: I've not tried to reproduce your code at this stage as I'm travelling. I can do so if my suggestions don't unblock your problem(s).

I'll follow up on the uiautomator: permission denied separately. UI Automator tests do run on real devices. They don't need the device to be rooted. I run them on standard Android 4.2.x devices.



来源:https://stackoverflow.com/questions/15971426/android-tests-are-not-executed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!