Android的测试驱动开发 [英] Android Test Driven Development

查看:140
本文介绍了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安卓类),但我不能这样做。我通过这个博客<一去href="http://sites.google.com/site/androiddevtesting/">http://sites.google.com/site/androiddevtesting/并通过这种<一个href="http://sdudzin.blogspot.com/2011/01/easy-unit-testing-for-android.html">http://sdudzin.blogspot.com/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 http://sites.google.com/site/androiddevtesting/ and through this http://sdudzin.blogspot.com/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

有关设备的测试,看看<一href="http://www.paulbutcher.com/2011/03/mock-objects-on-android-with-borachio-part-1/">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的测试驱动开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆