Android单元测试的配置
来源:互联网 发布:常见网络端口号 编辑:程序博客网 时间:2024/04/30 12:05
在实际开发中,开发android软件的过程需要不断地进行测试。而使用Junit测试框架,侧是正规Android开发的必用技术,在Junit中可以得到组件,可以模拟发送事件和检测程序处理的正确性..........
第一步:首先在AndroidManifest.xml中加入下面代码:
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="hb.learn.junit"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-sdk android:minSdkVersion="8" />
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <!-- 在本应用中导入需要使用的包,放在application里面activity外面 -->
- <uses-library android:name="android.test.runner" />
- <activity android:name=".JunitTestActivity"
- 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>
- <!-- 记住这个一要放在application外面,不然会出现配置错误 信息 -->
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="hb.learn.junit" android:label="Tests for My App" />
- </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);
- }
- }
0 0
- Android单元测试的配置
- Android单元测试的配置
- Android:单元测试Junit的配置
- Android:单元测试Junit的配置
- Android:单元测试Junit的配置
- Android:单元测试Junit的配置
- Android:单元测试Junit的配置
- Android单元测试Junit的配置
- Android:单元测试Junit的配置
- Android:单元测试Junit的配置
- Android:单元测试Junit的配置
- Android:单元测试Junit的配置
- Android:单元测试Junit的配置
- Android:单元测试Junit的配置
- Android 中 单元测试的配置
- Android:单元测试Junit的配置
- Android:单元测试Junit的配置
- Android配置 常规单元测试
- POJ2371#堆排
- 4 way handshake
- SQL Server 2008 阻止保存要求重新创建表的更改问题的设置方法
- 我可以做的更好,但我不会这么做。
- 五种开源协议的比较
- Android单元测试的配置
- Python的50个模块,满足你各种需要
- HBase性能优化方法总结(二):写表操作
- C++ 在线编译器(支持 C++11)
- java学习笔记3--java语言基础
- HBase性能优化方法总结(三):读表操作
- UISearchDisplayController 自定义取消按钮标题
- SDWebImage的基本使用
- oracle数据库连接器