Android 测试工具集02

Robotium自动化测试
本文介绍了一种用于Android应用的功能性和用户界面自动化测试框架——Robotium。Robotium支持原生及混合应用测试,允许测试开发者编写跨越多个Android活动的强大的、健壮的自动黑盒UI测试案例。

User scenario testing for Android(功能性测试框架)

Robotium is an Android test automation framework that has full support for native and hybrid applications. Robotium makes it easy to write powerful and robust automatic black-box UI tests for Android applications. With the support of Robotium, test case developers can write function, system and user acceptance test scenarios, spanning multiple Android activities.

See Questions & Answers for common Robotium questions and answers. 

See Getting Started for instructions and examples on how to create your first Robotium tests. 

Join the discussions in the Robotium Developers Group.

robotium wiki:http://code.google.com/p/robotium/w/list

 

这里有篇文章对于robotium的介绍很贴切:robotium 是 android 自带类 Instrumentation 的一个封装,方便测试人员直接调用封装好的接口,也就是说,实际上我们直接使用Instrumentation 也能够进行自动化测试,但robotium可以简化我们的测试步骤,我们只需要调用某个robotium的API,传几个参数,就等于我们在调用一部分的Instrumentation帮我们实现测试。robotium 就是富二代!!高帅富!!

http://www.51testing.com/?uid-22381-action-viewspace-itemid-238847

 

需要注意:

1.测试项目:例如:HelloWorldTest,Build Path需要导入robotium-solo.jar包

2.Eclipse:3.7 版本,需要勾选Order and Export中的内容

 

    1. package com.luwenjie.helloworld.test; 
    2.  
    3. import android.test.ActivityInstrumentationTestCase2; 
    4. import com.luwenjie.helloworld.HelloWorldActivity; 
    5. import com.jayway.android.robotium.solo.Solo; 
    6.  
    7. public class HelloWorldTest extends ActivityInstrumentationTestCase2
    8. <HelloWorldActivity>{ 
    9.  
    10.     private Solo solo; 
    11.  
    12. //需要测试的app是什么?
    13. //这里需要测试com.luwenjie.helloworld包下的HelloWorldActivity这个应用
    14.  
    15.     public HelloWorldTest(){ 
    16.          super("com.luwenjie.helloworld", HelloWorldActivity.class); 
    17.     } 
    18.    
    19. //打开HelloWorld这个应用
    20.  
    21.     public void setUp() throws Exception{ 
    22.          solo = new Solo(getInstrumentation(), getActivity()); 
    23.     } 
    24.  
    25. //执行测试
    26. //searchText(String str):验证字符串是否存在
    27.  
    28.     public void testUI() throws Exception { 
    29.         boolean expected = true; 
    30.         boolean actual = solo.searchText("Hello") && solo.searchText("World"); 
    31.  
    32.         assertEquals("This and/or is are not found", expected, actual); 
    33.     } 

    34.  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值