Android单元测试
来源:互联网 发布:网络安全法宣传视频 编辑:程序博客网 时间:2024/04/28 10:11
实际开发中,开发android软件的过程需要不断地进行测试。而使用Junit测试框架,侧是正规的Android开发的必用技术,在Junit中可以得到组件,可以模拟发送事件和检测程序处理的正确性。
第一步:首先在AndroidManifest.xml中加入下面黑体代码:
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
package="cn.itcast.action“ android:versionCode="1“ android:versionName="1.0">
<applicationandroid:icon="@drawable/icon"android:label="@string/app_name">
<uses-libraryandroid:name="android.test.runner" />
....
</application>
<uses-sdkandroid:minSdkVersion="6" />
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="应用的package " android:label="标签可以随意取值 "/>
</manifest>
上面targetPackage指定的包要和应用的package相同。
第二步:编写单元测试代码(选择要测试的方法,右键点击“Run As”--“Android Junit Test” ):
import android.test.AndroidTestCase;
import android.util.Log;
public class XMLTest extends AndroidTestCase{
public void testSomething() throws Throwable {
Assert.assertTrue(1+ 1 == 3);
}
}
- android 单元测试
- Android单元测试
- Android单元测试
- android单元测试
- Android单元测试
- Android单元测试
- android单元测试
- android单元测试
- Android单元测试
- Android单元测试
- android 单元测试
- android 单元测试
- Android--单元测试
- android单元测试
- Android单元测试
- Android单元测试
- Android单元测试
- ANDROID 单元测试
- 什么是GIS
- 快速锁定桌面
- 多系统启动
- 病毒测试文件
- 为什么要用GIS
- Android单元测试
- 如何做GIS分析
- 如何在SQL语句中动态显示信息的状态
- php中fastcgi两种运行模式 spawn-fcgi和php-fpm
- S3c2410 LCD驱动学习心得
- Excel.Application使用手册
- linux下如何运行.sh文件
- ssh项目开发中细节拾遗7.6(配置文件、命名空间跳转、)
- Google Earth