求Robotium大神解决一下这个新手问题啊
------------------------------Android Launch!
adb is running normally.
Performing android.test.InstrumentationTestRunner JUnit launch
Automatic Target Mode: using device 'bb75902e'
Uploading NotePadTest.apk onto device 'bb75902e'
Installing NotePadTest.apk...
Success!
Project dependency found, installing: NotePad
Application already deployed. No need to reinstall.
Launching instrumentation android.test.InstrumentationTestRunner on bb75902e
Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
百度里面的原因我都排查了一下 ,都不是呀。。我按照视频写的代码一模一样都会这样报错。
建议你把问题描述的清晰一点。。。 lsekfe 发表于 2015-1-8 09:18
建议你把问题描述的清晰一点。。。
就是用Robotium框架写了一个关于eclipse自带例子NotePad的测试用例,测试用例代码如下:
package com.example.android.notepad.test;
import junit.framework.Assert;
import com.robotium.solo.Solo;
import android.app.Activity;
import android.app.Instrumentation;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
public class NotePadTest extends ActivityInstrumentationTestCase2 {
private static final String Launcher_Avtivity_Full_ClassName = "com.example.android.notpad.NotesList";
private static Class<?> launcherActivityClass;
private Solo solo;
private Activity activity;
private Instrumentation inst;
static {
try{
launcherActivityClass = Class.forName(Launcher_Avtivity_Full_ClassName);
}catch (ClassNotFoundException e){
throw new RuntimeException(e);
}
}
public NotePadTest() {
super(launcherActivityClass);
}
protected static void setUpBeforeClass() throws Exception {
}
protected static void tearDownAfterClass() throws Exception {
}
public Activity getActivity(){
return super.getActivity();
}
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'。
Conrad 发表于 2015-1-8 10:10
就是用Robotium框架写了一个关于eclipse自带例子NotePad的测试用例,测试用例代码如下:
package com.ex ...
从代码上看,感觉上是冲突了。你仔细看下~ 楼主解决了么?我也遇到同样问题。。已经解决的话能指点一下么?谢谢~
页:
[1]