android Junit demo

package com.sondon.dhjk.test;

import com.sondon.dhjk.utils.LogUtil;

import junit.framework.TestCase;

public class Test extends TestCase {

	private static final String TAG = "Test";
	/**
	 * 构造函数
	 * @param name
	 */
	public Test(String name) {
		super(name);
	}
	public void testMytest(){
		LogUtil.i(TAG, "测试方法");
	}
	/**
	 * Sets up the fixture, for example, open a network connection. This method
	 * is called before a test is executed.
	 */
	protected void setUp() throws Exception {
		super.setUp();
		LogUtil.i(TAG, "setUp");
	}

	/**
	 * Tears down the fixture, for example, close a network connection. This
	 * method is called after a test is executed.
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
		LogUtil.i(TAG, "tearDown");
	}

}

Androidmanifest.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="<span style="font-family: Arial, Helvetica, sans-serif;">com.sondon.dhjk</span><span style="font-family: Arial, Helvetica, sans-serif;">"</span>
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <uses-library android:name="android.test.runner"/> <!--不可修改-->
        <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>
    </application>
    <instrumentation android:name="android.test.InstrumentationTestRunner" <!--不可修改-->
	android:targetPackage="<span style="font-family: Arial, Helvetica, sans-serif;">com.sondon.dhjk</span><span style="font-family: Arial, Helvetica, sans-serif;">" <!--跟package包名相同--></span>
	android:label="Testing"><!--可写可不写-->
	</instrumentation>
</manifest>

log日志:

android Junit demo,布布扣,bubuko.com

时间: 2024-08-05 00:29:13

android Junit demo的相关文章

在Android Studio进行“简单配置”单元测试(Android Junit)

起因 在Android studio 刚出.本人就想弄单元测试,可惜当时Android studio不知道抽什么风(准确来说,应该是我不会弄而已).无法执行到相应的代码.后来今天突然自己又抽风.又想去弄一下Android junit. 本文基于做过Eclipse开发使用过Android junit,如果Eclipse的Android Junit没有使用过,就我没有说过吧! 准备环境,配置 官网Demo地址:https://github.com/googlesamples/android-test

android junit 测试 简要步骤

android junit 测试 1.新建一个类继承TestCase这个类 2.AndroidManifest.xml, 加入<uses-library android:name="android.test.runner" /> <!-- 记住这个一要放在application外面,不然会出现配置错误 信息 -->      <instrumentation android:name="android.test.InstrumentationTe

1.Android JUnit Runner(使用AndroidStudio)

一.Android JUnit Runner介绍 1.Android JUnit Runner 1)是一个测试运行器,用于运行Junit3和Junit4的Android测试包 2)替换Instrumentation Test Runner(一个比较旧的测试运行器) 3)支持Instrumentation Test Runner所有特性,但又进行了扩展 4)保持了所有Instrumentation Test Runner的命令格式 2.继承关系 java.lang.Object android.a

android junit 测试程序

http://blog.csdn.net/to_cm/article/details/5704783 Assert.assertEquals(2, t); 断言 android junit 测试程序,布布扣,bubuko.com

Android Junit测试框架

对应用进行单元测试: 使用Junit测试框架,是正规Android开发的必用技术.在Junit中可以得到组件,可以模拟发送事件和检测程序处理的正确性. 1.配置指令集和函数库: (1)配置指令集,指定要测试的应用程序 需要在AndroidManifest.xml的instrumentation中增加InstrumentationTestRunner,并指定要测试的包名. AndroidManifest.xml中会添加代码: <instrumentation android:targetPacka

百度地图SDK for Android【Demo兴趣点搜索】

百度地图SDK为开发者提供了便捷的检索服务.今天我将为大家介绍Poi检索相关的内容. 首先,我们要构建一个最基本的地图应用,具体介绍请参考:百度地图SDK for Android[Demo地图展示] 在这个工程的基础之上我们做一定的修改. 第一步,修改布局文件,添加关键字输入框和用于执行搜索操作的按钮.代码如下: [html] view plaincopy <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/a

Android JUnit Test——批量运行测试代码

写Android测试用例有三要素,一是我们用的“安卓模拟器device”(用来显示UI),二是“uiautomatorviewer.bat”(用来定位UI上的元素),三是“Robotium”中提供的类(用来与UI元素进行交互).在写好Android的测试用例后,可通过Android JUnit Test批量运行测试代码.一共分四步—— 第一步:写一个suite类(suite中包含指定的测试用例,如下把SendInfoTest类作为一个测试用例添加进了suite中,LoginTest这个类由于被注

Android Junit测试框架的配置

instrumentation指令集需要在manifest节点下 <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.example.junittest" /> uses-library 需要在application节点下 <uses-library android:name="android.t

Android Service demo例子使用详解

Android Service demo例子使用详解\ 概述Service 是 Android 的四大组件之一,它主要的作用是后台执行操作,Activity 属于带有 UI 界面跟用户进行交互,而 Service 则没有 UI 界面,所有的操作都是基于后台运行完成.并且 Service 跟 Activity 一样也是可以由其它的应用程序调用启动的,而且就算用户切换了应用程序,Service 依旧保持运行.一个组件如果与 Service 进行了绑定( bind ),就可以跟 Service 进行数