我试图创建一个扩展AndroidTestCase的单元测试来测试BroadcastReceiver。 在测试中我是:
当我点击调试为Android JUnit测试时,它启动模拟器(启动良好且可用)启动,然后它以27%挂起尝试启动实际测试并且它永远不会发生。
我做错了什么?
编辑,代码段
public class RemoteControlReceiverTest extends AndroidTestCase {
public RemoteControlReceiverTest() {
super();
}
private RemoteControlReceiver mReceiver;
private String accountSettings;
@Override
protected void setUp() throws Exception
{
super.setUp();
mReceiver = new RemoteControlReceiver();
accountSettings = "<y>gmail</y><u></u><n>test</n><t>smtp+ssl+://::@:25</t><s>imap+ssl+://:test@:143</s>";
}
public void testStartActivity()
{
Intent addIntent = new Intent();
addIntent.setAction("com.kaseya.email.K9RemoteControl.addAccount");
addIntent.putExtra("accountSettings", accountSettings);
mReceiver.onReceive(getContext(), addIntent);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kaseya.email.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="3" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.kaseya.email" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
</manifest>