androidandroid-intentandroid-espresso

Android espresso - cannot resolve allOf method for intended


I'm learning how to UI testing with Espresso and I wanted to verify state of the intent. I'w written something like:

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")));

But it gives me the compliation error: enter image description here That's the example from here. What's wrong with this?


Solution

  • You can check full sample code here: https://github.com/android/testing-samples/blob/cdb134f5c409e3a1e401d090202bb4b03bc4e760/ui/espresso/IntentsBasicSample/app/src/sharedTest/java/com/example/android/testing/espresso/IntentsBasicSample/DialerActivityTest.java

    Should work with next imports:

    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;