protected void setUp() throws Exception {
inst = getInstrumentation();
solo = new Solo(inst,getActivity());
super.setUp();
}
protected void tearDown() throws Exception {
solo.finishOpenedActivities();
super.tearDown();
}
public void testAddNote(){
solo.sleep(3000);
View menuadd = solo.getView("menu_add");
solo.clickOnView(menuadd);
solo.sleep(2000);
solo.enterText(0, "Note1");
solo.sleep(2000);
View menusave = solo.getView("menu_save");
solo.clickOnView(menusave);
ListView list = (ListView)solo.getView("list");
TextView tv = (TextView)solo.getView("tv");
Assert.assertEquals(true, tv.getText().equals("Note1"));
}
public void testdeleteNote(){
ListView list = (ListView)solo.getView("list");
int beforecount = list.getChildCount();
Log.d("debug", "beforeCount:"+beforecount);
solo.sleep(2000);
solo.clickOnView(list.getChildAt(0));
solo.clickOnText("delete");
solo.sleep(3000);
int aftercount = list.getChildCount();
Log.d("debug", "beforeCount:"+aftercount);
Assert.assertEquals("删除笔记后数目没有减少", 1,beforecount-aftercount);
}
}
Run as android JUnit Test控制台就会报这个错误:
Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'。 作者: lsekfe 时间: 2015-1-8 13:01