Android应用程序的调试方法
来源:互联网 发布:淘宝换购什么意思啊 编辑:程序博客网 时间:2024/05/16 06:15
Android有时候我们需要调试或者测试一个类是否正确,我们可以使用如下方法。以下面的程序为例,我们测试下面的Person类是否正确。
package com.heima.junit;public class Person {public void eat() {System.out.println("eat ....");}public int divide(int i, int j) {return i/j;}}我们很容易看出Person类的divide()成员方法的第二个参数不能为0,假设我们不知道。
第一步:写个类去继承 AndroidTestCase 类
package test;import com.heima.junit.Person;import android.test.AndroidTestCase;public class testPerson extends AndroidTestCase {public void test1() {Person p = new Person();p.eat();System.out.println(p.divide(2, 1));}public void test2() {Person p = new Person();p.eat();System.out.println(p.divide(2, 0));}}
第二步:清单文件manifest中, 添加instrumentation 指令集
<instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.heima.junit" />第三步:继续在清单 文件application中,添加 uses-library
<uses-library android:name="android.test.runner" />
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.heima.junit.test" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.heima.junit" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <uses-library android:name="android.test.runner" /> </application></manifest>
按以下方法执行:
阅读全文
0 0
- Android应用程序的调试方法
- Android应用程序的调试
- 调试 Android* x86 应用程序的方法以及要使用的工具
- Windows应用程序调试方法
- Windows应用程序调试方法
- 解决android应用程序不能调试的问题
- Android* 操作系统上的应用程序远程调试
- Android* 操作系统上的应用程序远程调试
- Android* 操作系统上的应用程序远程调试
- Android* 操作系统上的应用程序远程调试
- Android* 操作系统上的应用程序远程调试
- android 应用程序全屏的方法
- Android 关闭应用程序的方法
- android应用程序调试
- android 应用程序调试
- android 应用程序调试-03
- Android调试应用程序
- GDB调试开发板上的应用程序的方法
- ConcurrentHashMap原理
- C语言中三目运算符的结合性问题
- java排序之 --- 冒泡排序
- PROGRESSIVE GROWING OF GANS FOR IMPROVED QUALITY, STABILITY, AND VARIATION
- golang基础-go对数据库的增删改查操作
- Android应用程序的调试方法
- 单例模式
- proc文件系统
- 如何将word转化为pdf(Java版)
- Android内核开发:图解Android系统的启动过程
- 史上最便宜的OpenMV 2 OpenMV3
- 【小白的CFD之旅】13 敲门实例【续3】
- 系统间通信方式之(ActiveMQ的集群方案介绍上)(十七)
- udev的工作过程