Android Maven 插件执行测试时运行时异常
我是 android maven 插件的新手。我在应用程序内创建了两个测试类。一个类扩展TestCase,另一个类扩展ActivityInstrumentationTestCase2我的活动>。当项目作为 eclipse 中的 android JUnit 测试运行时,所有测试用例都执行良好。没有错误。但是当我尝试从 eclipse 构建项目时,它会在测试类中生成错误。
然而, 在扩展 TestCase 的类中,测试方法也通过 Maven 执行,没有任何错误。但是,如果我尝试创建活动的对象,则会生成错误。 例如:PINLoginController mActivity = new PINLoginController() - 生成初始化错误。
并使用扩展 ActivityInstrumentationTestCase2< 的类MyActivity > 我收到运行时异常。
构造函数中出现异常:testPreconditions(java.lang.RuntimeException:Stub!
任何帮助将不胜感激。 提前致谢
I am new to the android maven plugin. I have created two test classes inside the application. One class extends TestCase and the other class extends the ActivityInstrumentationTestCase2< MyActivity >. When the project runs as the android JUnit test from eclipse all the test cases are executing fine. No errors. But when i try to build the project from eclipse it generates errors in the test classes.
However,
In the class which extends the TestCase the test methods executes without any error through the maven also. But if i try to create an object of an activity it generates an error.
ex: PINLoginController mActivity = new PINLoginController() - generates an initializationError.
And with the class which extends ActivityInstrumentationTestCase2< MyActivity > i get a runtime exception.
Exception in constructor: testPreconditions (java.lang.RuntimeException: Stub!
Any help would be greatly appreciated.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Android 测试用例设计为在 Android 模拟器中运行,因此如果您尝试在常规 Junit 测试运行程序中运行它们,您将会遇到异常。
如果您想自动化测试,您可能想尝试这个:
http://pivotal.github.com/robolectric /
Android test cases are designed to run within an Android emulator, so if you attempt to run them outside in a regular Junit test runner you'll get exceptions.
You might want to try this instead if you want to automate your tests:
http://pivotal.github.com/robolectric/