Android的测试驱动开发

编程入门 行业动态 更新时间:2024-10-09 17:27:53
本文介绍了Android的测试驱动开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在做Android应用程序相当丰富的经验。对于我的新项目,我们决定做测试驱动开发(TDD)。我已经让我的手在Robotium湿的用户场景测试,并能正常工作,看起来很容易。

I have considerable experience in making Android applications. For my new project, we have decided to do Test Driven Development (TDD). I have been getting my hands wet on Robotium for User Scenario Testing, and it works fine and looks easy too.

有关单元测试,我试着用嘲笑上下文(MockContext安卓类),但我不能这样做。我通过这个博客sites.google/site/androiddevtesting/并通过这种sdudzin.blogspot/2011/01/easy-unit-testing-for-android.html ,这表明在嘲讽Android应用程序仍然是非常有限的,硬,并建议使用PowerMock,jMockit,JeasyTest,或Roboelectric(与的Mockito和Maven的组合),甚至RoboGuice。

For unit testing, I tried to mock Context using (MockContext Android Class) but I am unable to do so. I went through this blog sites.google/site/androiddevtesting/ and through this sdudzin.blogspot/2011/01/easy-unit-testing-for-android.html , which suggests that mocking in Android apps is still very limited and hard, and have suggested to use PowerMock, jMockit, JeasyTest, or Roboelectric (in combination with Mockito and Maven) and even RoboGuice.

我希望得到你们哪个在您看来,单元测试框架是最好的测试Android应用程序的任何建议。 (特别是测试机器人类,可能给模拟上下文和其他嘲讽功能,这样我可以让我的测试案例尽可能独立)。任何建议或指针会很有帮助。谢谢

I would like to get any suggestions from you guys on which unit testing framework in your opinion is the best for testing Android applications. (particularly testing Android classes, possibly giving mock Contexts and other mocking features so that I can make my test cases as independent as possible). Any suggestions or pointers would be helpful . Thanks

推荐答案

有关关闭设备的测试,看看 Robolectric

For off-device testing, look at Robolectric

有关设备的测试,看看Borachio

底线:它仍然是非常非常困难的事很好。情况正在好转(显着提高今天比10个月前的情况),但Android是舒服,我曾经编写的程序在大多数测试恶劣的环境。

Bottom line: it's still very, very difficult to do well. Things are improving (the situation is dramatically better today than it was 6 months ago) but Android is comfortably the most test-hostile environment I've ever written programs for.

更多推荐

Android的测试驱动开发

本文发布于:2023-11-23 07:10:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620562.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:测试   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!