qileilove

blog已经转移至github,大家请访问 http://qaseven.github.io/

Android单元测试框架 Robolectric

 Android开发者们注意了,这款测试框架一定会让你们兴奋不已,因为它是一款已基本上摆脱了模拟器测试的老套路的速率单元测试框架Robolectric可以解压Android SDK,还能直接对应用进行测试,从而帮你轻而易举地解决所遇到的任何问题。
  Robolectric 是一款Android单元测试框架,示例代码:
@RunWith(RobolectricTestRunner.class)
public class MyActivityTest {
@Test
public void clickingButton_shouldChangeResultsViewText() throws Exception {
Activity activity = Robolectric.buildActivity(MyActivity.class).create().get();
Button pressMeButton = (Button) activity.findViewById(R.id.press_me_button);
TextView results = (TextView) activity.findViewById(R.id.results_text_view);
pressMeButton.performClick();
String resultsText = results.getText().toString();
assertThat(resultsText, equalTo("Testing Android Rocks!"));
}
}

posted on 2014-12-23 00:08 顺其自然EVO 阅读(440) 评论(0)  编辑  收藏 所属分类: android


只有注册用户登录后才能发表评论。


网站导航:
 
<2014年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜