Created
August 30, 2018 16:47
-
-
Save kozmi55/a6f12fda5488d02ee3d8c0d35ab663a2 to your computer and use it in GitHub Desktop.
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 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 CustomApplication | |
val testComponent = DaggerTestApplicationComponent.builder() | |
.testApplicationModule(TestApplicationModule(mockUserRepository)) | |
.build() | |
app.component = testComponent | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment