Android单元测试框架Robolectric.zip

时间:2022-08-08 09:55:21
【文件属性】:

文件名称:Android单元测试框架Robolectric.zip

文件大小:2.91MB

文件格式:ZIP

更新时间:2022-08-08 09:55:21

开源项目

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!")); } } 标签:Robolectric


网友评论