2016-07-31 3 views
2

에스프레소로 UI 테스트하는 방법을 배우고 있으며 의도 상태를 확인하고 싶습니다.Android 에스프레소 - 의도 된대로 allOf 메소드를 해결할 수 없습니다.

intended(allOf(
    hasAction(equalTo(Intent.ACTION_VIEW)), 
    hasCategories(hasItem(equalTo(Intent.CATEGORY_BROWSABLE))), 
    hasData(hasHost(equalTo("www.google.com"))), 
    hasExtras(allOf(
     hasEntry(equalTo("key1"), equalTo("value1")), 
     hasEntry(equalTo("key2"), equalTo("value2")))), 
     toPackage("com.android.browser"))); 

그러나 그것은 나에게 컴파일시 오류를 제공합니다 : I'w 작성 뭔가 같은 here의 예입니다 enter image description here . 이게 뭐가 잘못 됐어?

답변

2

현재 전체 샘플 코드를 확인할 수 있습니다 https://github.com/googlesamples/android-testing/blob/master/ui/espresso/IntentsBasicSample/app/src/androidTest/java/com/example/android/testing/espresso/BasicSample/DialerActivityTest.java

다음 수입으로 작동합니다 :

import static android.support.test.espresso.intent.Intents.intended; 
import static android.support.test.espresso.intent.matcher.BundleMatchers.hasEntry; 
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction; 
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasCategories; 
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasData; 
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasExtras; 
import static android.support.test.espresso.intent.matcher.IntentMatchers.toPackage; 
import static android.support.test.espresso.intent.matcher.UriMatchers.hasHost; 
import static org.hamcrest.Matchers.equalTo; 
import static org.hamcrest.Matchers.hasItem; 
import static org.hamcrest.core.AllOf.allOf; 
관련 문제