2016-09-15 5 views
0

私はuiautomator 1.0.1でeclispeを使ってjarファイルを生成し、私のセットアップで使用していました。 誰でもAndroid StudioでUiautomator 2.0に切り替えるための手順を段階的に確認できる適切なソースを指し示すことができます。UIautomator 2.0とAndroid Studio 2.xを使用しています

答えて

0

、あなたのGradleプロジェクトにAndroidのテストのサポートライブラリを使用して、あなたのbuild.gradleファイルでこれらの依存関係を追加するには:

dependencies { 
    androidTestCompile 'com.android.support.test:runner:0.4' 
    // Set this dependency to use JUnit 4 rules 
    androidTestCompile 'com.android.support.test:rules:0.4' 
    // Set this dependency to build and run Espresso tests 
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' 
    // Set this dependency to build and run UI Automator tests 
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' 
} 

はまた、あなたはあなたのGradleプロジェクトのデフォルトのテスト機器ランナーとしてJUnitRunnerを設定する必要があります(UI Automator 2.0はandroid.test.InstrumentationTestRunnerの代わりにandroid.support.test.runner.AndroidJUnitRunnerを使用します)。

android { 
    defaultConfig { 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
} 

詳細はhereです。

+0

実際には、どのテストランナーでもUiAutomatorを使用できます。 AndroidJUnitRunnerである必要はありません。たとえば、InstrumentationTestRunnerを使用することもできます。 –

+0

私が知る限り、 'InstrumentationTestRunner class'は、JUnit 3またはJUnit 4スタイルのテストクラスを実行できる 'AndroidJUnitRunner class'と比較して、JUnit 3テストのみをサポートしています。しかし、私はUIAutomatorをどのテストランナーとも使用できることに同意します。 –

関連する問題