简体   繁体   English

进行测试时出现UIAutomator错误

[英]UIAutomator error when runnging tests

I am having big problemes with the uiautomator from google. 我在使用google的uiautomator时遇到了大问题。 I have a S3 not rooted and I can't run my tests on the device. 我的S3没有扎根,无法在设备上运行测试。
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. 我不是100%知道为什么会这样,但是我认为这与ant构建JAR文件的方式有关。 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). 刚开始编写uiautomation测试时,我将它们与某些JUnit测试放在同一个项目中,这些测试位于单独的程序包中(一个用于源类,另一个用于测试)。 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. 我在测试包中创建了uiautomation测试,当我去构建和运行它们时,出现一个错误,提示找不到我的测试类。

I believe this was because the JAR file only included the source package and not the test package. 我相信这是因为JAR文件仅包含源软件包,而不包含测试软件包。 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. 因此,我创建了一个新项目,并将uiautomation测试放在一个源代码包中,构建了该项目,然后将JAR推送到我的设备上。 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. 一种替代解决方案可能是将UIA测试移至源包,而不是创建一个全新的项目。

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). 另外,Google的资源非常适合于基本了解设置和使用uiautomation的感觉(如果您尚未将它们签出的话)。 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 如果您确实找不到修复程序,建议您将其演示复制并粘贴到新项目中,然后尝试使其运行: http : //developer.android.com/tools/testing/testing_ui.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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