2017-09-03 4 views
0

現在、このライブラリを使用してアンドロイドでUIテストを実行しようとしています。 https://github.com/facebook/screenshot-tests-for-androidテストタスクに依存するカスタムのgradleプラグインを実行するには

は、私が使用してテストを実行します。

./gradlew verifyMode screenshotTests 

ディレクトリのルートに。

./gradlew test 

そして、私はそれがスクリーンショットのテストだけでなく、私のUIテストを実行したいと思います:

しかし、私が実行したいすべてがあります。これは可能ですか?現在のビルドファイル:

buildscript { 
    repositories { 
     jcenter() 
     mavenLocal() 
     mavenCentral() 
    } 

    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.0' 
     classpath 'com.facebook.testing.screenshot:plugin:0.4.2' 
    } 
} 

apply plugin: 'com.android.application' 
apply plugin: 'com.facebook.testing.screenshot' 

android { 
    compileSdkVersion 24 
    buildToolsVersion '24.0.3' 

    defaultConfig { 
     applicationId "sample" 
     minSdkVersion 16 
     targetSdkVersion 22 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "sample.TestRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    compile 'com.android.support:support-v4:24.2.0' 
    compile project(':library') 
    androidTestCompile 'com.android.support.test:runner:0.4' 
    androidTestCompile 'com.azimolabs.conditionwatcher:conditionwatcher:0.1' 
    androidTestCompile 'com.android.support.test:rules:0.4' 
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' 
    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0' 
    androidTestCompile 'com.google.dexmaker:dexmaker:1.0' 
    androidTestCompile 'org.mockito:mockito-core:1.10.17' 
    androidTestCompile 'com.android.support:support-annotations:24.2.1' 
} 

答えて

0

Gradleは、コマンドライン引数とその依存関係として指定されたタスクを実行します。

test { 
    dependsOn 'verifyMode', 'screenshotTests' 
} 

しかし、今のすべての実行を点に注意してください:あなただけのコマンドでtestタスクを指定し、まだタスクverifyModescreenshotTestsを実行したい場合はtestタスクの依存関係のように、あなたはこれらのタスクを登録することができますtestタスクはverifyMode,screenshotTestsとそれぞれの依存関係を実行させます。 testタスクはbuildタスクの依存関係であるため、gradle buildを呼び出すと、verifyModescreenshotTestsが実行されます。解決策として、すべてのあなたのテストタスクを収集ダミータスク、定義することができます。

task allTests { 
    dependsOn 'test', 'verifyMode', 'screenshotTests' 
} 

を今、あなたはgradle allTestsを呼び出すことができますし、Gradleではあなたが実行したいだけのタスクを実行します。

関連する問題