android 代码功能测试junit test
2015-07-19 00:03
465 查看
1、android 测试代码时候首先需要在manifest里申明服务,主要包括是拷贝2个标签:如下图代码里的红色部分,
instrumentation标签需要与application平级,而uses-library与activity平级。
2、创建一个test类,它继承AndroidTestCase,并且在test功能函数的时候不能传递参数,如下testadd 不能传参,否定不会执行此test函数
instrumentation标签需要与application平级,而uses-library与activity平级。
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.datebase" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <instrumentation android:label="Tests for myapp" android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.example.datebase" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="android.test.runner" /> <activity android:name="com.example.datebase.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> </application> </manifest>
2、创建一个test类,它继承AndroidTestCase,并且在test功能函数的时候不能传递参数,如下testadd 不能传参,否定不会执行此test函数
public class PersonTest extends AndroidTestCase { public void testadd ()throws Exception { System.out.println("start"); Persondao db2=new Persondao(getContext()); db2.add("zhangpeng", 156,12); System.out.println("success"); } }
相关文章推荐
- Android RxJava使用介绍(四) RxJava的操作符
- 说说Android中的ANR
- Android开发超常见的内存泄露以及解决
- Android如何实现毛玻璃效果之Android高级模糊技术
- 推荐几个非常有用的开发工具之Android Studio插件
- Mac下Android studio 之NDK配置教程
- Android 开发有哪些新技术出现?
- Android中Intent的用法介绍
- Android源码编译——Ubuntu 14.10的make3.8、gcc-4.4.7和g++-4.4.7安装方法
- android左右侧滑菜单控件的简易实现
- 我的Android进阶之旅------>四种呼叫转移场景
- Android开发环境搭建
- android 文件存储 Internal storage External storage
- 启动安卓模拟器时出现 The connection to adb is down, and a severe error has occured
- Android TV 视图体系分析
- Android基础入门教程——1.2 开发环境搭建
- Android开发中的menu菜单
- Android手机开机自动启动
- Android enum(枚举类型)使用详解
- 转:Android 设置屏幕不待机