Android 项目添加单元测试
来源:互联网 发布:网络规划设计师 没人考 编辑:程序博客网 时间:2024/04/30 00:46
Android 单元测试
修改配置文件:AndroidManifest.xml
1.在<application> 中添加 引入单元测试包
<uses-library android:name="android.test.runner"/>
2.在<manifest>中添加测试<instrumentation android:name="android.test.InstrumentationTestRunner"android:targetPackage="com.yueking.callocation"/>配置文件 整体像这样:<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.yueking.callocatioin" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="15"/> <application android:label="@string/app_name" android:icon="@drawable/ic_launcher"> <activity android:name="MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <span style="color:#ff0000;"> </span><span style="background-color: rgb(255, 0, 0);"><uses-library android:name="android.test.runner"/></span> </application> <span style="background-color: rgb(255, 0, 0);"><instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.yueking.callocatioin"/></span></manifest>3.最后编写测试用类,并 继承至 android.test.AndroidTestCase即可测试中打印日志 用 Log.i(String,String) 方法
实例代码:
<pre name="code" class="java">package com.yueking.callocatioin.service;import android.test.AndroidTestCase;import android.test.AndroidTestRunner;import android.util.Log;public class PersonServiceTest extends AndroidTestCase { static String tag = "yueking"; public void setUp() throws Exception { } public void testGetLocation() throws Exception { Log.i(tag, "hello yueking"); }}
0 0
- Android 项目添加单元测试
- android 添加单元测试配置
- 添加Silverlight单元测试项目模板
- 添加Silverlight单元测试项目模板
- Android项目中的单元测试
- Android项目中进行单元测试
- ubuntu 下android项目单元测试
- android项目开发之单元测试
- Android官方MVP项目单元测试
- Android添加单元测试的方法与步骤
- 在Android项目里如何构建单元测试
- android如何在项目中进行单元测试
- 解读Android官方MVP项目单元测试
- 解读Android官方MVP项目单元测试
- Android项目中的单元测试(Junit4)
- 解读Android官方MVP项目单元测试
- 解读Android官方MVP项目单元测试
- 解读 Android 官方 MVP 项目单元测试
- (九)洞悉linux下的Netfilter&iptables:网络地址转换原理之DNAT
- 《编码:隐匿在计算机软硬件背后的语言》读书笔记 04
- iOS 本地可以构造假数据,并转换为json数据
- AndroidManifest.xml中定义的application name的作用
- 使用CImage进行图像处理
- Android 项目添加单元测试
- time函数
- (十)洞悉linux下的Netfilter&iptables:网络地址转换原理之SNAT
- Struts2学习笔记——Action
- 如何编程旋转,镜像Revit实体(含美国AU的故事)
- HDOJ 题目1869 六度分离(最短路)
- iOS疯狂详解之自动布局(autolayout)下图片编辑器的实现
- (十一)洞悉linux下的Netfilter&iptables:iptables命令行工具源码解析【上】
- 各种字符集编码