Android JUnit Test

android debug , junit test , log,这几个在开发中经常要用到的,需要掌握一下 。

关于Android JUnit Test在eclipse下的配置

AndroidManifest.xml中写两个

  • 1 application里面加上
    <!-- android junit 调试用 -->
        <uses-library android:name="android.test.runner" />
  • 2 application外加上
  <!-- android junit test targetPackage 测试包 填主包名就行-->
  <instrumentation  android:name="android.test.InstrumentationTestRunner" android:targetPackage="包名" />   
测试类直接继承AndroidTestCase

public class BasicHttpClientTest extends AndroidTestCase

测试类中的方法 不用加上类似junit的 @Test ,直接些void方法
public void testHttpGet() {
    //具体测试操作 http什么的可以直接这里访问测试
}  
然后直接把这个方法run as 或 Debug as Android JUnit Test 就行了

你可能感兴趣的:(android,test)