1
我正在使用Robotium在Eclipse的自動化測試(運行它作爲一個Android JUnit測試),當我第一次啓動該應用程序不會在前臺運行的仿真器和測試失敗。如果我把仿真器打開,按「主菜單」按鈕,然後運行它工作正常的測試。測試是在一個記事本的測試項目中運行一些事件。Android模擬器無法開展活動前景
以推動應用推到前臺時,第一次打開模擬器的任何解決方案?
這裏的清單從測試項目
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jayway.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-library android:name="android.test.runner" />
下面是從實際項目
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.notepad" >
<application android:icon="@drawable/app_notes"
android:label="@string/app_name" >
<provider android:name="NotePadProvider"
android:authorities="com.example.notepad.provider.NotePad" />
<activity android:name="NotesList"
android:label="@string/title_notes_list">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
</activity>
<activity android:name="NoteEditor"
android:theme="@android:style/Theme.Light"
android:configChanges="keyboardHidden|orientation">
<!-- This filter says that we can view or edit the data of
a single note -->
<intent-filter android:label="@string/resolve_edit">
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="com.android.notes.action.EDIT_NOTE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
</activity>
<activity android:name="NotesLiveFolder" android:label="@string/live_folder_name"
android:icon="@drawable/live_folder_notes">
<intent-filter>
<action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="10"/>
</manifest>
</application>
<uses-sdk android:minSdkVersion="10" />
<instrumentation android:targetPackage="com.example.android.notepad" android:name="android.test.InstrumentationTestRunner" />
</manifest>
我可以建議你添加添加一些相關的代碼;你在測試什麼?並可能是某些日誌輸出供其他人使用。此外,在[Activity生命週期](http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle)中的哪個點你的應用程序被卡住了,假設你在調試中運行它來檢查?如果沒有,也許[這個問題](http://stackoverflow.com/questions/5504632/how-can-i-tell-if-android-app-is-running-in-the-foreground)可以提供幫助。 – Chilledrat 2012-04-24 20:43:03
我把清單XML代碼上面,這個測試不會在調試運行它是一個JUnit測試應用程序。日誌很長,沒有錯誤。當它到達主屏幕時,該應用程序無法通過模擬器打開,您需要按下應用程序的菜單按鈕才能到達前臺。 – 2012-04-25 08:48:27