Skip to content

Instantly share code, notes, and snippets.


Mohammed Audhil Audhil

Block or report user

Report or block Audhil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View AppRepositoryInjectTest.kt
class AppRepositoryInjectTest {
lateinit var appAPIs: AppAPIs
fun setUp() {
val component = DaggerTestAppComponent.builder()
View TestAppComponent.kt
modules = [
interface TestAppComponent : ApplicationComponent {
fun into(appRepositoryTest: AppRepositoryInjectNamedTest)
fun into(appRepositoryTest: AppRepositoryInjectTest)
fun into(baseTest: BaseTest)
View TestApplicationModule.kt
class TestApplicationModule(delegate: GDelegate) : ApplicationModule(delegate) {
override fun giveAppAPIs(): AppAPIs = mockk()
override fun giveRetrofitService(okHttpClient: OkHttpClient): AppAPIs = mockk()
override fun giveOkHttpClient(loggingInterceptor: HttpLoggingInterceptor): OkHttpClient = mockk()
override fun giveLoggingInterceptor(): HttpLoggingInterceptor = mockk()
View build.gradle
apply plugin: ''
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion rootProject.compileSdkVersion
View ApplicationComponent.kt
modules = [
interface ApplicationComponent {
fun inject(into: GDelegate)
fun inject(into: BaseRepository)
fun inject(into: BaseViewModel)
View ApplicationModule.kt
open class ApplicationModule(private val application: GDelegate) {
fun giveContext(): Context = this.application
fun givePackageManager(): PackageManager = application.packageManager
View somefile.kt
class MainActivity : AppCompatActivity() {
@Inject lateinit var info: Info
override fun onCreate(savedInstanceState: Bundle?) {
text_view.text = info.text
View gist:0570c90fa9dc56b0e67b1f9cfd6b6d98
# development way
if __name__ == '__main__':
## server on
## (invisible across the network) won't work on other device, other than development machine
# suggested way
if __name__ == '__main__':'', port=5000)
View BasicActivityTest.kt
class BasicActivityTest {
private lateinit var mockServer: MockWebServer
val rule = ActivityTestRule(, false, false)
View MockServerDispatcher.kt
class MockServerDispatcher {
// response dispatcher
class ResponseDispatcher : Dispatcher() {
override fun dispatch(request: RecordedRequest): MockResponse {
if (request.path.equals("/todos/1", true))
return MockResponse().setResponseCode(200).setBody(
"{\n" +
" \"id\" : 1,\n" +
" \"title\" : \"delectus aut autem\",\n" +
You can’t perform that action at this time.