首页 > android studio如何用AndroidTestCase测试呢?出错

android studio如何用AndroidTestCase测试呢?出错

按照这种教程,还是出很多问题

第一步:首先在AndroidManifest.xml中加入下面红色代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.lee0000.test" android:versionCode="1" android:versionName="1.0">

<application android:icon="@drawable/icon" android:label="@string/app_name">

    <uses-library android:name="android.test.runner"/> 

</application>

<use-sdk android:minSdkVersion="6"/>

<instrumentation android:name="android.test.instrumentationTestRunner" android:targetPackage="com.lee0000.test" android:label="Tests"/> 

 ***上面targetPackage指定的包要和应用的package相同。

出现问题是:
当新建如下程序的时候,出错:

package com.china.anonymous.demodemo;

import android.test.AndroidTestCase;

/**
 * Created by Anonymous on 2016/1/30.
 */
public class MyTest extends AndroidTestCase {


        public void show(){

                System.out.println("this is a get");
        }

}

java.lang.RuntimeException: Method setUp in android.test.AndroidTestCase not mocked

怎么回事呢?

【热门文章】
【热门文章】