重新编辑发帖,新人求指点,自己按照网上各种资料,写了一段代码,就是对安装在虚拟机中的一个 debug 版的 apk 软件,进行点击 “注册” 按钮的一个小动作,但是 run as “Android Junit Test” 时报脚本有问题,不知道需要修改啥?导入的是:robotium-solo-5.2.1.jar

package com.asiainfo.ha.kq.activity.test;
//import com.jayway.android.robotium.solo.Solo;
import com.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;

public class AndroidTest001 extends ActivityInstrumentationTestCase2
{   
    private Solo solo;

    private static final String TARGET_PACKAGE_ID ="com.asiainfo.ha.kq.activity";

    private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME ="com.asiainfo.ha.kq.activity.WelcomeActivity";

    private static Class launcherActivityClass;

    //private static final int Sleeptime1 = 120000;

    static
    {
    try    
      { 
        launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
      } 
    catch(ClassNotFoundException e) 
      {
        throw new RuntimeException(e);
      }
    }

    public AndroidTest001()
    {
        super(TARGET_PACKAGE_ID,launcherActivityClass);

    }

    //定义一个Solo对象

    protected void setUp()throws Exception 
    {
    solo= new Solo(getInstrumentation(),getActivity());
    }


    //这是自己定义的一个测试case,只是简单进入界面,点击一下两个选项

    public void test_Watch_001(){
    //solo.sleep(Sleeptime1);
    solo.clickOnText("注册");
    //solo.sleep(Sleeptime1);
    solo.goBack();

    }

    public void tearDown()throws Exception
    {
    try
       { 
        solo.finalize();
       }
    catch(Throwable e)
       {
        e.printStackTrace();
       }
    getActivity().finish();
    super.tearDown();
    }

}

然后点击项目的 “Android Junit Test” 进行运行,“Console” 提示:

[2014-09-19 14:52:26 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/robotium/solo/ActivityUtils$1;
[2014-09-19 14:52:26 - KaoQinTest] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/robotium/solo/ActivityUtils$1;

eclipse 中,工程的文件如下:

还请老师们,能够指点下,虚拟机是 android4.4 版本的


↙↙↙阅读原文可查看相关链接,并与作者交流