android下的Juint测试
2015-10-26 15:15
429 查看
安卓下的Junit测试主要分三个步骤:
导入测试类库:在项目的AndriodManiFest.xml配置文件的application中导入测试类库
<!-- 1.导入测试类库 --> <uses-library android:name="android.test.runner"/>
2.配置测试启动类:
在项目的AndriodManiFest.xml配置文件的manifest中配置测试启动类
<!-- 2.配置测试启动类 --> <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.test.junit"></instrumentation>
其中targetPackage为manifest所在的package在AndriodManiFest.xml可以查看
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.junit" android:versionCode="1" android:versionName="1.0" >
3.创建一个测试类:
创建一个测试类,让这个类继承自AndroidTestCase
package com.test.junit.Service.Test; import com.test.junit.Service.PersonService; import android.test.AndroidTestCase; /** * * 3..在Test 包底下创建一个测试类,让这个类继承自AndroidTestCase * @author yuxin * */ public class PersonServiseTest extends AndroidTestCase { public void testGetFirstName() throws Exception { PersonService ps=new PersonService(); ps.getFirstName(); } public void testAdd() throws Exception { PersonService ps=new PersonService(); int actual=ps.Add(2,1); assertEquals(3, actual); } }
具体需要测试哪一个方法可以在Outline中选中该方法右键Debug As>Andriod Junit Test
相关文章推荐
- iOS开发UI篇—Quartz2D简单介绍
- HDU 4027 Can you answer these queries?(线段树)
- UITableViewDelegate_常用
- ios UI tintcolor 与 bartintcolor
- hdu5504 GT and sequence
- burpsuite安装
- [UI界面]-UIImage的拉伸
- 2.ui
- Codeforces Round #327 (Div. 2) (A. Wizards' Duel 简单数学)
- iPhone:动态获取UILabel的高度和宽度
- CodeForces-591A Wizards' Duel
- EasyUI - Datatable转Json and Json转Datatable
- request对象和response对象
- IOS--UITableViewController及UITableView
- IOS--自定义UITableViewCell
- EasyUI - 一般处理程序 返回 Json值
- MUI-图片轮播控件
- IOS--控件UITableView详解
- Set Programming Guide
- MUI-CheckBox的基本介绍