• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

软件测试之Android单元测试

发布: 2009-12-21 11:17 | 作者: 不详 | 来源: 领测国际测试网采编 | 查看: 1677次 | 进入软件测试论坛讨论

领测软件测试网

  *

  * @Override

  * protected void setUp() throws Exception {

  * String tag = "setUp";

  * Log.e(tag, "init all var....");

  * newActivity = getActivity();

  * button1 = (Button) newActivity.findViewById(R.id.Button01);

  * button2 = (Button) newActivity.findViewById(R.id.Button02);

  * }

  * /**

  * * Testing the button is focused or not

  * */

  * public void testButtonFocus() {

  * String tag = "testButtonFocus";

  * Log.e(tag, "start the button focus...");

  * assertTrue("Button1 is focused", button1.isFocused());

  * Log.e(tag, "send the down key event...");

  * sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);

  * assertTrue("Button2 is focused", button2.isFocused());

  * }

  *

  * /**

  * * Testing the add method in actvity

  * */

  * public void testAdd(){

  * String tag ="testAdd";

  * Log.e(tag, "Test the add method in NewActivity...");

  * int i = newActivity.add(2, 5);

  * assertEquals(7, i);

  * }

  *

  * }

  五、配置Manifest.xml文件

Java代码

复制代码

  *

  *

  * package="cc.androidos.activity" android:versionCode="1"

  * android:versionName="1.0">

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  * android:label="Test New Activty" android:name="android.test.InstrumentationTestRunner">

  *

  *

  *

  * package="cc.androidos.activity" android:versionCode="1"

  * android:versionName="1.0">

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  *

  * android:label="Test New Activty" android:name="android.test.InstrumentationTestRunner">

  *

Java代码

复制代码

  # E:\android\android-sdk-windows-1.5_pre\tools>adb shell am instrument -w cc.andro

  # idos.activity/android.test.InstrumentationTestRunner

  # 如果你配置了Android环境变量,直接使用:

  # adb shell am instrument -w cc.androidos.activity/android.test.InstrumentationTestRunner

  # 语法:adb shell am instrument -w <被测试的类的包名>/android.test.InstrumentationTestRunner

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网