Espresso and Integration Testing: clarifying steps

Here’s a complete listing for the integration test described in the “For the More Curious: Espresso and Integration Testing” section.

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

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

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.anything;

@RunWith(AndroidJUnit4.class)
public class BeatBoxActivityTest {

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

    @Test
    public void showsFirstFileName() {
        onView(withText("65_cjipie")).check(matches(anything()));
    }

}

Hi ybakos,

According to the method Is.is() choosen in the previous part of the chapter, I chose “org.hamcrest.core.IsAnything.anything()” instead of “org.hamcrest.Matchers.anything()”.

However, I’m not sure what’s the difference between these two methods.

http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matchers.html#anything()
http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/core/IsAnything.html#anything()