简体   繁体   中英

UIAutomator error when runnging tests

I am having big problemes with the uiautomator from google. I have a S3 not rooted and I can't run my tests on the device.
Error:

INSTRUMENTATION_RESULT: shortMsg=java.lang.RuntimeException
INSTRUMENTATION_RESULT: longMsg=com.test1.test
INSTRUMENTATION_CODE: 0

I saw some answers that pointed me to root the phone. I do not want to do that.
Please give me some answers how to use the tests.

I was having this same issue! I'm not 100% sure why it was happening, but I think it has to do with the way ant builds the JAR file. When I first started writing my uiautomation tests, I put them in the same project as some JUnit tests, which were in separate packages (one for the source classes and one for the tests). I created my uiautomation tests in the test package, and when I went to build and run them, I got an error that my test classes weren't being found.

I believe this was because the JAR file only included the source package and not the test package. So, I made a new project and put my uiautomation tests in a single source package, built the project, and pushed the JAR to my device. They ran smoothly after that!

I'm pretty new to this stuff too, so I'm not entirely sure if that answers your question. An alternative solution might be to move the UIA tests to the source package instead of creating a whole new project.

Also, Google's resources are really good for getting a basic feel for setting up and using uiautomation (if you haven't checked them out already). If you really can't find a fix, I'd recommend copying and pasting their demo into a fresh project and trying to get that to run: http://developer.android.com/tools/testing/testing_ui.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM