-
Notifications
You must be signed in to change notification settings - Fork 7
0. Considerations
-
If you get stuck,
Master
branch contains already solved tests forSuperHeroesLoginActivity
,SuperHeroesActivityTest
andSuperHeroDetailActivity
-
A DaggerMockRule is an utility to let you create Dagger 2 modules dynamically. In this case we are using it to create a new
MainModule
in this testing scope. Instead of returning real objects, this newMainModule
will returns the mock forSuperHeroesRepository
defined in this test. -
You will find some utilities to help you test RecyclerViews and Toolbars easily in:
app/src/androidTest/java/com/karumi/katasuperheroes/matchers
andapp/src/androidTest/java/com/karumi/katasuperheroes/recyclerview
.-
RecyclerViewInteraction
: provides an easy way to apply an Espresso matcher to all of the RecyclerView elementsRecyclerViewInteraction.<ITEM_TYPE>onRecyclerView(withId(R.id.recycler_view)) .withItems(A_LIST_OF_ITEMS) .check(new RecyclerViewInteraction.ItemViewAssertion<ITEM_TYPE>() { @Override public void check(ITEM_TYPE item, View view, NoMatchingViewException e) { matches(A_MATCHER).check(view, e); } });
-
RecyclerViewItemsCountMatcher
: a matcher that returns true if RecyclerView contains the expected number of elements. -
ToolbarMatcher
: a matcher that returns true if a Toolbar with expected title is found.
-