eclipse中android单元测试
来源:互联网 发布:mac如何安装flash插件 编辑:程序博客网 时间:2024/05/16 15:43
说说正常的代码吧
1)
1:java测试类
<span style="font-size:14px;">package com.medivh.app;public class Person{public String sub(String username){String sub = username.substring(3);return sub;}public int add(int a,int b){return a+b;}}</span>2:
<span style="font-size:14px;">package com.medivh.app;import org.junit.Test;import junit.framework.Assert;import android.test.AndroidTestCase;public class PersonTest extends AndroidTestCase{@Testpublic void testSub() throws Exception{Person p = new Person();p.sub(null);}public void testAdd() throws Exception{Person p = new Person();int result = p.add(1, 4);Assert.assertEquals(result, 6);}}</span>
2)AndroidManifest.xml
<span style="font-size:14px;"><?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.medivh.app" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name"> <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;"><uses-library android:name="android.test.runner" /></span> </application> <uses-sdk android:minSdkVersion="8" /><span style="color:#FF0000;"><instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.medivh.app" android:label="Tests for My App" /></span></manifest> </span>3)测试
右键项目Run as.. Android Junit Test 就会出结果
开始的时候犯迷糊结果各种出错:
No instrumentation runner found for the launch, using android.test.InstrumentationTestRunner
First does not specify a android.test.InstrumentationTestRunner instrumentation or does not declare uses-library android.test.runner in its AndroidManifest.xml
is not configured correctly for running tests
到网上各种查,发现配置没错啊。最后才发现问题出在我居然眼睛进沙子一般修改了bin下面的AndroidManifest.xml,可能是我前面打开了这个目录,结果就随意打开了它修改了它。希望大家以后小心行事。
0 0
- eclipse中android单元测试
- eclipse中和android studio中进行单元测试
- Eclipse 中android调用JUnit进行单元测试
- Android开发之在Eclipse中单元测试,在Class中进行单元测试与Activity中单元测试
- Android单元测试-Eclipse+JUnit
- Android学习 Eclipse Android 单元测试
- 4、Android中单元测试
- android中junit单元测试
- Android开发基础之Eclipse单元测试
- Android studio及eclipse中的junit单元测试
- 在Eclipse中使用JUnit进行单元测试
- 在Eclipse中使用JUnit进行单元测试
- 在Eclipse中使用JUnit进行单元测试
- Eclipse中使用JUnit插件做单元测试
- Eclipse中使用JUnit4进行单元测试
- 在Eclipse中使用JUnit4进行单元测试
- 在Eclipse中使用JUnit4进行单元测试
- 在Eclipse中使用JUnit4进行单元测试
- Java对象池技术的原理及其实现
- esqw掏纪号纪迷迂惶naoqi
- 【项目1-动物这样叫】
- 14周项目一动物这样叫
- 非常高效的文件处理 API 和 CFile 的使用详解
- eclipse中android单元测试
- PostgreSQL 中 index scan 与 seq scan 的对比学习
- android_wifi读书笔记之3-JNI层 分析
- Linux程序设计-mmap使用
- JAVA学习随记1
- android_wifi读书笔记之4-HAL层分析
- linux 比较文件相同部分comm命令和不同部分diff命令
- 推荐一个比较好的.net论坛,http://bbs.netluntan.com
- 多参多线程