robotium



 被测工程为android自动拨打电话http://blog.csdn.net/zm_21/article/details/40508959.

所以程序运行后,可以看到电话自动拨出

  1. New android test project andchoose Junit4

  2. Right click project -> ChooseBuild path -> Choose Configure Build Path.

  3. Add  JUnit4 and robotium-solo-5.2.1.jar andandroid-support-v4.jar (E:\tools\adt-bundle-windows-x86-20140624\sdk\extras\android\support\v4) to Libraries and "Order and Export".

Notice: If not add android-support-v4.jar,there is error “Test run failed: Instrumentation runfailed due to 'java.lang.ClassNotFoundException'”

 

 

 

 

  1. In AndroidManifest.xml, thereis the below:

   

   <uses-permission android:name="android.permission.RUN_INSTRUMENTATION"/>

 

   <instrumentation

       android:name="android.test.InstrumentationTestRunner"

       android:targetPackage="com.example.testandroid1"/>

 

   <application

       android:icon="@drawable/ic_launcher"

       android:label="@string/app_name">

       <uses-libraryandroid:name="android.test.runner"/>

   </application>

 

  1. Add test code

 

import android.test.ActivityInstrumentationTestCase2;

import com.robotium.solo.Solo;

import com.example.testandroid1.MainActivity;

// com.example.testandroid1:packagename,

// MainActivity:class name

 

 

publicclassCallTestextendsActivityInstrumentationTestCase2 {

   

   private Solo solo;//声明Solo

   

   public CallTest()

   {

       super(MainActivity.class);

   }

   

   @Override

   public void setUp()throwsException

   {                                                    

       solo =newSolo(getInstrumentation(), getActivity());  

   }                                                       

                                                               

   @Override   

   public void tearDown()throwsException

   {

       solo.finishOpenedActivities();  

   }

                                    

   @Test

   publicvoid test() {

       solo.clickOnMenuItem("Button");

   }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值