1. 程式人生 > >android 自動化測試之Robotium 測試apk時遇到的問題

android 自動化測試之Robotium 測試apk時遇到的問題

1.執行測試工程時提示:

        Test run failed: Permission Denial: starting instrumentation ComponentInfo{com.example.androidcalculator.test/android.test.InstrumentationTestRunner} from pid=724, uid=724 not allowed because package com.example.androidcalculator.test does not have a signature matching the target com.test

原因:被測程式與測試程式簽名包不同,

解決方案:需要使用相同的簽名檔案進行簽名。

2.執行測試工程時提示:

 java.lang.NullPointerException****

原因:Debug檢視發現 testCase的值為“null,通過反射沒有傳過來值”

解決方法:同樣是因為因為被測程式與測試程式簽名不一致導致

搜尋結果

  1. 3.執行測試工程時提示:

  2.        Test run failed: Unable to find instrumentation target package: com.example.action02

  3. 原因:被測程式的包名未找到,需要修改AndroidMainfest.xml的程式碼內容
  4. 解決方法:
  5.    <instrumentation
            android:name="android.test.InstrumentationTestRunner"
            android:targetPackage="被測程式包名" />

4.執行robotium 測試時提示“teardown 語句空指標異常”

程式碼:

protectedvoid tearDown()throwsException{super.tearDown();
        solo.finishOpenedActivities();}

應該修改為:

@Overrideprotected
void tearDown()throwsException{ solo.finishOpenedActivities();super.tearDown();}
因為super在前面時他不知道要去做什麼動作所以就提示為空異常