Skip to content

Instantly share code, notes, and snippets.

@kozmi55
Last active September 3, 2018 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kozmi55/ae2a0a13c1f5f5d1b2b8042d2a630229 to your computer and use it in GitHub Desktop.
Save kozmi55/ae2a0a13c1f5f5d1b2b8042d2a630229 to your computer and use it in GitHub Desktop.
@RunWith(AndroidJUnit4::class)
class UserListFragmentTest {
@Rule
@JvmField
var activityRule = ActivityTestRule(MainActivity::class.java, true, false)
@Mock
private lateinit var mockUserRepository: UserRepository
private fun withRecyclerView(recyclerViewId: Int): RecyclerViewMatcher {
return RecyclerViewMatcher(recyclerViewId)
}
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
val instrumentation = InstrumentationRegistry.getInstrumentation()
val app = instrumentation.targetContext.applicationContext as TestApplication
DaggerTestApplicationComponent
.builder()
.appModule(TestApplicationModule(mockUserRepository))
.create(app)
.inject(app)
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment