2016-04-01 14 views
1

私は、エスプレッソをAndroidスタジオで動作させるのにいくつかの重大な問題を抱えています。エスプレッソの方法が解決されていません

私はテストのために次のコードを持っている:

残念ながら
import android.support.test.rule.ActivityTestRule; 
import android.support.test.runner.AndroidJUnit4; 

import com.nullpointexecutioners.buzzfilms.activities.WelcomeActivity; 

import org.junit.Rule; 
import org.junit.Test; 
import org.junit.runner.RunWith; 

@RunWith(AndroidJUnit4.class) 
public class ApplicationTest { 

    @Rule 
    public ActivityTestRule<WelcomeActivity> mActivityRule = new ActivityTestRule<>(WelcomeActivity.class); 

    @Test 
    public void testTitle() { 
     onView(withText("Buzz Films")).check(matches(isDisplayed())); 
    } 
} 

を、onViewwithTextmatches、およびisDisplayed()すべては私の方法は解決できないというエラーメッセージを与えます。私はstatic import文の束をしたらそれを働かせることができます - しかし、私はそれに頼りたくありませんでした。 (つまり、私はEspresso.onView(ViewMatchers.withText(...)...と書く必要があります)

私は自分の問題に関してどのような情報が得られたかに基づいてbuild.gradleファイルが正しいと思っています。

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.nullpointexecutioners.buzzfilms" 
     minSdkVersion 23 
     targetSdkVersion 23 
     versionCode 7 
     versionName "2.0" //bump this up per milestone 

     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
      zipAlignEnabled true 
     } 
     debug { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
      zipAlignEnabled false 
     } 
    } 
    packagingOptions { 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE-FIREBASE.txt' 
     exclude 'META-INF/NOTICE' 
    } 
    testOptions { 
     unitTests.returnDefaultValues = true 
     unitTests.all { 
      // All the usual Gradle options. 
      jvmArgs '-XX:MaxPermSize=256m' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    androidTestCompile 'com.android.support:support-annotations:23.2.1' 
    androidTestCompile 'com.android.support.test:rules:0.5' 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    } 
    androidTestCompile('com.android.support.test.espresso:espresso-intents:2.2.2') { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    } 
    androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') { 
     exclude group: 'com.android.support', module: 'support-annotations' 
     exclude group: 'com.android.support', module: 'appcompat' 
     exclude group: 'com.android.support', module: 'support-v4' 
     exclude module: 'recyclerview-v7' 
    } 
    androidTestCompile('com.android.support.test.espresso:espresso-web:2.2.2') { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    } 
    androidTestCompile ('com.android.support.test:runner:0.5') { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    } 
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1' 


    compile('com.github.afollestad.material-dialogs:core:[email protected]') { 
     transitive = true 
    } 
    compile('com.mikepenz:materialdrawer:[email protected]') { 
     transitive = true 
    } 
    compile 'com.android.support:design:23.1.1' 
    compile 'com.android.support:support-v4:23.2.1' 
    compile 'com.jakewharton:butterknife:7.0.1' 
    compile 'com.mikepenz:iconics-core:[email protected]' 
    compile 'com.mikepenz:google-material-typeface:[email protected]' 
    compile 'com.firebase:firebase-client-android:2.3.1' 
    compile 'com.android.support:cardview-v7:23.2.1' 
    compile 'com.android.support:recyclerview-v7:23.2.1' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.android.support:palette-v7:23.2.1' 
    compile 'com.github.florent37:picassopalette:[email protected]' 
    compile 'com.squareup.okhttp:okhttp:2.4.0' 
    compile 'com.github.channguyen:rsv:1.0.1' 
} 
+0

静的インポートを使用する必要があります。それが標準的な習慣です。 – yogurtearl

+0

@yogurtearlそれでもうまくいきません。 – Nxt3

+0

スタティックインポートを含めるように質問を更新できますか? – yogurtearl

答えて

0

静的インポートが必要です。

Googleの公式サンプルコードでは、静的なインポートが使用されています。静的なインポートは、流暢なAPIの標準的な習慣です。

Sample Espresso Test

関連する問題