Last active
December 17, 2017 23:22
-
-
Save SabagRonen/c442fd5808b944b1c5527fcdc771d9a5 to your computer and use it in GitHub Desktop.
dagger android injector post main activity tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(AndroidJUnit4::class) | |
class MainViewTests { | |
val mockUserAction = mock(MainContract.UserAction::class.java) | |
@get:Rule val activityTestRule = object : ActivityTestRule<MainActivity>(MainActivity::class.java, true, true) { | |
override fun beforeActivityLaunched() { | |
super.beforeActivityLaunched() | |
val myApp = InstrumentationRegistry.getTargetContext().applicationContext as MyApp | |
myApp.dispatchingActivityInjector = createFakeMainActivityInjector { | |
userAction = mockUserAction | |
} | |
} | |
} | |
@Test | |
fun clickOnFabCallToCreateTopic() { | |
onView(withId(R.id.fab)).perform(click()) | |
verify(mockUserAction).createTopic(view = activityTestRule.activity) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment