2016-12-14 20 views
0

コマンドラインからuiautomator 2.0をテストします。私の手順は以下の通りです:uiautomator 2.0を使用してテストを実行できませんでした。

  1. が計測プロジェクトを作成し、以下のコードは、次のとおりです。

    package com.android.uiautomator.client; 
    
    
    import org.junit.Before; 
    import org.junit.Test; 
    import org.junit.runner.RunWith; 
    import android.app.Application; 
    import android.app.Instrumentation; 
    import android.content.Context; 
    import android.support.test.InstrumentationRegistry; 
    import android.support.test.runner.AndroidJUnit4; 
    import android.test.ApplicationTestCase; 
    
    @RunWith(AndroidJUnit4.class) 
    public class Initialize { 
    
    @Test 
    public void testStartServer() { 
        System.out.println("this is the test"); 
    } 
    } 
    
  2. 使用gradlewは、AndroidエミュレータにテストAPKをインストールし、テストAPK

  3. を生成します

    adb shell push ${apkPath}/test.apk /data/local/tmp/com.android.test 
    
    adb shell pm install -r /data/local/tmp/com.android.test 
    
  4. テストa pkが正常にインストールされました。そして、私はインストールされたAPKを見つけることができます。インストール後

    adb shell pm list packages 
    
  5. 、私はエミュレータで計測をチェックし、私はテストAPKについての計測を見つけるcant't。これは、コマンドの実行に失敗につながる:

    adb shell am instrument -e class com.android.uiautomator.client.Initialize -w com.android.uiautomator.client.test/android.support.test.runner.AndroidJUnitRunner 
    

はそう、私は混乱しています。テストAPKをインストールした後に計測器を見つけることができないのはなぜですか?

答えて

0

あなたはアプリで利用可能なインストルメンテーションをチェックするために、あなたのAPPLICATIONIDでapplicationIdを交換

$ adb shell pm list instrumentation | grep 'target=applicationId' 

を実行する必要があります。

+0

はい、私はそれを試しました。しかし、私はまだインストールされたテストapkのための計測器を見つけることができません – kobe990

+0

その後、計測器はインストールされていないか、またはそのパッケージ用ではありません、grepフィルタを削除し、 –

関連する問題